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

Side by Side Diff: Source/bindings/v8/DOMWrapperWorld.h

Issue 13954010: Eliminate "temporary" and "uninitialized" isolated worlds (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 namespace WebCore { 43 namespace WebCore {
44 44
45 class DOMDataStore; 45 class DOMDataStore;
46 46
47 // This class represent a collection of DOM wrappers for a specific world. 47 // This class represent a collection of DOM wrappers for a specific world.
48 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> { 48 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
49 public: 49 public:
50 static const int mainWorldId = 0; 50 static const int mainWorldId = 0;
51 static const int mainWorldExtensionGroup = 0; 51 static const int mainWorldExtensionGroup = 0;
52 static const int uninitializedWorldId = -1;
53 static const int uninitializedExtensionGroup = -1;
54 // If uninitializedWorldId is passed as worldId, the world will be assigned a temporary id instead.
55 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int exte nsionGroup); 52 static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int exte nsionGroup);
56 ~DOMWrapperWorld(); 53 ~DOMWrapperWorld();
57 54
58 static bool isolatedWorldsExist() { return isolatedWorldCount; } 55 static bool isolatedWorldsExist() { return isolatedWorldCount; }
59 static bool isIsolatedWorldId(int worldId) { return worldId != mainWorldId & & worldId != uninitializedWorldId; } 56 static bool isIsolatedWorldId(int worldId) { return worldId > mainWorldId; }
60 static void getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds); 57 static void getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds);
61 58
62 void makeContextWeak(v8::Handle<v8::Context>); 59 void makeContextWeak(v8::Handle<v8::Context>);
63 void setIsolatedWorldField(v8::Handle<v8::Context>); 60 void setIsolatedWorldField(v8::Handle<v8::Context>);
64 61
65 static DOMWrapperWorld* isolatedWorld(v8::Handle<v8::Context> context) 62 static DOMWrapperWorld* isolatedWorld(v8::Handle<v8::Context> context)
66 { 63 {
67 ASSERT(contextHasCorrectPrototype(context)); 64 ASSERT(contextHasCorrectPrototype(context));
68 return static_cast<DOMWrapperWorld*>(context->GetAlignedPointerFromEmbed derData(v8ContextIsolatedWorld)); 65 return static_cast<DOMWrapperWorld*>(context->GetAlignedPointerFromEmbed derData(v8ContextIsolatedWorld));
69 } 66 }
(...skipping 15 matching lines...) Expand all
85 // applied correctly. 82 // applied correctly.
86 static void setIsolatedWorldContentSecurityPolicy(int worldID, const String& policy); 83 static void setIsolatedWorldContentSecurityPolicy(int worldID, const String& policy);
87 static void clearIsolatedWorldContentSecurityPolicy(int worldID); 84 static void clearIsolatedWorldContentSecurityPolicy(int worldID);
88 bool isolatedWorldHasContentSecurityPolicy(); 85 bool isolatedWorldHasContentSecurityPolicy();
89 86
90 // Associate a logger with the world identified by worldId (worlId may be 0 87 // Associate a logger with the world identified by worldId (worlId may be 0
91 // identifying the main world). 88 // identifying the main world).
92 static void setActivityLogger(int worldId, PassOwnPtr<V8DOMActivityLogger>); 89 static void setActivityLogger(int worldId, PassOwnPtr<V8DOMActivityLogger>);
93 static V8DOMActivityLogger* activityLogger(int worldId); 90 static V8DOMActivityLogger* activityLogger(int worldId);
94 91
95 // FIXME: this is a workaround for a problem in WebViewImpl.
96 // Do not use this anywhere else!!
97 static PassRefPtr<DOMWrapperWorld> createUninitializedWorld();
98
99 bool isMainWorld() const { return m_worldId == mainWorldId; } 92 bool isMainWorld() const { return m_worldId == mainWorldId; }
100 bool isIsolatedWorld() const { return isIsolatedWorldId(m_worldId); } 93 bool isIsolatedWorld() const { return isIsolatedWorldId(m_worldId); }
101 bool createdFromUnitializedWorld() const { return m_worldId < uninitializedW orldId; }
102 94
103 int worldId() const { return m_worldId; } 95 int worldId() const { return m_worldId; }
104 int extensionGroup() const { return m_extensionGroup; } 96 int extensionGroup() const { return m_extensionGroup; }
105 DOMDataStore* isolatedWorldDOMDataStore() const 97 DOMDataStore* isolatedWorldDOMDataStore() const
106 { 98 {
107 ASSERT(isIsolatedWorld()); 99 ASSERT(isIsolatedWorld());
108 return m_domDataStore.get(); 100 return m_domDataStore.get();
109 } 101 }
110 102
111 static void setInitializingWindow(bool); 103 static void setInitializingWindow(bool);
112 104
113 private: 105 private:
114 static int isolatedWorldCount; 106 static int isolatedWorldCount;
115 static PassRefPtr<DOMWrapperWorld> createMainWorld(); 107 static PassRefPtr<DOMWrapperWorld> createMainWorld();
116 static bool contextHasCorrectPrototype(v8::Handle<v8::Context>); 108 static bool contextHasCorrectPrototype(v8::Handle<v8::Context>);
117 109
118 DOMWrapperWorld(int worldId, int extensionGroup); 110 DOMWrapperWorld(int worldId, int extensionGroup);
119 111
120 const int m_worldId; 112 const int m_worldId;
121 const int m_extensionGroup; 113 const int m_extensionGroup;
122 OwnPtr<DOMDataStore> m_domDataStore; 114 OwnPtr<DOMDataStore> m_domDataStore;
123 115
124 friend DOMWrapperWorld* mainThreadNormalWorld(); 116 friend DOMWrapperWorld* mainThreadNormalWorld();
117 friend DOMWrapperWorld* existingWindowShellWorkaroundWorld();
125 }; 118 };
126 119
127 DOMWrapperWorld* mainThreadNormalWorld(); 120 DOMWrapperWorld* mainThreadNormalWorld();
128 121
122 // FIXME: this is a workaround for a problem in ScriptController
123 // Do not use this anywhere else!!
124 DOMWrapperWorld* existingWindowShellWorkaroundWorld();
haraken 2013/04/12 02:14:19 Maybe deprecatedWindowShellWorld is a better name?
adamk 2013/04/12 15:44:04 I actually think the nearly-nonsensical name is a
125
129 } // namespace WebCore 126 } // namespace WebCore
130 127
131 #endif // DOMWrapperWorld_h 128 #endif // DOMWrapperWorld_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698