| OLD | NEW |
| 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 "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| 10 #include "core/frame/LocalFrame.h" | 11 #include "core/frame/LocalFrame.h" |
| 11 #include "platform/UserGestureIndicator.h" | 12 #include "platform/UserGestureIndicator.h" |
| 12 #include "public/platform/WebVector.h" | 13 #include "public/platform/WebVector.h" |
| 13 #include "public/web/WebScriptExecutionCallback.h" | 14 #include "public/web/WebScriptExecutionCallback.h" |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 void SuspendableScriptExecutor::createAndRun(LocalFrame* frame, int worldID, con
st Vector<ScriptSourceCode>& sources, int extensionGroup, bool userGesture, WebS
criptExecutionCallback* callback) | 18 void SuspendableScriptExecutor::createAndRun(LocalFrame* frame, int worldID, con
st WillBeHeapVector<ScriptSourceCode>& sources, int extensionGroup, bool userGes
ture, WebScriptExecutionCallback* callback) |
| 18 { | 19 { |
| 19 RefPtrWillBeRawPtr<SuspendableScriptExecutor> executor = adoptRefWillBeNoop(
new SuspendableScriptExecutor(frame, worldID, sources, extensionGroup, userGestu
re, callback)); | 20 RefPtrWillBeRawPtr<SuspendableScriptExecutor> executor = adoptRefWillBeNoop(
new SuspendableScriptExecutor(frame, worldID, sources, extensionGroup, userGestu
re, callback)); |
| 20 executor->run(); | 21 executor->run(); |
| 21 executor->ref(); | 22 executor->ref(); |
| 22 } | 23 } |
| 23 | 24 |
| 24 void SuspendableScriptExecutor::resume() | 25 void SuspendableScriptExecutor::resume() |
| 25 { | 26 { |
| 26 executeAndDestroySelf(); | 27 executeAndDestroySelf(); |
| 27 } | 28 } |
| 28 | 29 |
| 29 void SuspendableScriptExecutor::contextDestroyed() | 30 void SuspendableScriptExecutor::contextDestroyed() |
| 30 { | 31 { |
| 31 // this method can only be called if the script was not called in run() | 32 // this method can only be called if the script was not called in run() |
| 32 // and context remained suspend (method resume has never called) | 33 // and context remained suspend (method resume has never called) |
| 33 ActiveDOMObject::contextDestroyed(); | 34 ActiveDOMObject::contextDestroyed(); |
| 34 m_callback->completed(Vector<v8::Local<v8::Value>>()); | 35 m_callback->completed(Vector<v8::Local<v8::Value>>()); |
| 35 deref(); | 36 deref(); |
| 36 } | 37 } |
| 37 | 38 |
| 38 SuspendableScriptExecutor::SuspendableScriptExecutor(LocalFrame* frame, int worl
dID, const Vector<ScriptSourceCode>& sources, int extensionGroup, bool userGestu
re, WebScriptExecutionCallback* callback) | 39 SuspendableScriptExecutor::SuspendableScriptExecutor(LocalFrame* frame, int worl
dID, const WillBeHeapVector<ScriptSourceCode>& sources, int extensionGroup, bool
userGesture, WebScriptExecutionCallback* callback) |
| 39 : ActiveDOMObject(frame->document()) | 40 : ActiveDOMObject(frame->document()) |
| 40 , m_frame(frame) | 41 , m_frame(frame) |
| 41 , m_worldID(worldID) | 42 , m_worldID(worldID) |
| 42 , m_sources(sources) | 43 , m_sources(sources) |
| 43 , m_extensionGroup(extensionGroup) | 44 , m_extensionGroup(extensionGroup) |
| 44 , m_userGesture(userGesture) | 45 , m_userGesture(userGesture) |
| 45 , m_callback(callback) | 46 , m_callback(callback) |
| 46 { | 47 { |
| 47 } | 48 } |
| 48 | 49 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 74 } else { | 75 } else { |
| 75 v8::Local<v8::Value> scriptValue = m_frame->script().executeScriptInMain
WorldAndReturnValue(m_sources.first()); | 76 v8::Local<v8::Value> scriptValue = m_frame->script().executeScriptInMain
WorldAndReturnValue(m_sources.first()); |
| 76 results.append(scriptValue); | 77 results.append(scriptValue); |
| 77 } | 78 } |
| 78 m_callback->completed(results); | 79 m_callback->completed(results); |
| 79 deref(); | 80 deref(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void SuspendableScriptExecutor::trace(Visitor* visitor) | 83 void SuspendableScriptExecutor::trace(Visitor* visitor) |
| 83 { | 84 { |
| 85 #if ENABLE(OILPAN) |
| 84 visitor->trace(m_frame); | 86 visitor->trace(m_frame); |
| 87 visitor->trace(m_sources); |
| 88 #endif |
| 85 ActiveDOMObject::trace(visitor); | 89 ActiveDOMObject::trace(visitor); |
| 86 } | 90 } |
| 87 | 91 |
| 88 } // namespace blink | 92 } // namespace blink |
| OLD | NEW |