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

Side by Side Diff: Source/web/SuspendableScriptExecutor.cpp

Issue 1197163003: Oilpan: make SuspendableScriptExecutor safe. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: re-intro RefCountedGarbageCollected Created 5 years, 6 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/web/SuspendableScriptExecutor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "web/SuspendableScriptExecutor.h" 6 #include "web/SuspendableScriptExecutor.h"
7 7
8 #include "bindings/core/v8/ScriptController.h" 8 #include "bindings/core/v8/ScriptController.h"
9 #include "bindings/core/v8/ScriptSourceCode.h" 9 #include "bindings/core/v8/ScriptSourceCode.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
(...skipping 10 matching lines...) Expand all
21 executor->ref(); 21 executor->ref();
22 executor->run(); 22 executor->run();
23 } 23 }
24 24
25 void SuspendableScriptExecutor::contextDestroyed() 25 void SuspendableScriptExecutor::contextDestroyed()
26 { 26 {
27 // this method can only be called if the script was not called in run() 27 // this method can only be called if the script was not called in run()
28 // and context remained suspend (method resume has never called) 28 // and context remained suspend (method resume has never called)
29 SuspendableTimer::contextDestroyed(); 29 SuspendableTimer::contextDestroyed();
30 m_callback->completed(Vector<v8::Local<v8::Value>>()); 30 m_callback->completed(Vector<v8::Local<v8::Value>>());
31 deref(); 31 dispose();
32 } 32 }
33 33
34 SuspendableScriptExecutor::SuspendableScriptExecutor(LocalFrame* frame, int worl dID, const WillBeHeapVector<ScriptSourceCode>& sources, int extensionGroup, bool userGesture, WebScriptExecutionCallback* callback) 34 SuspendableScriptExecutor::SuspendableScriptExecutor(LocalFrame* frame, int worl dID, const WillBeHeapVector<ScriptSourceCode>& sources, int extensionGroup, bool userGesture, WebScriptExecutionCallback* callback)
35 : SuspendableTimer(frame->document()) 35 : SuspendableTimer(frame->document())
36 , m_frame(frame) 36 , m_frame(frame)
37 , m_worldID(worldID) 37 , m_worldID(worldID)
38 , m_sources(sources) 38 , m_sources(sources)
39 , m_extensionGroup(extensionGroup) 39 , m_extensionGroup(extensionGroup)
40 , m_userGesture(userGesture) 40 , m_userGesture(userGesture)
41 , m_callback(callback) 41 , m_callback(callback)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 v8::HandleScope scope(v8::Isolate::GetCurrent()); 75 v8::HandleScope scope(v8::Isolate::GetCurrent());
76 Vector<v8::Local<v8::Value>> results; 76 Vector<v8::Local<v8::Value>> results;
77 if (m_worldID) { 77 if (m_worldID) {
78 m_frame->script().executeScriptInIsolatedWorld(m_worldID, m_sources, m_e xtensionGroup, &results); 78 m_frame->script().executeScriptInIsolatedWorld(m_worldID, m_sources, m_e xtensionGroup, &results);
79 } else { 79 } else {
80 v8::Local<v8::Value> scriptValue = m_frame->script().executeScriptInMain WorldAndReturnValue(m_sources.first()); 80 v8::Local<v8::Value> scriptValue = m_frame->script().executeScriptInMain WorldAndReturnValue(m_sources.first());
81 results.append(scriptValue); 81 results.append(scriptValue);
82 } 82 }
83 m_callback->completed(results); 83 m_callback->completed(results);
84 dispose();
85 }
86
87 void SuspendableScriptExecutor::dispose()
88 {
89 #if ENABLE(OILPAN)
90 // Remove object as a ContextLifecycleObserver.
91 ActiveDOMObject::clearContext();
haraken 2015/06/23 09:25:56 Is this a performance optimization? Or do we need
sof 2015/06/23 09:40:59 I think it makes sense to remove oneself here, rat
haraken 2015/06/23 09:44:55 Makes sense. (I'd prefer calling ActiveDOMObject::
92 #endif
84 deref(); 93 deref();
85 } 94 }
86 95
87 DEFINE_TRACE(SuspendableScriptExecutor) 96 DEFINE_TRACE(SuspendableScriptExecutor)
88 { 97 {
89 #if ENABLE(OILPAN) 98 #if ENABLE(OILPAN)
90 visitor->trace(m_frame); 99 visitor->trace(m_frame);
91 visitor->trace(m_sources); 100 visitor->trace(m_sources);
92 #endif 101 #endif
93 SuspendableTimer::trace(visitor); 102 SuspendableTimer::trace(visitor);
94 } 103 }
95 104
96 } // namespace blink 105 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/SuspendableScriptExecutor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698