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

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

Issue 559363002: Switch blink to use a gin-managed isolate. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: updates Created 6 years, 3 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
« no previous file with comments | « Source/bindings/core/v8/V8PerIsolateData.cpp ('k') | Source/web/WebKit.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // WorkerScriptController's WorkerGlobalScopeExecutionState is popped 98 // WorkerScriptController's WorkerGlobalScopeExecutionState is popped
99 // and the previous one restored (see above dtor.) 99 // and the previous one restored (see above dtor.)
100 // 100 //
101 // With Oilpan, |m_outerState| isn't traced. It'll be "up the stack" 101 // With Oilpan, |m_outerState| isn't traced. It'll be "up the stack"
102 // and its fields will be traced when scanning the stack. 102 // and its fields will be traced when scanning the stack.
103 WorkerScriptController* m_controller; 103 WorkerScriptController* m_controller;
104 WorkerGlobalScopeExecutionState* m_outerState; 104 WorkerGlobalScopeExecutionState* m_outerState;
105 }; 105 };
106 106
107 WorkerScriptController::WorkerScriptController(WorkerGlobalScope& workerGlobalSc ope) 107 WorkerScriptController::WorkerScriptController(WorkerGlobalScope& workerGlobalSc ope)
108 : m_isolate(v8::Isolate::New()) 108 : m_isolate(0)
109 , m_workerGlobalScope(workerGlobalScope) 109 , m_workerGlobalScope(workerGlobalScope)
110 , m_executionForbidden(false) 110 , m_executionForbidden(false)
111 , m_executionScheduledToTerminate(false) 111 , m_executionScheduledToTerminate(false)
112 , m_globalScopeExecutionState(0) 112 , m_globalScopeExecutionState(0)
113 { 113 {
114 m_isolate->Enter(); 114 m_isolate = V8PerIsolateData::initialize();
115 V8Initializer::initializeWorker(m_isolate); 115 V8Initializer::initializeWorker(m_isolate);
116 v8::V8::Initialize();
117 V8PerIsolateData::ensureInitialized(m_isolate);
118 m_world = DOMWrapperWorld::create(WorkerWorldId); 116 m_world = DOMWrapperWorld::create(WorkerWorldId);
119 m_interruptor = adoptPtr(new V8IsolateInterruptor(m_isolate)); 117 m_interruptor = adoptPtr(new V8IsolateInterruptor(m_isolate));
120 ThreadState::current()->addInterruptor(m_interruptor.get()); 118 ThreadState::current()->addInterruptor(m_interruptor.get());
121 } 119 }
122 120
123 // We need to postpone V8 Isolate destruction until the very end of 121 // We need to postpone V8 Isolate destruction until the very end of
124 // worker thread finalization when all objects on the worker heap 122 // worker thread finalization when all objects on the worker heap
125 // are destroyed. 123 // are destroyed.
126 class IsolateCleanupTask : public ThreadState::CleanupTask { 124 class IsolateCleanupTask : public ThreadState::CleanupTask {
127 public: 125 public:
128 static PassOwnPtr<IsolateCleanupTask> create(v8::Isolate* isolate) 126 static PassOwnPtr<IsolateCleanupTask> create(v8::Isolate* isolate)
129 { 127 {
130 return adoptPtr(new IsolateCleanupTask(isolate)); 128 return adoptPtr(new IsolateCleanupTask(isolate));
131 } 129 }
132 130
133 virtual void postCleanup() 131 virtual void postCleanup()
134 { 132 {
135 V8PerIsolateData::dispose(m_isolate); 133 V8PerIsolateData::dispose(m_isolate);
136 m_isolate->Exit();
137 m_isolate->Dispose();
138 } 134 }
139 135
140 private: 136 private:
141 explicit IsolateCleanupTask(v8::Isolate* isolate) : m_isolate(isolate) { } 137 explicit IsolateCleanupTask(v8::Isolate* isolate) : m_isolate(isolate) { }
142 138
143 v8::Isolate* m_isolate; 139 v8::Isolate* m_isolate;
144 }; 140 };
145 141
146 WorkerScriptController::~WorkerScriptController() 142 WorkerScriptController::~WorkerScriptController()
147 { 143 {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 309
314 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState) 310 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState)
315 { 311 {
316 const String& errorMessage = errorEvent->message(); 312 const String& errorMessage = errorEvent->message();
317 if (m_globalScopeExecutionState) 313 if (m_globalScopeExecutionState)
318 m_globalScopeExecutionState->m_errorEventFromImportedScript = errorEvent ; 314 m_globalScopeExecutionState->m_errorEventFromImportedScript = errorEvent ;
319 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(error Message, m_isolate)); 315 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(error Message, m_isolate));
320 } 316 }
321 317
322 } // namespace blink 318 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8PerIsolateData.cpp ('k') | Source/web/WebKit.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698