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

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

Issue 66193005: Independently enable recording and event callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
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/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 is_devtools_client_(false) { 75 is_devtools_client_(false) {
76 g_agent_for_routing_id.Get()[routing_id()] = this; 76 g_agent_for_routing_id.Get()[routing_id()] = this;
77 77
78 render_view->webview()->setDevToolsAgentClient(this); 78 render_view->webview()->setDevToolsAgentClient(this);
79 render_view->webview()->devToolsAgent()->setProcessId( 79 render_view->webview()->devToolsAgent()->setProcessId(
80 base::Process::Current().pid()); 80 base::Process::Current().pid());
81 } 81 }
82 82
83 DevToolsAgent::~DevToolsAgent() { 83 DevToolsAgent::~DevToolsAgent() {
84 g_agent_for_routing_id.Get().erase(routing_id()); 84 g_agent_for_routing_id.Get().erase(routing_id());
85 setTraceEventCallback(NULL);
85 } 86 }
86 87
87 // Called on the Renderer thread. 88 // Called on the Renderer thread.
88 bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { 89 bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) {
89 bool handled = true; 90 bool handled = true;
90 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) 91 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message)
91 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) 92 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach)
92 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach) 93 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach)
93 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) 94 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach)
94 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, 95 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void DevToolsAgent::clearBrowserCache() { 131 void DevToolsAgent::clearBrowserCache() {
131 Send(new DevToolsHostMsg_ClearBrowserCache(routing_id())); 132 Send(new DevToolsHostMsg_ClearBrowserCache(routing_id()));
132 } 133 }
133 134
134 void DevToolsAgent::clearBrowserCookies() { 135 void DevToolsAgent::clearBrowserCookies() {
135 Send(new DevToolsHostMsg_ClearBrowserCookies(routing_id())); 136 Send(new DevToolsHostMsg_ClearBrowserCookies(routing_id()));
136 } 137 }
137 138
138 void DevToolsAgent::setTraceEventCallback(TraceEventCallback cb) { 139 void DevToolsAgent::setTraceEventCallback(TraceEventCallback cb) {
139 TraceLog* trace_log = TraceLog::GetInstance(); 140 TraceLog* trace_log = TraceLog::GetInstance();
140 trace_log->SetEventCallback(cb ? TraceEventCallbackWrapper : 0);
141 base::subtle::NoBarrier_Store(&event_callback_, 141 base::subtle::NoBarrier_Store(&event_callback_,
142 reinterpret_cast<base::subtle::AtomicWord>(cb)); 142 reinterpret_cast<base::subtle::AtomicWord>(cb));
143 if (!!cb) { 143 if (!!cb) {
144 trace_log->SetEnabled(base::debug::CategoryFilter( 144 trace_log->SetEventCallbackEnabled(base::debug::CategoryFilter(
145 base::debug::CategoryFilter::kDefaultCategoryFilterString), 145 base::debug::CategoryFilter::kDefaultCategoryFilterString),
146 TraceLog::RECORD_UNTIL_FULL); 146 TraceEventCallbackWrapper);
147 } else { 147 } else {
148 trace_log->SetDisabled(); 148 trace_log->SetEventCallbackDisabled();
149 } 149 }
150 } 150 }
151 151
152 void DevToolsAgent::TraceEventCallbackWrapper( 152 void DevToolsAgent::TraceEventCallbackWrapper(
153 base::TimeTicks timestamp, 153 base::TimeTicks timestamp,
154 char phase, 154 char phase,
155 const unsigned char* category_group_enabled, 155 const unsigned char* category_group_enabled,
156 const char* name, 156 const char* name,
157 unsigned long long id, 157 unsigned long long id,
158 int num_args, 158 int num_args,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 if (!web_view) 298 if (!web_view)
299 return NULL; 299 return NULL;
300 return web_view->devToolsAgent(); 300 return web_view->devToolsAgent();
301 } 301 }
302 302
303 bool DevToolsAgent::IsAttached() { 303 bool DevToolsAgent::IsAttached() {
304 return is_attached_; 304 return is_attached_;
305 } 305 }
306 306
307 } // namespace content 307 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_shutdown_profile_dumper.cc ('k') | webkit/child/webkitplatformsupport_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698