summaryrefslogtreecommitdiffstats
path: root/gin/wrappable.h
diff options
context:
space:
mode:
authortommycli <tommycli@chromium.org>2015-06-11 15:20:14 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-11 22:21:17 +0000
commit425d6965196e7448a2ba9180a3fd2f5b08f5b329 (patch)
tree0799c08a8aa683b6196ebbf7f3963b29731abbcc /gin/wrappable.h
parent60b17299b23088c43179c092a26977cdb294b0da (diff)
downloadchromium_src-425d6965196e7448a2ba9180a3fd2f5b08f5b329.zip
chromium_src-425d6965196e7448a2ba9180a3fd2f5b08f5b329.tar.gz
chromium_src-425d6965196e7448a2ba9180a3fd2f5b08f5b329.tar.bz2
Reland: Plugin Placeholders: Refactor for platforms that don't support plugins
This patch removes a lot of plugin placeholder code from builds that don't support plugins (enable_plugins==0). This is a reland of https://codereview.chromium.org/1126073003/. See patchsets for fixes of the crashes. BUG=493889 TBR= Review URL: https://codereview.chromium.org/1161923004 Cr-Commit-Position: refs/heads/master@{#334054}
Diffstat (limited to 'gin/wrappable.h')
-rw-r--r--gin/wrappable.h28
1 files changed, 15 insertions, 13 deletions
diff --git a/gin/wrappable.h b/gin/wrappable.h
index cd4d30e..f7d82b0 100644
--- a/gin/wrappable.h
+++ b/gin/wrappable.h
@@ -12,15 +12,6 @@
namespace gin {
-namespace internal {
-
-GIN_EXPORT void* FromV8Impl(v8::Isolate* isolate,
- v8::Local<v8::Value> val,
- WrapperInfo* info);
-
-} // namespace internal
-
-
// Wrappable is a base class for C++ objects that have corresponding v8 wrapper
// objects. To retain a Wrappable object on the stack, use a gin::Handle.
//
@@ -51,8 +42,20 @@ GIN_EXPORT void* FromV8Impl(v8::Isolate* isolate,
// wrapper for the object. If clients fail to create a wrapper for a wrappable
// object, the object will leak because we use the weak callback from the
// wrapper as the signal to delete the wrapped object.
-template<typename T>
-class Wrappable;
+//
+// Wrappable<T> explicitly does not support further subclassing of T.
+// Subclasses of Wrappable<T> should be declared final. Because Wrappable<T>
+// caches the object template using &T::kWrapperInfo as the key, all subclasses
+// would share a single object template. This will lead to hard to debug crashes
+// that look like use-after-free errors.
+
+namespace internal {
+
+GIN_EXPORT void* FromV8Impl(v8::Isolate* isolate,
+ v8::Local<v8::Value> val,
+ WrapperInfo* info);
+
+} // namespace internal
class ObjectTemplateBuilder;
@@ -62,6 +65,7 @@ class GIN_EXPORT WrappableBase {
WrappableBase();
virtual ~WrappableBase();
+ // Overrides of this method should be declared final and not overridden again.
virtual ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate* isolate);
v8::Local<v8::Object> GetWrapperImpl(v8::Isolate* isolate,
@@ -83,8 +87,6 @@ template<typename T>
class Wrappable : public WrappableBase {
public:
// Retrieve (or create) the v8 wrapper object cooresponding to this object.
- // To customize the wrapper created for a subclass, override GetWrapperInfo()
- // instead of overriding this function.
v8::Local<v8::Object> GetWrapper(v8::Isolate* isolate) {
return GetWrapperImpl(isolate, &T::kWrapperInfo);
}