[common] Create C++ wrapper to replace ExtensionAdapater
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Fri, 20 Sep 2013 16:30:41 +0000 (13:30 -0300)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Mon, 23 Sep 2013 17:06:29 +0000 (14:06 -0300)
commit591d2a2e0246f69d46b577550d3d5139d3ed1cf9
tree6e202171410a8458ec169a95d2ed2253005e6b32
parent94fecb3c9d83499c2759b741ec63a0948d075499
[common] Create C++ wrapper to replace ExtensionAdapater

Current ExtensionAdapter ends up merging the concept of extension and
instance (before called Context) together, and this causes confusion
understanding the execution of the code.

The new approach is to create a C++ pair of classes that represent
Extension and Instance. This mimics what we have inside Crosswalk, and
also is pretty much the same approach PPAPI constructs its C++ API as
well.

One nice consequence is that the subclass of Extension can be used to
store objects shared by all instances -- since it have the correct
lifetime. We can get rid of most ad-hoc singleton implementations in the
code.

One downside is that we resort to virtual methods in this new
approach. Even though the overhead is low, if this proves to be a
bottleneck for a specific extension, it's easy to fallback to using the
C API directly instead of the convenience.
common/extension.cc [new file with mode: 0644]
common/extension.h [new file with mode: 0644]