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 "web/SuspendableScriptExecutor.h" | 5 #include "web/SuspendableScriptExecutor.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptController.h" | 7 #include "bindings/core/v8/ScriptController.h" |
8 #include "bindings/core/v8/ScriptSourceCode.h" | 8 #include "bindings/core/v8/ScriptSourceCode.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
11 #include "platform/UserGestureIndicator.h" | 11 #include "platform/UserGestureIndicator.h" |
12 #include "public/platform/WebVector.h" | 12 #include "public/platform/WebVector.h" |
13 #include "public/web/WebScriptExecutionCallback.h" | 13 #include "public/web/WebScriptExecutionCallback.h" |
| 14 #include "wtf/PtrUtil.h" |
| 15 #include <memory> |
14 | 16 |
15 namespace blink { | 17 namespace blink { |
16 | 18 |
17 void SuspendableScriptExecutor::createAndRun(LocalFrame* frame, int worldID, con
st HeapVector<ScriptSourceCode>& sources, int extensionGroup, bool userGesture,
WebScriptExecutionCallback* callback) | 19 void SuspendableScriptExecutor::createAndRun(LocalFrame* frame, int worldID, con
st HeapVector<ScriptSourceCode>& sources, int extensionGroup, bool userGesture,
WebScriptExecutionCallback* callback) |
18 { | 20 { |
19 SuspendableScriptExecutor* executor = new SuspendableScriptExecutor(frame, w
orldID, sources, extensionGroup, userGesture, callback); | 21 SuspendableScriptExecutor* executor = new SuspendableScriptExecutor(frame, w
orldID, sources, extensionGroup, userGesture, callback); |
20 executor->run(); | 22 executor->run(); |
21 } | 23 } |
22 | 24 |
23 void SuspendableScriptExecutor::contextDestroyed() | 25 void SuspendableScriptExecutor::contextDestroyed() |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 return; | 60 return; |
59 } | 61 } |
60 startOneShot(0, BLINK_FROM_HERE); | 62 startOneShot(0, BLINK_FROM_HERE); |
61 suspendIfNeeded(); | 63 suspendIfNeeded(); |
62 } | 64 } |
63 | 65 |
64 void SuspendableScriptExecutor::executeAndDestroySelf() | 66 void SuspendableScriptExecutor::executeAndDestroySelf() |
65 { | 67 { |
66 // after calling the destructor of object - object will be unsubscribed from | 68 // after calling the destructor of object - object will be unsubscribed from |
67 // resumed and contextDestroyed LifecycleObserver methods | 69 // resumed and contextDestroyed LifecycleObserver methods |
68 OwnPtr<UserGestureIndicator> indicator; | 70 std::unique_ptr<UserGestureIndicator> indicator; |
69 if (m_userGesture) | 71 if (m_userGesture) |
70 indicator = adoptPtr(new UserGestureIndicator(DefinitelyProcessingNewUse
rGesture)); | 72 indicator = wrapUnique(new UserGestureIndicator(DefinitelyProcessingNewU
serGesture)); |
71 | 73 |
72 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 74 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
73 Vector<v8::Local<v8::Value>> results; | 75 Vector<v8::Local<v8::Value>> results; |
74 if (m_worldID) { | 76 if (m_worldID) { |
75 m_frame->script().executeScriptInIsolatedWorld(m_worldID, m_sources, m_e
xtensionGroup, &results); | 77 m_frame->script().executeScriptInIsolatedWorld(m_worldID, m_sources, m_e
xtensionGroup, &results); |
76 } else { | 78 } else { |
77 v8::Local<v8::Value> scriptValue = m_frame->script().executeScriptInMain
WorldAndReturnValue(m_sources.first()); | 79 v8::Local<v8::Value> scriptValue = m_frame->script().executeScriptInMain
WorldAndReturnValue(m_sources.first()); |
78 results.append(scriptValue); | 80 results.append(scriptValue); |
79 } | 81 } |
80 | 82 |
(...skipping 15 matching lines...) Expand all Loading... |
96 } | 98 } |
97 | 99 |
98 DEFINE_TRACE(SuspendableScriptExecutor) | 100 DEFINE_TRACE(SuspendableScriptExecutor) |
99 { | 101 { |
100 visitor->trace(m_frame); | 102 visitor->trace(m_frame); |
101 visitor->trace(m_sources); | 103 visitor->trace(m_sources); |
102 SuspendableTimer::trace(visitor); | 104 SuspendableTimer::trace(visitor); |
103 } | 105 } |
104 | 106 |
105 } // namespace blink | 107 } // namespace blink |
OLD | NEW |