Skip to content
  • abarth@chromium.org's avatar
    [Gin] Add a mechanism for wrapping C++ object · 93f9f360
    abarth@chromium.org authored
    This CL adds a mechanism for wrapping C++ objects to Gin. The approach in this
    CL is similar to Blink's ScriptWrappable class, with a couple of differences:
    
    1) gin::Wrappable has a vtable whereas Blink's ScriptWrappable class does not.
       Having a vtable in this base class lets us simplify a large number of
       concerns. We've talked about adding a vtable to ScriptWrappable but have
       avoided it because Blink creates many thousands of wrapped objects. When we
       refactor Blink to use Gin, we can still support the non-vtable approach, but
       most clients of Gin will want the simpler approach.
    
    2) In Gin, we've bound together the notion of being reference counted with the
       notion of being wrappable from JavaScript. In Blink, those concepts are
       separate because we don't want to introduce a virtual destructor for
       ScriptWrappable. However, because gin::Wrappable already has a vtable,
       adding a virtual destructor is relatively cheap.
    
    Actually wrapping a C++ object still takes too much typing, but we can improve
    that in future CLs.
    
    R=jochen@chromium.org
    BUG=317398
    
    Review URL: https://codereview.chromium.org/79203004
    
    git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236555 0039d316-1c4b-4281-b951-d872f2087c98
    93f9f360