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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/InspectorEmulationAgent.cpp
diff --git a/third_party/WebKit/Source/web/InspectorEmulationAgent.cpp b/third_party/WebKit/Source/web/InspectorEmulationAgent.cpp
index ba8f31b71d66cf75371e9b2a69a84c72ef71fe77..279a96c5d4af8cf827f6fa27f7730905d5426789 100644
--- a/third_party/WebKit/Source/web/InspectorEmulationAgent.cpp
+++ b/third_party/WebKit/Source/web/InspectorEmulationAgent.cpp
@@ -9,6 +9,7 @@
#include "core/frame/Settings.h"
#include "core/page/Page.h"
#include "platform/geometry/DoubleRect.h"
+#include "public/platform/WebViewScheduler.h"
#include "web/DevToolsEmulator.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WebViewImpl.h"
@@ -92,6 +93,33 @@ void InspectorEmulationAgent::setCPUThrottlingRate(ErrorString*, double throttli
m_client->setCPUThrottlingRate(throttlingRate);
}
+void InspectorEmulationAgent::enableVirtualTime(ErrorString*)
+{
+ for (WebLocalFrame* frame = m_webLocalFrameImpl; frame; frame = frame->traverseNextLocal(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.
+ frame->view()->scheduler()->enableVirtualTime();
+ }
+}
+
+namespace {
+void setVirtualTimePolicyForEachFrame(WebLocalFrameImpl* mainFrame, WebViewScheduler::VirtualTimePolicy policy)
+{
+ for (WebLocalFrame* frame = mainFrame; frame; frame = frame->traverseNextLocal(false)) {
+ frame->view()->scheduler()->setVirtualTimePolicy(policy);
+ }
+}
+}
+
+void InspectorEmulationAgent::setVirtualTimePolicy(ErrorString*, const String& in_policy)
+{
+ if (protocol::Emulation::VirtualTimePolicyEnum::Advance == in_policy) {
+ setVirtualTimePolicyForEachFrame(m_webLocalFrameImpl, WebViewScheduler::VirtualTimePolicy::ADVANCE);
+ } else if (protocol::Emulation::VirtualTimePolicyEnum::Pause == in_policy) {
+ setVirtualTimePolicyForEachFrame(m_webLocalFrameImpl, WebViewScheduler::VirtualTimePolicy::PAUSE);
+ } else if (protocol::Emulation::VirtualTimePolicyEnum::PauseIfNetworkFetchesPending == in_policy) {
+ setVirtualTimePolicyForEachFrame(m_webLocalFrameImpl, WebViewScheduler::VirtualTimePolicy::PAUSE_IF_NETWORK_FETCHES_PENDING);
+ }
+}
+
DEFINE_TRACE(InspectorEmulationAgent)
{
visitor->trace(m_webLocalFrameImpl);

Powered by Google App Engine
This is Rietveld 408576698