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

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

Issue 270873005: Initializes the context of WorkerScriptController before calling willEvaluateWorkerScript. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2012 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 ScriptValue exception; 61 ScriptValue exception;
62 }; 62 };
63 63
64 class WorkerScriptController { 64 class WorkerScriptController {
65 public: 65 public:
66 explicit WorkerScriptController(WorkerGlobalScope&); 66 explicit WorkerScriptController(WorkerGlobalScope&);
67 ~WorkerScriptController(); 67 ~WorkerScriptController();
68 68
69 WorkerGlobalScope& workerGlobalScope() { return m_workerGlobalScope; } 69 WorkerGlobalScope& workerGlobalScope() { return m_workerGlobalScope; }
70 70
71 bool initializeContext();
72
71 void evaluate(const ScriptSourceCode&, RefPtrWillBeRawPtr<ErrorEvent>* = 0); 73 void evaluate(const ScriptSourceCode&, RefPtrWillBeRawPtr<ErrorEvent>* = 0);
72 74
73 void rethrowExceptionFromImportedScript(PassRefPtrWillBeRawPtr<ErrorEven t>); 75 void rethrowExceptionFromImportedScript(PassRefPtrWillBeRawPtr<ErrorEven t>);
74 76
75 // Async request to terminate a future JS execution. Eventually causes t ermination 77 // Async request to terminate a future JS execution. Eventually causes t ermination
76 // exception raised during JS execution, if the worker thread happens to run JS. 78 // exception raised during JS execution, if the worker thread happens to run JS.
77 // After JS execution was terminated in this way, the Worker thread has to use 79 // After JS execution was terminated in this way, the Worker thread has to use
78 // forbidExecution()/isExecutionForbidden() to guard against reentry int o JS. 80 // forbidExecution()/isExecutionForbidden() to guard against reentry int o JS.
79 // Can be called from any thread. 81 // Can be called from any thread.
80 void scheduleExecutionTermination(); 82 void scheduleExecutionTermination();
(...skipping 13 matching lines...) Expand all
94 DOMWrapperWorld& world() const { return *m_world; } 96 DOMWrapperWorld& world() const { return *m_world; }
95 ScriptState* scriptState() { return m_scriptState.get(); } 97 ScriptState* scriptState() { return m_scriptState.get(); }
96 v8::Local<v8::Context> context() { return m_scriptState ? m_scriptState- >context() : v8::Local<v8::Context>(); } 98 v8::Local<v8::Context> context() { return m_scriptState ? m_scriptState- >context() : v8::Local<v8::Context>(); }
97 bool isContextInitialized() { return m_scriptState && !!m_scriptState->p erContextData(); } 99 bool isContextInitialized() { return m_scriptState && !!m_scriptState->p erContextData(); }
98 100
99 // Send a notification about current thread is going to be idle. 101 // Send a notification about current thread is going to be idle.
100 // Returns true if the embedder should stop calling idleNotification 102 // Returns true if the embedder should stop calling idleNotification
101 // until real work has been done. 103 // until real work has been done.
102 bool idleNotification() { return v8::V8::IdleNotification(); } 104 bool idleNotification() { return v8::V8::IdleNotification(); }
103 105
106
104 private: 107 private:
105 bool initializeContextIfNeeded();
106
107 v8::Isolate* m_isolate; 108 v8::Isolate* m_isolate;
108 WorkerGlobalScope& m_workerGlobalScope; 109 WorkerGlobalScope& m_workerGlobalScope;
109 RefPtr<ScriptState> m_scriptState; 110 RefPtr<ScriptState> m_scriptState;
110 RefPtr<DOMWrapperWorld> m_world; 111 RefPtr<DOMWrapperWorld> m_world;
111 String m_disableEvalPending; 112 String m_disableEvalPending;
112 bool m_executionForbidden; 113 bool m_executionForbidden;
113 bool m_executionScheduledToTerminate; 114 bool m_executionScheduledToTerminate;
114 mutable Mutex m_scheduledTerminationMutex; 115 mutable Mutex m_scheduledTerminationMutex;
115 RefPtrWillBePersistent<ErrorEvent> m_errorEventFromImportedScript; 116 RefPtrWillBePersistent<ErrorEvent> m_errorEventFromImportedScript;
116 OwnPtr<V8IsolateInterruptor> m_interruptor; 117 OwnPtr<V8IsolateInterruptor> m_interruptor;
117 }; 118 };
118 119
119 } // namespace WebCore 120 } // namespace WebCore
120 121
121 #endif // WorkerScriptController_h 122 #endif // WorkerScriptController_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/v8/WorkerScriptController.cpp » ('j') | Source/bindings/v8/WorkerScriptController.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698