Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Unified Diff: gin/wrappable.cc

Issue 1161923004: Reland: Plugin Placeholders: Refactor for platforms that don't support plugins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge to solve patch conflicts again... Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gin/wrappable.cc
diff --git a/gin/wrappable.cc b/gin/wrappable.cc
index 27c58dfdb01fe9c804f0e9157b67e15d5c911552..53a2f2549f1a809732adda9b9e87159b77d9116d 100644
--- a/gin/wrappable.cc
+++ b/gin/wrappable.cc
@@ -4,7 +4,6 @@
#include "gin/wrappable.h"
-#include "base/logging.h"
#include "gin/object_template_builder.h"
#include "gin/per_isolate_data.h"
@@ -36,7 +35,7 @@ void WrappableBase::SecondWeakCallback(
}
v8::Local<v8::Object> WrappableBase::GetWrapperImpl(v8::Isolate* isolate,
- WrapperInfo* info) {
+ WrapperInfo* info) {
if (!wrapper_.IsEmpty()) {
return v8::Local<v8::Object>::New(isolate, wrapper_);
}
@@ -59,35 +58,12 @@ v8::Local<v8::Object> WrappableBase::GetWrapperImpl(v8::Isolate* isolate,
return wrapper;
}
wrapper->SetAlignedPointerInInternalField(kWrapperInfoIndex, info);
+ // This needs to be adjusted with downcasting on retrieval, as this points
+ // to the WrapperBase object, which may not be the start of the whole object.
wrapper->SetAlignedPointerInInternalField(kEncodedValueIndex, this);
wrapper_.Reset(isolate, wrapper);
wrapper_.SetWeak(this, FirstWeakCallback, v8::WeakCallbackType::kParameter);
return wrapper;
}
-namespace internal {
-
-void* FromV8Impl(v8::Isolate* isolate, v8::Local<v8::Value> val,
- WrapperInfo* wrapper_info) {
- if (!val->IsObject())
- return NULL;
- v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(val);
- WrapperInfo* info = WrapperInfo::From(obj);
-
- // If this fails, the object is not managed by Gin. It is either a normal JS
- // object that's not wrapping any external C++ object, or it is wrapping some
- // C++ object, but that object isn't managed by Gin (maybe Blink).
- if (!info)
- return NULL;
-
- // If this fails, the object is managed by Gin, but it's not wrapping an
- // instance of the C++ class associated with wrapper_info.
- if (info != wrapper_info)
- return NULL;
-
- return obj->GetAlignedPointerFromInternalField(kEncodedValueIndex);
-}
-
-} // namespace internal
-
} // namespace gin

Powered by Google App Engine
This is Rietveld 408576698