summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authordgozman <dgozman@chromium.org>2015-11-12 09:18:42 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-12 17:19:45 +0000
commit2af4be3722e3dea304e3c5e18581521f9606248b (patch)
tree73d9609772540e9cad768915f037ecb1c1f6db45 /content
parent9596af111d9e82b0e27c9fab01fa688515623b1f (diff)
downloadchromium_src-2af4be3722e3dea304e3c5e18581521f9606248b.zip
chromium_src-2af4be3722e3dea304e3c5e18581521f9606248b.tar.gz
chromium_src-2af4be3722e3dea304e3c5e18581521f9606248b.tar.bz2
Revert of [DevTools] Throttle device emulation with respect to produced frames. (patchset #1 id:1 of https://codereview.chromium.org/1436983003/ )
Reason for revert: Broke some tests. Original issue's description: > [DevTools] Throttle device emulation with respect to produced frames. > > We do not issue new device emulation command until the frame arrives (guarded by timeout). > > BUG=none TBR=pfeldman@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=none Review URL: https://codereview.chromium.org/1436823004 Cr-Commit-Position: refs/heads/master@{#359335}
Diffstat (limited to 'content')
-rw-r--r--content/browser/devtools/protocol/emulation_handler.cc38
-rw-r--r--content/browser/devtools/protocol/emulation_handler.h9
-rw-r--r--content/browser/devtools/render_frame_devtools_agent_host.cc4
3 files changed, 6 insertions, 45 deletions
diff --git a/content/browser/devtools/protocol/emulation_handler.cc b/content/browser/devtools/protocol/emulation_handler.cc
index 9659991..cae9f00 100644
--- a/content/browser/devtools/protocol/emulation_handler.cc
+++ b/content/browser/devtools/protocol/emulation_handler.cc
@@ -35,19 +35,11 @@ ui::GestureProviderConfigType TouchEmulationConfigurationToType(
return result;
}
-// When continuously applying device emulation, we wait for compositor frame
-// before applying new values. If the frame does not arrive during this
-// timeout, we proceed anyway.
-const int kFrameTimeoutMs = 67;
-
} // namespace
EmulationHandler::EmulationHandler(page::PageHandler* page_handler)
: touch_emulation_enabled_(false),
device_emulation_enabled_(false),
- device_emulation_needs_update_(false),
- device_emulation_waiting_for_frame_(false),
- frame_timer_(new base::Timer(false, false)),
page_handler_(page_handler),
host_(nullptr)
{
@@ -67,14 +59,14 @@ void EmulationHandler::SetRenderFrameHost(RenderFrameHostImpl* host) {
host_ = host;
UpdateTouchEventEmulationState();
- ApplyDeviceEmulationState();
+ UpdateDeviceEmulationState();
}
void EmulationHandler::Detached() {
touch_emulation_enabled_ = false;
device_emulation_enabled_ = false;
UpdateTouchEventEmulationState();
- ApplyDeviceEmulationState();
+ UpdateDeviceEmulationState();
}
Response EmulationHandler::SetGeolocationOverride(
@@ -200,7 +192,7 @@ Response EmulationHandler::SetDeviceMetricsOverride(
device_emulation_enabled_ = true;
device_emulation_params_ = params;
- DeviceEmulationNeedsUpdate();
+ UpdateDeviceEmulationState();
return Response::OK();
}
@@ -209,7 +201,7 @@ Response EmulationHandler::ClearDeviceMetricsOverride() {
return Response::OK();
device_emulation_enabled_ = false;
- DeviceEmulationNeedsUpdate();
+ UpdateDeviceEmulationState();
return Response::OK();
}
@@ -233,31 +225,11 @@ void EmulationHandler::UpdateTouchEventEmulationState() {
GetWebContents()->SetForceDisableOverscrollContent(enabled);
}
-void EmulationHandler::DeviceEmulationNeedsUpdate() {
- device_emulation_needs_update_ = true;
- if (!device_emulation_waiting_for_frame_)
- ApplyDeviceEmulationState();
-}
-
-void EmulationHandler::OnSwapCompositorFrame() {
- frame_timer_->Stop();
- device_emulation_waiting_for_frame_ = false;
- if (device_emulation_needs_update_)
- ApplyDeviceEmulationState();
-}
-
-void EmulationHandler::ApplyDeviceEmulationState() {
- device_emulation_needs_update_ = false;
+void EmulationHandler::UpdateDeviceEmulationState() {
RenderWidgetHostImpl* widget_host =
host_ ? host_->GetRenderWidgetHost() : nullptr;
if (!widget_host)
return;
- device_emulation_waiting_for_frame_ = true;
- frame_timer_->Start(
- FROM_HERE,
- base::TimeDelta::FromMilliseconds(kFrameTimeoutMs),
- base::Bind(&EmulationHandler::OnSwapCompositorFrame,
- base::Unretained(this)));
if (device_emulation_enabled_) {
widget_host->Send(new ViewMsg_EnableDeviceEmulation(
widget_host->GetRoutingID(), device_emulation_params_));
diff --git a/content/browser/devtools/protocol/emulation_handler.h b/content/browser/devtools/protocol/emulation_handler.h
index 4f1e26f..c2a4bd3 100644
--- a/content/browser/devtools/protocol/emulation_handler.h
+++ b/content/browser/devtools/protocol/emulation_handler.h
@@ -5,7 +5,6 @@
#ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_EMULATION_HANDLER_H_
#define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_EMULATION_HANDLER_H_
-#include "base/timer/timer.h"
#include "content/browser/devtools/protocol/devtools_protocol_dispatcher.h"
#include "content/browser/devtools/protocol/page_handler.h"
#include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
@@ -33,7 +32,6 @@ class EmulationHandler : public page::PageHandler::ScreencastListener {
void SetRenderFrameHost(RenderFrameHostImpl* host);
void Detached();
- void OnSwapCompositorFrame();
Response SetGeolocationOverride(double* latitude,
double* longitude,
@@ -61,18 +59,13 @@ class EmulationHandler : public page::PageHandler::ScreencastListener {
private:
WebContentsImpl* GetWebContents();
void UpdateTouchEventEmulationState();
-
- void DeviceEmulationNeedsUpdate();
- void ApplyDeviceEmulationState();
+ void UpdateDeviceEmulationState();
bool touch_emulation_enabled_;
std::string touch_emulation_configuration_;
bool device_emulation_enabled_;
blink::WebDeviceEmulationParams device_emulation_params_;
- bool device_emulation_needs_update_;
- bool device_emulation_waiting_for_frame_;
- scoped_ptr<base::Timer> frame_timer_;
page::PageHandler* page_handler_;
RenderFrameHostImpl* host_;
diff --git a/content/browser/devtools/render_frame_devtools_agent_host.cc b/content/browser/devtools/render_frame_devtools_agent_host.cc
index 4c5b369..fb191fb 100644
--- a/content/browser/devtools/render_frame_devtools_agent_host.cc
+++ b/content/browser/devtools/render_frame_devtools_agent_host.cc
@@ -716,8 +716,6 @@ void RenderFrameDevToolsAgentHost::OnSwapCompositorFrame(
page_handler_->OnSwapCompositorFrame(base::get<1>(param).metadata);
if (input_handler_)
input_handler_->OnSwapCompositorFrame(base::get<1>(param).metadata);
- if (emulation_handler_)
- emulation_handler_->OnSwapCompositorFrame();
if (frame_trace_recorder_ && tracing_handler_->did_initiate_recording()) {
frame_trace_recorder_->OnSwapCompositorFrame(
current_ ? current_->host() : nullptr,
@@ -731,8 +729,6 @@ void RenderFrameDevToolsAgentHost::SynchronousSwapCompositorFrame(
page_handler_->OnSynchronousSwapCompositorFrame(frame_metadata);
if (input_handler_)
input_handler_->OnSwapCompositorFrame(frame_metadata);
- if (emulation_handler_)
- emulation_handler_->OnSwapCompositorFrame();
if (frame_trace_recorder_ && tracing_handler_->did_initiate_recording()) {
frame_trace_recorder_->OnSynchronousSwapCompositorFrame(
current_ ? current_->host() : nullptr,