Commit 2658bb52 authored by haraken's avatar haraken Committed by Commit bot

Rename ScriptWrappable::newLocalWrapper to ScriptWrappable::mainWorldWrapper

To clarify that it returns a main world's wrapper.
To avoid the method from being used randomly, this CL makes the method private.

BUG=
CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2021203002
Cr-Commit-Position: refs/heads/master@{#396796}
parent b849256f
......@@ -106,7 +106,7 @@ public:
static v8::Local<v8::Object> getWrapper(Node* node, v8::Isolate* isolate)
{
if (canUseScriptWrappable(node))
return ScriptWrappable::fromNode(node)->newLocalWrapper(isolate);
return ScriptWrappable::fromNode(node)->mainWorldWrapper(isolate);
return current(isolate).get(ScriptWrappable::fromNode(node), isolate);
}
......@@ -149,7 +149,7 @@ public:
v8::Local<v8::Object> get(ScriptWrappable* object, v8::Isolate* isolate)
{
if (m_isMainWorld)
return object->newLocalWrapper(isolate);
return object->mainWorldWrapper(isolate);
return m_wrapperMap->newLocal(isolate, object);
}
......
......@@ -12,7 +12,7 @@ namespace blink {
struct SameSizeAsScriptWrappable {
virtual ~SameSizeAsScriptWrappable() { }
v8::Persistent<v8::Object> m_wrapper;
v8::Persistent<v8::Object> m_mainWorldWrapper;
};
static_assert(sizeof(ScriptWrappable) <= sizeof(SameSizeAsScriptWrappable), "ScriptWrappable should stay small");
......@@ -39,7 +39,7 @@ v8::Local<v8::Object> ScriptWrappable::associateWithWrapper(v8::Isolate* isolate
void ScriptWrappable::markWrapper(v8::Isolate* isolate) const
{
if (containsWrapper())
ScriptWrappableVisitor::markWrapper(&m_wrapper, isolate);
ScriptWrappableVisitor::markWrapper(&m_mainWorldWrapper, isolate);
}
} // namespace blink
......@@ -100,24 +100,19 @@ public:
{
ASSERT(!wrapper.IsEmpty());
if (UNLIKELY(containsWrapper())) {
wrapper = newLocalWrapper(isolate);
wrapper = mainWorldWrapper(isolate);
return false;
}
m_wrapper.Reset(isolate, wrapper);
wrapperTypeInfo->configureWrapper(&m_wrapper);
m_wrapper.SetWeak();
m_mainWorldWrapper.Reset(isolate, wrapper);
wrapperTypeInfo->configureWrapper(&m_mainWorldWrapper);
m_mainWorldWrapper.SetWeak();
ASSERT(containsWrapper());
return true;
}
v8::Local<v8::Object> newLocalWrapper(v8::Isolate* isolate) const
{
return v8::Local<v8::Object>::New(isolate, m_wrapper);
}
bool isEqualTo(const v8::Local<v8::Object>& other) const
{
return m_wrapper == other;
return m_mainWorldWrapper == other;
}
// Provides a way to convert Node* to ScriptWrappable* without including
......@@ -139,16 +134,16 @@ public:
bool setReturnValue(v8::ReturnValue<v8::Value> returnValue)
{
returnValue.Set(m_wrapper);
returnValue.Set(m_mainWorldWrapper);
return containsWrapper();
}
void setReference(const v8::Persistent<v8::Object>& parent, v8::Isolate* isolate)
{
isolate->SetReference(parent, m_wrapper);
isolate->SetReference(parent, m_mainWorldWrapper);
}
bool containsWrapper() const { return !m_wrapper.IsEmpty(); }
bool containsWrapper() const { return !m_mainWorldWrapper.IsEmpty(); }
/**
* Mark wrapper of this ScriptWrappable as alive in V8. Only marks
......@@ -169,7 +164,18 @@ public:
// already broken), we must not hit the RELEASE_ASSERT.
private:
v8::Persistent<v8::Object> m_wrapper;
// These classes are exceptionally allowed to use mainWorldWrapper().
friend class DOMDataStore;
friend class V8HiddenValue;
friend class V8PrivateProperty;
friend class WebGLRenderingContextBase;
v8::Local<v8::Object> mainWorldWrapper(v8::Isolate* isolate) const
{
return v8::Local<v8::Object>::New(isolate, m_mainWorldWrapper);
}
v8::Persistent<v8::Object> m_mainWorldWrapper;
};
// Defines 'wrapperTypeInfo' virtual method which returns the WrapperTypeInfo of
......
......@@ -50,7 +50,7 @@ bool V8HiddenValue::deleteHiddenValue(ScriptState* scriptState, v8::Local<v8::Ob
v8::Local<v8::Value> V8HiddenValue::getHiddenValueFromMainWorldWrapper(ScriptState* scriptState, ScriptWrappable* wrappable, v8::Local<v8::String> key)
{
v8::Local<v8::Object> wrapper = wrappable->newLocalWrapper(scriptState->isolate());
v8::Local<v8::Object> wrapper = wrappable->mainWorldWrapper(scriptState->isolate());
return wrapper.IsEmpty() ? v8::Local<v8::Value>() : getHiddenValue(scriptState, wrapper, key);
}
......
......@@ -13,7 +13,7 @@ namespace blink {
v8::Local<v8::Value> V8PrivateProperty::Symbol::getFromMainWorld(ScriptState* scriptState, ScriptWrappable* scriptWrappable)
{
v8::Local<v8::Object> wrapper = scriptWrappable->newLocalWrapper(scriptState->isolate());
v8::Local<v8::Object> wrapper = scriptWrappable->mainWorldWrapper(scriptState->isolate());
return wrapper.IsEmpty() ? v8::Local<v8::Value>() : get(scriptState->context(), wrapper);
}
......
......@@ -6334,7 +6334,7 @@ void WebGLRenderingContextBase::preserveObjectWrapper(ScriptState* scriptState,
persistentCache->set(isolate, v8::Array::New(isolate));
V8HiddenValue::setHiddenValue(
scriptState,
sourceObject->newLocalWrapper(isolate),
sourceObject->mainWorldWrapper(isolate),
hiddenValueName,
persistentCache->newLocal(isolate));
// It is important to mark the persistent cache as weak
......@@ -6346,7 +6346,7 @@ void WebGLRenderingContextBase::preserveObjectWrapper(ScriptState* scriptState,
v8::Local<v8::Array> localCache = persistentCache->newLocal(isolate);
if (targetObject) {
v8CallOrCrash(localCache->Set(scriptState->context(), index, targetObject->newLocalWrapper(isolate)));
v8CallOrCrash(localCache->Set(scriptState->context(), index, targetObject->mainWorldWrapper(isolate)));
} else {
v8CallOrCrash(localCache->Set(scriptState->context(), index, v8::Null(isolate)));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment