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

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

Issue 929953002: CachedMetadata support for ServiceWorker script. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incorporated tkent's comment Created 5 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 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 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 WorkerScriptController_h 31 #ifndef WorkerScriptController_h
32 #define WorkerScriptController_h 32 #define WorkerScriptController_h
33 33
34 #include "bindings/core/v8/RejectedPromises.h" 34 #include "bindings/core/v8/RejectedPromises.h"
35 #include "bindings/core/v8/ScriptValue.h" 35 #include "bindings/core/v8/ScriptValue.h"
36 #include "bindings/core/v8/V8Binding.h" 36 #include "bindings/core/v8/V8Binding.h"
37 #include "bindings/core/v8/V8CacheOptions.h"
37 #include "wtf/OwnPtr.h" 38 #include "wtf/OwnPtr.h"
38 #include "wtf/ThreadingPrimitives.h" 39 #include "wtf/ThreadingPrimitives.h"
39 #include "wtf/text/TextPosition.h" 40 #include "wtf/text/TextPosition.h"
40 #include <v8.h> 41 #include <v8.h>
41 42
42 namespace blink { 43 namespace blink {
43 44
45 class CachedMetadataHandler;
44 class ErrorEvent; 46 class ErrorEvent;
45 class ExceptionState; 47 class ExceptionState;
46 class ScriptSourceCode; 48 class ScriptSourceCode;
47 class WorkerGlobalScope; 49 class WorkerGlobalScope;
48 50
49 class WorkerScriptController { 51 class WorkerScriptController {
50 public: 52 public:
51 explicit WorkerScriptController(WorkerGlobalScope&); 53 explicit WorkerScriptController(WorkerGlobalScope&);
52 ~WorkerScriptController(); 54 ~WorkerScriptController();
53 55
54 bool isExecutionForbidden() const; 56 bool isExecutionForbidden() const;
55 bool isExecutionTerminating() const; 57 bool isExecutionTerminating() const;
56 58
57 // Returns true if the evaluation completed with no uncaught exception. 59 // Returns true if the evaluation completed with no uncaught exception.
58 bool evaluate(const ScriptSourceCode&, RefPtrWillBeRawPtr<ErrorEvent>* = 0); 60 bool evaluate(const ScriptSourceCode&, RefPtrWillBeRawPtr<ErrorEvent>* = nul lptr, CachedMetadataHandler* = nullptr, V8CacheOptions = V8CacheOptionsDefault);
59 61
60 // Prevents future JavaScript execution. See 62 // Prevents future JavaScript execution. See
61 // scheduleExecutionTermination, isExecutionForbidden. 63 // scheduleExecutionTermination, isExecutionForbidden.
62 void forbidExecution(); 64 void forbidExecution();
63 65
64 // Used by WorkerThread: 66 // Used by WorkerThread:
65 bool initializeContextIfNeeded(); 67 bool initializeContextIfNeeded();
66 // Async request to terminate future JavaScript execution on the 68 // Async request to terminate future JavaScript execution on the
67 // worker thread. JavaScript evaluation exits with a 69 // worker thread. JavaScript evaluation exits with a
68 // non-continuable exception and WorkerScriptController calls 70 // non-continuable exception and WorkerScriptController calls
(...skipping 17 matching lines...) Expand all
86 v8::Local<v8::Context> context() { return m_scriptState ? m_scriptState->con text() : v8::Local<v8::Context>(); } 88 v8::Local<v8::Context> context() { return m_scriptState ? m_scriptState->con text() : v8::Local<v8::Context>(); }
87 89
88 RejectedPromises* rejectedPromises() const { return m_rejectedPromises.get() ; } 90 RejectedPromises* rejectedPromises() const { return m_rejectedPromises.get() ; }
89 91
90 private: 92 private:
91 class WorkerGlobalScopeExecutionState; 93 class WorkerGlobalScopeExecutionState;
92 94
93 bool isContextInitialized() { return m_scriptState && !!m_scriptState->perCo ntextData(); } 95 bool isContextInitialized() { return m_scriptState && !!m_scriptState->perCo ntextData(); }
94 96
95 // Evaluate a script file in the current execution environment. 97 // Evaluate a script file in the current execution environment.
96 ScriptValue evaluate(const String& script, const String& fileName, const Tex tPosition& scriptStartPosition); 98 ScriptValue evaluate(const String& script, const String& fileName, const Tex tPosition& scriptStartPosition, CachedMetadataHandler*, V8CacheOptions);
97 99
98 v8::Isolate* m_isolate; 100 v8::Isolate* m_isolate;
99 WorkerGlobalScope& m_workerGlobalScope; 101 WorkerGlobalScope& m_workerGlobalScope;
100 RefPtr<ScriptState> m_scriptState; 102 RefPtr<ScriptState> m_scriptState;
101 RefPtr<DOMWrapperWorld> m_world; 103 RefPtr<DOMWrapperWorld> m_world;
102 String m_disableEvalPending; 104 String m_disableEvalPending;
103 bool m_executionForbidden; 105 bool m_executionForbidden;
104 bool m_executionScheduledToTerminate; 106 bool m_executionScheduledToTerminate;
105 mutable Mutex m_scheduledTerminationMutex; 107 mutable Mutex m_scheduledTerminationMutex;
106 108
107 OwnPtrWillBePersistent<RejectedPromises> m_rejectedPromises; 109 OwnPtrWillBePersistent<RejectedPromises> m_rejectedPromises;
108 110
109 // |m_globalScopeExecutionState| refers to a stack object 111 // |m_globalScopeExecutionState| refers to a stack object
110 // that evaluate() allocates; evaluate() ensuring that the 112 // that evaluate() allocates; evaluate() ensuring that the
111 // pointer reference to it is removed upon returning. Hence 113 // pointer reference to it is removed upon returning. Hence
112 // kept as a bare pointer here, and not a Persistent with 114 // kept as a bare pointer here, and not a Persistent with
113 // Oilpan enabled; stack scanning will visit the object and 115 // Oilpan enabled; stack scanning will visit the object and
114 // trace its on-heap fields. 116 // trace its on-heap fields.
115 GC_PLUGIN_IGNORE("394615") 117 GC_PLUGIN_IGNORE("394615")
116 WorkerGlobalScopeExecutionState* m_globalScopeExecutionState; 118 WorkerGlobalScopeExecutionState* m_globalScopeExecutionState;
117 OwnPtr<V8IsolateInterruptor> m_interruptor; 119 OwnPtr<V8IsolateInterruptor> m_interruptor;
118 }; 120 };
119 121
120 } // namespace blink 122 } // namespace blink
121 123
122 #endif // WorkerScriptController_h 124 #endif // WorkerScriptController_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8ScriptRunnerTest.cpp ('k') | Source/bindings/core/v8/WorkerScriptController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698