Commit 376a8159 authored by haraken@chromium.org's avatar haraken@chromium.org

Remove m_domDataStoreList from V8PerIsolateData

- This CL removes V8PerIsolateData::m_domDataStoreList and related methods.

- The only customer of these methods is SerializedScriptValue::neuterBinding(). This CL replaces it to use DOMWrapperWorld::allWorldsInMainThread() instead.

BUG=341032
NOTRY=true

Review URL: https://codereview.chromium.org/182513003

git-svn-id: svn://svn.chromium.org/blink/trunk@168347 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0e726fa8
......@@ -41,13 +41,11 @@ DOMDataStore::DOMDataStore(bool isMainWorld)
: m_isMainWorld(isMainWorld)
, m_wrapperMap(v8::Isolate::GetCurrent()) // FIXME Don't call GetCurrent twice.
{
V8PerIsolateData::current()->registerDOMDataStore(this);
}
DOMDataStore::~DOMDataStore()
{
ASSERT(!m_isMainWorld); // We never actually destruct the main world's DOMDataStore.
V8PerIsolateData::current()->unregisterDOMDataStore(this);
m_wrapperMap.clear();
}
......
......@@ -83,7 +83,7 @@ static WorldMap& isolatedWorldMap()
return map;
}
void DOMWrapperWorld::getAllWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& worlds)
void DOMWrapperWorld::allWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& worlds)
{
ASSERT(isMainThread());
worlds.append(mainWorld());
......
......@@ -63,7 +63,7 @@ public:
~DOMWrapperWorld();
static bool isolatedWorldsExist() { return isolatedWorldCount; }
static void getAllWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& worlds);
static void allWorldsInMainThread(Vector<RefPtr<DOMWrapperWorld> >& worlds);
static DOMWrapperWorld* world(v8::Handle<v8::Context> context)
{
......
......@@ -42,6 +42,7 @@
#include "bindings/v8/ScriptState.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8Utilities.h"
#include "bindings/v8/WorkerScriptController.h"
#include "bindings/v8/custom/V8ArrayBufferCustom.h"
#include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
#include "bindings/v8/custom/V8DataViewCustom.h"
......@@ -2322,12 +2323,21 @@ SerializedScriptValue::SerializedScriptValue()
{
}
inline void neuterBinding(ArrayBuffer* object)
static void neuterArrayBufferInAllWorlds(ArrayBuffer* object)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
Vector<DOMDataStore*>& allStores = V8PerIsolateData::from(isolate)->allStores();
for (size_t i = 0; i < allStores.size(); i++) {
v8::Handle<v8::Object> wrapper = allStores[i]->get<V8ArrayBuffer>(object, isolate);
if (isMainThread()) {
Vector<RefPtr<DOMWrapperWorld> > worlds;
DOMWrapperWorld::allWorldsInMainThread(worlds);
for (size_t i = 0; i < worlds.size(); i++) {
v8::Handle<v8::Object> wrapper = worlds[i]->domDataStore().get<V8ArrayBuffer>(object, isolate);
if (!wrapper.IsEmpty()) {
ASSERT(wrapper->IsArrayBuffer());
v8::Handle<v8::ArrayBuffer>::Cast(wrapper)->Neuter();
}
}
} else {
v8::Handle<v8::Object> wrapper = WorkerScriptController::controllerForContext(isolate)->world()->domDataStore().get<V8ArrayBuffer>(object, isolate);
if (!wrapper.IsEmpty()) {
ASSERT(wrapper->IsArrayBuffer());
v8::Handle<v8::ArrayBuffer>::Cast(wrapper)->Neuter();
......@@ -2360,7 +2370,7 @@ PassOwnPtr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValu
return nullptr;
}
neuterBinding(arrayBuffers[i].get());
neuterArrayBufferInAllWorlds(arrayBuffers[i].get());
}
return contents.release();
}
......
......@@ -82,20 +82,6 @@ public:
v8::Persistent<v8::Value>& ensureLiveRoot();
DOMDataStoreList& allStores() { return m_domDataStoreList; }
void registerDOMDataStore(DOMDataStore* domDataStore)
{
ASSERT(m_domDataStoreList.find(domDataStore) == kNotFound);
m_domDataStoreList.append(domDataStore);
}
void unregisterDOMDataStore(DOMDataStore* domDataStore)
{
ASSERT(m_domDataStoreList.find(domDataStore) != kNotFound);
m_domDataStoreList.remove(m_domDataStoreList.find(domDataStore));
}
int recursionLevel() const { return m_recursionLevel; }
int incrementRecursionLevel() { return ++m_recursionLevel; }
int decrementRecursionLevel() { return --m_recursionLevel; }
......@@ -137,8 +123,6 @@ private:
ScopedPersistent<v8::FunctionTemplate> m_toStringTemplate;
OwnPtr<StringCache> m_stringCache;
Vector<DOMDataStore*> m_domDataStoreList;
ScopedPersistent<v8::Value> m_liveRoot;
ScopedPersistent<v8::Context> m_regexContext;
......
......@@ -94,6 +94,7 @@ namespace WebCore {
ScriptValue evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, WorkerGlobalScopeExecutionState*);
v8::Isolate* isolate() const { return m_isolate; }
DOMWrapperWorld* world() const { return m_world.get(); }
v8::Local<v8::Context> context() { return m_perContextData ? m_perContextData->context() : v8::Local<v8::Context>(); }
// Send a notification about current thread is going to be idle.
......
......@@ -1443,7 +1443,7 @@ void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
InspectorInstrumentation::didClearWindowObjectInMainWorld(m_frame);
Vector<RefPtr<DOMWrapperWorld> > worlds;
DOMWrapperWorld::getAllWorldsInMainThread(worlds);
DOMWrapperWorld::allWorldsInMainThread(worlds);
for (size_t i = 0; i < worlds.size(); ++i)
m_client->dispatchDidClearWindowObjectInWorld(worlds[i].get());
}
......
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