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

Side by Side Diff: third_party/WebKit/Source/web/InspectorEmulationAgent.cpp

Issue 2185033002: Emulation.setVirtualTimePolicy to have an optional virtual time budge (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename parameter Created 4 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
« no previous file with comments | « third_party/WebKit/Source/web/InspectorEmulationAgent.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/InspectorEmulationAgent.h" 5 #include "web/InspectorEmulationAgent.h"
6 6
7 #include "core/frame/FrameHost.h" 7 #include "core/frame/FrameHost.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/page/Page.h" 10 #include "core/page/Page.h"
11 #include "platform/geometry/DoubleRect.h" 11 #include "platform/geometry/DoubleRect.h"
12 #include "public/platform/Platform.h"
13 #include "public/platform/WebThread.h"
12 #include "public/platform/WebViewScheduler.h" 14 #include "public/platform/WebViewScheduler.h"
13 #include "web/DevToolsEmulator.h" 15 #include "web/DevToolsEmulator.h"
14 #include "web/WebLocalFrameImpl.h" 16 #include "web/WebLocalFrameImpl.h"
15 #include "web/WebViewImpl.h" 17 #include "web/WebViewImpl.h"
16 18
17 namespace blink { 19 namespace blink {
18 20
19 namespace EmulationAgentState { 21 namespace EmulationAgentState {
20 static const char scriptExecutionDisabled[] = "scriptExecutionDisabled"; 22 static const char scriptExecutionDisabled[] = "scriptExecutionDisabled";
21 static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled"; 23 static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled";
22 static const char emulatedMedia[] = "emulatedMedia"; 24 static const char emulatedMedia[] = "emulatedMedia";
23 } 25 }
24 26
25 InspectorEmulationAgent* InspectorEmulationAgent::create(WebLocalFrameImpl* webL ocalFrameImpl, Client* client) 27 InspectorEmulationAgent* InspectorEmulationAgent::create(WebLocalFrameImpl* webL ocalFrameImpl, Client* client)
26 { 28 {
27 return new InspectorEmulationAgent(webLocalFrameImpl, client); 29 return new InspectorEmulationAgent(webLocalFrameImpl, client);
28 } 30 }
29 31
30 InspectorEmulationAgent::InspectorEmulationAgent(WebLocalFrameImpl* webLocalFram eImpl, Client* client) 32 InspectorEmulationAgent::InspectorEmulationAgent(WebLocalFrameImpl* webLocalFram eImpl, Client* client)
31 : m_webLocalFrameImpl(webLocalFrameImpl) 33 : m_webLocalFrameImpl(webLocalFrameImpl)
32 , m_client(client) 34 , m_client(client)
35 , m_virtualTimeBudgetExpiredTask(CancellableTaskFactory::create(this, &Inspe ctorEmulationAgent::virtualTimeBudgetExpired))
33 { 36 {
34 } 37 }
35 38
36 InspectorEmulationAgent::~InspectorEmulationAgent() 39 InspectorEmulationAgent::~InspectorEmulationAgent()
37 { 40 {
38 } 41 }
39 42
40 WebViewImpl* InspectorEmulationAgent::webViewImpl() 43 WebViewImpl* InspectorEmulationAgent::webViewImpl()
41 { 44 {
42 return m_webLocalFrameImpl->viewImpl(); 45 return m_webLocalFrameImpl->viewImpl();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 { 89 {
87 m_state->setString(EmulationAgentState::emulatedMedia, media); 90 m_state->setString(EmulationAgentState::emulatedMedia, media);
88 webViewImpl()->page()->settings().setMediaTypeOverride(media); 91 webViewImpl()->page()->settings().setMediaTypeOverride(media);
89 } 92 }
90 93
91 void InspectorEmulationAgent::setCPUThrottlingRate(ErrorString*, double throttli ngRate) 94 void InspectorEmulationAgent::setCPUThrottlingRate(ErrorString*, double throttli ngRate)
92 { 95 {
93 m_client->setCPUThrottlingRate(throttlingRate); 96 m_client->setCPUThrottlingRate(throttlingRate);
94 } 97 }
95 98
96 void InspectorEmulationAgent::setVirtualTimePolicy(ErrorString*, const String& i n_policy) 99 void InspectorEmulationAgent::setVirtualTimePolicy(ErrorString*, const String& i n_policy, const Maybe<int>& in_budget)
97 { 100 {
98 if (protocol::Emulation::VirtualTimePolicyEnum::Advance == in_policy) { 101 if (protocol::Emulation::VirtualTimePolicyEnum::Advance == in_policy) {
99 m_webLocalFrameImpl->view()->scheduler()->enableVirtualTime();
100 m_webLocalFrameImpl->view()->scheduler()->setVirtualTimePolicy(WebViewSc heduler::VirtualTimePolicy::ADVANCE); 102 m_webLocalFrameImpl->view()->scheduler()->setVirtualTimePolicy(WebViewSc heduler::VirtualTimePolicy::ADVANCE);
101 } else if (protocol::Emulation::VirtualTimePolicyEnum::Pause == in_policy) { 103 } else if (protocol::Emulation::VirtualTimePolicyEnum::Pause == in_policy) {
102 m_webLocalFrameImpl->view()->scheduler()->enableVirtualTime();
103 m_webLocalFrameImpl->view()->scheduler()->setVirtualTimePolicy(WebViewSc heduler::VirtualTimePolicy::PAUSE); 104 m_webLocalFrameImpl->view()->scheduler()->setVirtualTimePolicy(WebViewSc heduler::VirtualTimePolicy::PAUSE);
104 } else if (protocol::Emulation::VirtualTimePolicyEnum::PauseIfNetworkFetches Pending == in_policy) { 105 } else if (protocol::Emulation::VirtualTimePolicyEnum::PauseIfNetworkFetches Pending == in_policy) {
105 m_webLocalFrameImpl->view()->scheduler()->enableVirtualTime();
106 m_webLocalFrameImpl->view()->scheduler()->setVirtualTimePolicy(WebViewSc heduler::VirtualTimePolicy::DETERMINISTIC_LOADING); 106 m_webLocalFrameImpl->view()->scheduler()->setVirtualTimePolicy(WebViewSc heduler::VirtualTimePolicy::DETERMINISTIC_LOADING);
107 } 107 }
108 m_webLocalFrameImpl->view()->scheduler()->enableVirtualTime();
109
110 if (in_budget.isJust()) {
111 WebTaskRunner* taskRunner = Platform::current()->currentThread()->getWeb TaskRunner();
112 long long delayMillis = static_cast<long long>(in_budget.fromJust());
113 taskRunner->postDelayedTask(BLINK_FROM_HERE, m_virtualTimeBudgetExpiredT ask->cancelAndCreate(), delayMillis);
114 }
108 } 115 }
109 116
117 void InspectorEmulationAgent::virtualTimeBudgetExpired()
118 {
119 m_webLocalFrameImpl->view()->scheduler()->setVirtualTimePolicy(WebViewSchedu ler::VirtualTimePolicy::PAUSE);
120 frontend()->virtualTimeBudgetExpired();
121 }
122
110 DEFINE_TRACE(InspectorEmulationAgent) 123 DEFINE_TRACE(InspectorEmulationAgent)
111 { 124 {
112 visitor->trace(m_webLocalFrameImpl); 125 visitor->trace(m_webLocalFrameImpl);
113 InspectorBaseAgent::trace(visitor); 126 InspectorBaseAgent::trace(visitor);
114 } 127 }
115 128
116 } // namespace blink 129 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/InspectorEmulationAgent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698