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

Side by Side Diff: content/renderer/devtools/devtools_agent.cc

Issue 1521113002: DevTools: Initial implementation of slow CPU emulation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 4 landing Created 5 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/devtools/devtools_agent.h" 5 #include "content/renderer/devtools/devtools_agent.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "content/common/devtools_messages.h" 13 #include "content/common/devtools_messages.h"
14 #include "content/common/frame_messages.h" 14 #include "content/common/frame_messages.h"
15 #include "content/renderer/devtools/devtools_client.h" 15 #include "content/renderer/devtools/devtools_client.h"
16 #include "content/renderer/devtools/devtools_cpu_throttler.h"
16 #include "content/renderer/render_frame_impl.h" 17 #include "content/renderer/render_frame_impl.h"
17 #include "content/renderer/render_widget.h" 18 #include "content/renderer/render_widget.h"
18 #include "ipc/ipc_channel.h" 19 #include "ipc/ipc_channel.h"
19 #include "third_party/WebKit/public/platform/WebPoint.h" 20 #include "third_party/WebKit/public/platform/WebPoint.h"
20 #include "third_party/WebKit/public/platform/WebString.h" 21 #include "third_party/WebKit/public/platform/WebString.h"
21 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 22 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
22 #include "third_party/WebKit/public/web/WebDevToolsAgent.h" 23 #include "third_party/WebKit/public/web/WebDevToolsAgent.h"
23 #include "third_party/WebKit/public/web/WebLocalFrame.h" 24 #include "third_party/WebKit/public/web/WebLocalFrame.h"
24 25
25 #if defined(USE_TCMALLOC) 26 #if defined(USE_TCMALLOC)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER; 62 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER;
62 63
63 } // namespace 64 } // namespace
64 65
65 DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame) 66 DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame)
66 : RenderFrameObserver(frame), 67 : RenderFrameObserver(frame),
67 is_attached_(false), 68 is_attached_(false),
68 is_devtools_client_(false), 69 is_devtools_client_(false),
69 paused_in_mouse_move_(false), 70 paused_in_mouse_move_(false),
70 paused_(false), 71 paused_(false),
71 frame_(frame) { 72 frame_(frame),
73 cpu_throttler_(new DevToolsCPUThrottler()) {
72 g_agent_for_routing_id.Get()[routing_id()] = this; 74 g_agent_for_routing_id.Get()[routing_id()] = this;
73 frame_->GetWebFrame()->setDevToolsAgentClient(this); 75 frame_->GetWebFrame()->setDevToolsAgentClient(this);
74 } 76 }
75 77
76 DevToolsAgent::~DevToolsAgent() { 78 DevToolsAgent::~DevToolsAgent() {
77 g_agent_for_routing_id.Get().erase(routing_id()); 79 g_agent_for_routing_id.Get().erase(routing_id());
78 } 80 }
79 81
80 // Called on the Renderer thread. 82 // Called on the Renderer thread.
81 bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { 83 bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 TraceLog* trace_log = TraceLog::GetInstance(); 142 TraceLog* trace_log = TraceLog::GetInstance();
141 trace_log->SetEnabled( 143 trace_log->SetEnabled(
142 base::trace_event::TraceConfig(category_filter.utf8(), ""), 144 base::trace_event::TraceConfig(category_filter.utf8(), ""),
143 TraceLog::RECORDING_MODE); 145 TraceLog::RECORDING_MODE);
144 } 146 }
145 147
146 void DevToolsAgent::disableTracing() { 148 void DevToolsAgent::disableTracing() {
147 TraceLog::GetInstance()->SetDisabled(); 149 TraceLog::GetInstance()->SetDisabled();
148 } 150 }
149 151
152 void DevToolsAgent::setCPUThrottlingRate(double rate) {
153 cpu_throttler_->SetThrottlingRate(rate);
154 }
155
150 // static 156 // static
151 DevToolsAgent* DevToolsAgent::FromRoutingId(int routing_id) { 157 DevToolsAgent* DevToolsAgent::FromRoutingId(int routing_id) {
152 IdToAgentMap::iterator it = g_agent_for_routing_id.Get().find(routing_id); 158 IdToAgentMap::iterator it = g_agent_for_routing_id.Get().find(routing_id);
153 if (it != g_agent_for_routing_id.Get().end()) { 159 if (it != g_agent_for_routing_id.Get().end()) {
154 return it->second; 160 return it->second;
155 } 161 }
156 return NULL; 162 return NULL;
157 } 163 }
158 164
159 // static 165 // static
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { 285 WebDevToolsAgent* DevToolsAgent::GetWebAgent() {
280 WebLocalFrame* web_frame = frame_->GetWebFrame(); 286 WebLocalFrame* web_frame = frame_->GetWebFrame();
281 return web_frame ? web_frame->devToolsAgent() : nullptr; 287 return web_frame ? web_frame->devToolsAgent() : nullptr;
282 } 288 }
283 289
284 bool DevToolsAgent::IsAttached() { 290 bool DevToolsAgent::IsAttached() {
285 return is_attached_; 291 return is_attached_;
286 } 292 }
287 293
288 } // namespace content 294 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/devtools/devtools_agent.h ('k') | content/renderer/devtools/devtools_cpu_throttler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698