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

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

Issue 2109843003: Adds enableVirtualTime and setVirtualTimePolicy To Emulation domain. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + address nit Created 4 years, 5 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
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/WebViewScheduler.h"
12 #include "web/DevToolsEmulator.h" 13 #include "web/DevToolsEmulator.h"
13 #include "web/WebLocalFrameImpl.h" 14 #include "web/WebLocalFrameImpl.h"
14 #include "web/WebViewImpl.h" 15 #include "web/WebViewImpl.h"
15 16
16 namespace blink { 17 namespace blink {
17 18
18 namespace EmulationAgentState { 19 namespace EmulationAgentState {
19 static const char scriptExecutionDisabled[] = "scriptExecutionDisabled"; 20 static const char scriptExecutionDisabled[] = "scriptExecutionDisabled";
20 static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled"; 21 static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled";
21 static const char emulatedMedia[] = "emulatedMedia"; 22 static const char emulatedMedia[] = "emulatedMedia";
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 { 86 {
86 m_state->setString(EmulationAgentState::emulatedMedia, media); 87 m_state->setString(EmulationAgentState::emulatedMedia, media);
87 webViewImpl()->page()->settings().setMediaTypeOverride(media); 88 webViewImpl()->page()->settings().setMediaTypeOverride(media);
88 } 89 }
89 90
90 void InspectorEmulationAgent::setCPUThrottlingRate(ErrorString*, double throttli ngRate) 91 void InspectorEmulationAgent::setCPUThrottlingRate(ErrorString*, double throttli ngRate)
91 { 92 {
92 m_client->setCPUThrottlingRate(throttlingRate); 93 m_client->setCPUThrottlingRate(throttlingRate);
93 } 94 }
94 95
96 void InspectorEmulationAgent::enableVirtualTime(ErrorString*)
97 {
98 for (WebLocalFrame* frame = m_webLocalFrameImpl; frame; frame = frame->trave rseNextLocal(false)) {
dgozman 2016/07/05 15:30:35 We have InspectedFrames class, which allows to ite
alex clarke (OOO till 29th) 2016/07/05 16:51:23 I tried that but the problem is we need to get hol
dcheng 2016/07/06 01:09:48 I don't think we should be introducing new usages
alex clarke (OOO till 29th) 2016/07/06 09:23:25 I didn't realize it was depreciated, good to know.
99 frame->view()->scheduler()->enableVirtualTime();
100 }
101 }
102
103 namespace {
104 void setVirtualTimePolicyForEachFrame(WebLocalFrameImpl* mainFrame, WebViewSched uler::VirtualTimePolicy policy)
105 {
106 for (WebLocalFrame* frame = mainFrame; frame; frame = frame->traverseNextLoc al(false)) {
107 frame->view()->scheduler()->setVirtualTimePolicy(policy);
108 }
109 }
110 }
111
112 void InspectorEmulationAgent::setVirtualTimePolicy(ErrorString*, const String& i n_policy)
113 {
114 if (protocol::Emulation::VirtualTimePolicyEnum::Advance == in_policy) {
115 setVirtualTimePolicyForEachFrame(m_webLocalFrameImpl, WebViewScheduler:: VirtualTimePolicy::ADVANCE);
116 } else if (protocol::Emulation::VirtualTimePolicyEnum::Pause == in_policy) {
117 setVirtualTimePolicyForEachFrame(m_webLocalFrameImpl, WebViewScheduler:: VirtualTimePolicy::PAUSE);
118 } else if (protocol::Emulation::VirtualTimePolicyEnum::PauseIfNetworkFetches Pending == in_policy) {
119 setVirtualTimePolicyForEachFrame(m_webLocalFrameImpl, WebViewScheduler:: VirtualTimePolicy::PAUSE_IF_NETWORK_FETCHES_PENDING);
120 }
121 }
122
95 DEFINE_TRACE(InspectorEmulationAgent) 123 DEFINE_TRACE(InspectorEmulationAgent)
96 { 124 {
97 visitor->trace(m_webLocalFrameImpl); 125 visitor->trace(m_webLocalFrameImpl);
98 InspectorBaseAgent::trace(visitor); 126 InspectorBaseAgent::trace(visitor);
99 } 127 }
100 128
101 } // namespace blink 129 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698