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

Unified Diff: Source/bindings/v8/DOMWrapperWorld.h

Issue 182903003: Make DOMWrapperWorld::current() callable from workers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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
« no previous file with comments | « no previous file | Source/bindings/v8/DOMWrapperWorld.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/DOMWrapperWorld.h
diff --git a/Source/bindings/v8/DOMWrapperWorld.h b/Source/bindings/v8/DOMWrapperWorld.h
index 17f23ffdc9e8fbf0a537a457fa62a43b9054ce9d..00abab7aac70ee154a863336e81ea347d6bce7fb 100644
--- a/Source/bindings/v8/DOMWrapperWorld.h
+++ b/Source/bindings/v8/DOMWrapperWorld.h
@@ -34,11 +34,12 @@
#include "bindings/v8/V8DOMActivityLogger.h"
#include "bindings/v8/V8PerContextData.h"
#include "platform/weborigin/SecurityOrigin.h"
-#include <v8.h>
+#include "wtf/MainThread.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
#include "wtf/text/WTFString.h"
+#include <v8.h>
namespace WebCore {
@@ -68,12 +69,24 @@ public:
static DOMWrapperWorld* world(v8::Handle<v8::Context> context)
{
- ASSERT(contextHasCorrectPrototype(context));
dcarney 2014/02/27 17:03:44 This ASSERT has saved us a lot of debugging in the
haraken 2014/02/28 00:06:25 Done. Reverted back the ASSERT.
- return V8PerContextDataHolder::from(context)->world();
+ V8PerContextDataHolder* contextHolder = V8PerContextDataHolder::from(context);
+ return contextHolder ? contextHolder->world() : 0;
}
// Will return null if there is no DOMWrapperWorld for the current v8::Context
- static DOMWrapperWorld* current(v8::Isolate*);
+ static DOMWrapperWorld* current(v8::Isolate* isolate)
+ {
+ v8::Handle<v8::Context> context = isolate->GetCurrentContext();
+ if (context.IsEmpty()) {
+ // It's possible that DOMWrapperWorld::current() is called while window is being initialized.
+ // To make DOMWrapperWorld::current() workable during the initialization phase,
+ // we cache the world of the initializing window on worldOfInitializingWindow.
+ // If there is no initiazing window, worldOfInitializingWindow is 0.
+ return worldOfInitializingWindow;
+ }
+ return world(context);
+ }
+
static DOMWrapperWorld* mainWorld();
// Associates an isolated world (see above for description) with a security
@@ -108,11 +121,17 @@ public:
int extensionGroup() const { return m_extensionGroup; }
DOMDataStore& domDataStore() { return *m_domDataStore; }
-private:
- static unsigned isolatedWorldCount;
+ static void setWorldOfInitializingWindow(DOMWrapperWorld* world)
+ {
+ ASSERT(isMainThread());
+ worldOfInitializingWindow = world;
+ }
+private:
DOMWrapperWorld(int worldId, int extensionGroup);
- static bool contextHasCorrectPrototype(v8::Handle<v8::Context>);
+
+ static unsigned isolatedWorldCount;
+ static DOMWrapperWorld* worldOfInitializingWindow;
const int m_worldId;
const int m_extensionGroup;
« no previous file with comments | « no previous file | Source/bindings/v8/DOMWrapperWorld.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698