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

Side by Side Diff: Source/bindings/core/v8/ScriptController.h

Issue 627933002: Oilpan: move ScriptController+WindowProxy to the heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Non-Oilpan compile fix Created 6 years, 2 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) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef ScriptController_h 31 #ifndef ScriptController_h
32 #define ScriptController_h 32 #define ScriptController_h
33 33
34 #include "bindings/core/v8/SharedPersistent.h" 34 #include "bindings/core/v8/SharedPersistent.h"
35 35
36 #include "core/fetch/CrossOriginAccessControl.h" 36 #include "core/fetch/CrossOriginAccessControl.h"
37 #include "platform/heap/Handle.h"
37 #include "wtf/HashMap.h" 38 #include "wtf/HashMap.h"
38 #include "wtf/RefCounted.h"
39 #include "wtf/Vector.h" 39 #include "wtf/Vector.h"
40 #include "wtf/text/TextPosition.h" 40 #include "wtf/text/TextPosition.h"
41 #include <v8.h> 41 #include <v8.h>
42 42
43 struct NPObject; 43 struct NPObject;
44 44
45 namespace blink { 45 namespace blink {
46 46
47 class DOMWrapperWorld; 47 class DOMWrapperWorld;
48 class ExecutionContext; 48 class ExecutionContext;
49 class HTMLDocument; 49 class HTMLDocument;
50 class HTMLPlugInElement; 50 class HTMLPlugInElement;
51 class KURL; 51 class KURL;
52 class LocalFrame; 52 class LocalFrame;
53 class ScriptState; 53 class ScriptState;
54 class ScriptSourceCode; 54 class ScriptSourceCode;
55 class SecurityOrigin; 55 class SecurityOrigin;
56 class WindowProxy; 56 class WindowProxy;
57 class Widget; 57 class Widget;
58 58
59 typedef WTF::Vector<v8::Extension*> V8Extensions; 59 typedef WTF::Vector<v8::Extension*> V8Extensions;
60 60
61 enum ReasonForCallingCanExecuteScripts { 61 enum ReasonForCallingCanExecuteScripts {
62 AboutToExecuteScript, 62 AboutToExecuteScript,
63 NotAboutToExecuteScript 63 NotAboutToExecuteScript
64 }; 64 };
65 65
66 class ScriptController { 66 class ScriptController final : public NoBaseWillBeGarbageCollectedFinalized<Scri ptController> {
67 public: 67 public:
68 enum ExecuteScriptPolicy { 68 enum ExecuteScriptPolicy {
69 ExecuteScriptWhenScriptsDisabled, 69 ExecuteScriptWhenScriptsDisabled,
70 DoNotExecuteScriptWhenScriptsDisabled 70 DoNotExecuteScriptWhenScriptsDisabled
71 }; 71 };
72 72
73 ScriptController(LocalFrame*); 73 static PassOwnPtrWillBeRawPtr<ScriptController> create(LocalFrame* frame)
74 {
75 return adoptPtrWillBeNoop(new ScriptController(frame));
76 }
77
74 ~ScriptController(); 78 ~ScriptController();
79 void trace(Visitor*);
75 80
76 bool initializeMainWorld(); 81 bool initializeMainWorld();
77 WindowProxy* windowProxy(DOMWrapperWorld&); 82 WindowProxy* windowProxy(DOMWrapperWorld&);
78 WindowProxy* existingWindowProxy(DOMWrapperWorld&); 83 WindowProxy* existingWindowProxy(DOMWrapperWorld&);
79 84
80 // Evaluate JavaScript in the main world. 85 // Evaluate JavaScript in the main world.
81 void executeScriptInMainWorld(const String&, ExecuteScriptPolicy = DoNotExec uteScriptWhenScriptsDisabled); 86 void executeScriptInMainWorld(const String&, ExecuteScriptPolicy = DoNotExec uteScriptWhenScriptsDisabled);
82 void executeScriptInMainWorld(const ScriptSourceCode&, AccessControlStatus = NotSharableCrossOrigin, double* compilationFinishTime = 0); 87 void executeScriptInMainWorld(const ScriptSourceCode&, AccessControlStatus = NotSharableCrossOrigin, double* compilationFinishTime = 0);
83 v8::Local<v8::Value> executeScriptInMainWorldAndReturnValue(const ScriptSour ceCode&); 88 v8::Local<v8::Value> executeScriptInMainWorldAndReturnValue(const ScriptSour ceCode&);
84 v8::Local<v8::Value> executeScriptAndReturnValue(v8::Handle<v8::Context>, co nst ScriptSourceCode&, AccessControlStatus = NotSharableCrossOrigin, double* com pilationFinishTime = 0); 89 v8::Local<v8::Value> executeScriptAndReturnValue(v8::Handle<v8::Context>, co nst ScriptSourceCode&, AccessControlStatus = NotSharableCrossOrigin, double* com pilationFinishTime = 0);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // affect v8 contexts initialized after this call. Takes ownership of 145 // affect v8 contexts initialized after this call. Takes ownership of
141 // the v8::Extension object passed. 146 // the v8::Extension object passed.
142 static void registerExtensionIfNeeded(v8::Extension*); 147 static void registerExtensionIfNeeded(v8::Extension*);
143 static V8Extensions& registeredExtensions(); 148 static V8Extensions& registeredExtensions();
144 149
145 void setWorldDebugId(int worldId, int debuggerId); 150 void setWorldDebugId(int worldId, int debuggerId);
146 151
147 v8::Isolate* isolate() const { return m_isolate; } 152 v8::Isolate* isolate() const { return m_isolate; }
148 153
149 private: 154 private:
150 typedef HashMap<int, OwnPtr<WindowProxy> > IsolatedWorldMap; 155 explicit ScriptController(LocalFrame*);
156
157 typedef WillBeHeapHashMap<int, OwnPtrWillBeMember<WindowProxy> > IsolatedWor ldMap;
151 typedef HashMap<Widget*, NPObject*> PluginObjectMap; 158 typedef HashMap<Widget*, NPObject*> PluginObjectMap;
haraken 2014/10/05 23:37:26 Just to confirm: Are you sure that these raw point
sof 2014/10/06 07:34:40 Nothing changes wrt that; we do rely on plugins to
152 159
153 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, Acce ssControlStatus, ExecuteScriptPolicy, double* compilationFinishTime = 0); 160 v8::Local<v8::Value> evaluateScriptInMainWorld(const ScriptSourceCode&, Acce ssControlStatus, ExecuteScriptPolicy, double* compilationFinishTime = 0);
154 161
155 LocalFrame* m_frame; 162 RawPtrWillBeMember<LocalFrame> m_frame;
156 const String* m_sourceURL; 163 const String* m_sourceURL;
157 v8::Isolate* m_isolate; 164 v8::Isolate* m_isolate;
158 165
159 OwnPtr<WindowProxy> m_windowProxy; 166 OwnPtrWillBeMember<WindowProxy> m_windowProxy;
160 IsolatedWorldMap m_isolatedWorlds; 167 IsolatedWorldMap m_isolatedWorlds;
161 168
162 // A mapping between Widgets and their corresponding script object. 169 // A mapping between Widgets and their corresponding script object.
163 // This list is used so that when the plugin dies, we can immediately 170 // This list is used so that when the plugin dies, we can immediately
164 // invalidate all sub-objects which are associated with that plugin. 171 // invalidate all sub-objects which are associated with that plugin.
165 // The frame keeps a NPObject reference for each item on the list. 172 // The frame keeps a NPObject reference for each item on the list.
166 PluginObjectMap m_pluginObjects; 173 PluginObjectMap m_pluginObjects;
167 174
168 NPObject* m_windowScriptNPObject; 175 NPObject* m_windowScriptNPObject;
169 }; 176 };
170 177
171 } // namespace blink 178 } // namespace blink
172 179
173 #endif // ScriptController_h 180 #endif // ScriptController_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptController.cpp » ('j') | Source/bindings/core/v8/ScriptController.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698