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

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

Issue 22467005: Correctly attribute exceptions thrown inside a Worker's imported scripts. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Killing windows-specific expectations. Created 7 years, 4 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, 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 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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/v8/ScriptValue.h" 34 #include "bindings/v8/ScriptValue.h"
35 #include "bindings/v8/V8Binding.h" 35 #include "bindings/v8/V8Binding.h"
36 #include <v8.h> 36 #include "core/dom/ErrorEvent.h"
37 #include "wtf/OwnPtr.h" 37 #include "wtf/OwnPtr.h"
38 #include "wtf/Threading.h" 38 #include "wtf/Threading.h"
39 #include "wtf/text/TextPosition.h" 39 #include "wtf/text/TextPosition.h"
40 #include <v8.h>
40 41
41 namespace WebCore { 42 namespace WebCore {
42 43
43 class ScriptSourceCode; 44 class ScriptSourceCode;
44 class ScriptValue; 45 class ScriptValue;
45 class WorkerGlobalScope; 46 class WorkerGlobalScope;
46 47
47 struct WorkerGlobalScopeExecutionState { 48 struct WorkerGlobalScopeExecutionState {
48 WorkerGlobalScopeExecutionState() 49 WorkerGlobalScopeExecutionState()
49 : hadException(false) 50 : hadException(false)
50 , lineNumber(0) 51 , lineNumber(0)
51 , columnNumber(0) 52 , columnNumber(0)
52 { 53 {
53 } 54 }
54 55
55 bool hadException; 56 bool hadException;
56 ScriptValue exception;
57 String errorMessage; 57 String errorMessage;
58 int lineNumber; 58 int lineNumber;
59 int columnNumber; 59 int columnNumber;
60 String sourceURL; 60 String sourceURL;
61 }; 61 };
62 62
63 class WorkerScriptController { 63 class WorkerScriptController {
64 public: 64 public:
65 WorkerScriptController(WorkerGlobalScope*); 65 WorkerScriptController(WorkerGlobalScope*);
66 ~WorkerScriptController(); 66 ~WorkerScriptController();
67 67
68 WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope; } 68 WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope; }
69 69
70 void evaluate(const ScriptSourceCode&, ScriptValue* = 0); 70 void evaluate(const ScriptSourceCode&, RefPtr<ErrorEvent>* = 0);
71 71
72 void setException(const ScriptValue&); 72 void rethrowExceptionFromImportedScript(PassRefPtr<ErrorEvent>);
73 73
74 // Async request to terminate a future JS execution. Eventually causes t ermination 74 // Async request to terminate a future JS execution. Eventually causes t ermination
75 // exception raised during JS execution, if the worker thread happens to run JS. 75 // exception raised during JS execution, if the worker thread happens to run JS.
76 // After JS execution was terminated in this way, the Worker thread has to use 76 // After JS execution was terminated in this way, the Worker thread has to use
77 // forbidExecution()/isExecutionForbidden() to guard against reentry int o JS. 77 // forbidExecution()/isExecutionForbidden() to guard against reentry int o JS.
78 // Can be called from any thread. 78 // Can be called from any thread.
79 void scheduleExecutionTermination(); 79 void scheduleExecutionTermination();
80 bool isExecutionTerminating() const; 80 bool isExecutionTerminating() const;
81 81
82 // Called on Worker thread when JS exits with termination exception caus ed by forbidExecution() request, 82 // Called on Worker thread when JS exits with termination exception caus ed by forbidExecution() request,
(...skipping 23 matching lines...) Expand all
106 106
107 WorkerGlobalScope* m_workerGlobalScope; 107 WorkerGlobalScope* m_workerGlobalScope;
108 v8::Isolate* m_isolate; 108 v8::Isolate* m_isolate;
109 ScopedPersistent<v8::Context> m_context; 109 ScopedPersistent<v8::Context> m_context;
110 OwnPtr<V8PerContextData> m_perContextData; 110 OwnPtr<V8PerContextData> m_perContextData;
111 String m_disableEvalPending; 111 String m_disableEvalPending;
112 OwnPtr<DOMDataStore> m_domDataStore; 112 OwnPtr<DOMDataStore> m_domDataStore;
113 bool m_executionForbidden; 113 bool m_executionForbidden;
114 bool m_executionScheduledToTerminate; 114 bool m_executionScheduledToTerminate;
115 mutable Mutex m_scheduledTerminationMutex; 115 mutable Mutex m_scheduledTerminationMutex;
116 RefPtr<ErrorEvent> m_errorEventFromImportedScript;
116 }; 117 };
117 118
118 } // namespace WebCore 119 } // namespace WebCore
119 120
120 #endif // WorkerScriptController_h 121 #endif // WorkerScriptController_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698