| OLD | NEW |
| 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 11 matching lines...) Expand all Loading... |
| 22 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 22 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 23 #include "third_party/WebKit/public/web/WebDevToolsAgent.h" | 23 #include "third_party/WebKit/public/web/WebDevToolsAgent.h" |
| 24 #include "third_party/WebKit/public/web/WebFrame.h" | 24 #include "third_party/WebKit/public/web/WebFrame.h" |
| 25 #include "third_party/WebKit/public/web/WebSettings.h" | 25 #include "third_party/WebKit/public/web/WebSettings.h" |
| 26 #include "third_party/WebKit/public/web/WebView.h" | 26 #include "third_party/WebKit/public/web/WebView.h" |
| 27 | 27 |
| 28 #if defined(USE_TCMALLOC) | 28 #if defined(USE_TCMALLOC) |
| 29 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" | 29 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 using WebKit::WebConsoleMessage; | 32 using blink::WebConsoleMessage; |
| 33 using WebKit::WebDevToolsAgent; | 33 using blink::WebDevToolsAgent; |
| 34 using WebKit::WebDevToolsAgentClient; | 34 using blink::WebDevToolsAgentClient; |
| 35 using WebKit::WebFrame; | 35 using blink::WebFrame; |
| 36 using WebKit::WebPoint; | 36 using blink::WebPoint; |
| 37 using WebKit::WebString; | 37 using blink::WebString; |
| 38 using WebKit::WebCString; | 38 using blink::WebCString; |
| 39 using WebKit::WebVector; | 39 using blink::WebVector; |
| 40 using WebKit::WebView; | 40 using blink::WebView; |
| 41 | 41 |
| 42 using base::debug::TraceLog; | 42 using base::debug::TraceLog; |
| 43 | 43 |
| 44 namespace content { | 44 namespace content { |
| 45 | 45 |
| 46 base::subtle::AtomicWord DevToolsAgent::event_callback_; | 46 base::subtle::AtomicWord DevToolsAgent::event_callback_; |
| 47 | 47 |
| 48 namespace { | 48 namespace { |
| 49 | 49 |
| 50 class WebKitClientMessageLoopImpl | 50 class WebKitClientMessageLoopImpl |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 IPC_END_MESSAGE_MAP() | 101 IPC_END_MESSAGE_MAP() |
| 102 | 102 |
| 103 if (message.type() == ViewMsg_Navigate::ID || | 103 if (message.type() == ViewMsg_Navigate::ID || |
| 104 message.type() == ViewMsg_Close::ID) | 104 message.type() == ViewMsg_Close::ID) |
| 105 ContinueProgram(); // Don't want to swallow the message. | 105 ContinueProgram(); // Don't want to swallow the message. |
| 106 | 106 |
| 107 return handled; | 107 return handled; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void DevToolsAgent::sendMessageToInspectorFrontend( | 110 void DevToolsAgent::sendMessageToInspectorFrontend( |
| 111 const WebKit::WebString& message) { | 111 const blink::WebString& message) { |
| 112 Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(routing_id(), | 112 Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(routing_id(), |
| 113 message.utf8())); | 113 message.utf8())); |
| 114 } | 114 } |
| 115 | 115 |
| 116 int DevToolsAgent::hostIdentifier() { | 116 int DevToolsAgent::hostIdentifier() { |
| 117 return routing_id(); | 117 return routing_id(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void DevToolsAgent::saveAgentRuntimeState( | 120 void DevToolsAgent::saveAgentRuntimeState( |
| 121 const WebKit::WebString& state) { | 121 const blink::WebString& state) { |
| 122 Send(new DevToolsHostMsg_SaveAgentRuntimeState(routing_id(), state.utf8())); | 122 Send(new DevToolsHostMsg_SaveAgentRuntimeState(routing_id(), state.utf8())); |
| 123 } | 123 } |
| 124 | 124 |
| 125 WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop* | 125 blink::WebDevToolsAgentClient::WebKitClientMessageLoop* |
| 126 DevToolsAgent::createClientMessageLoop() { | 126 DevToolsAgent::createClientMessageLoop() { |
| 127 return new WebKitClientMessageLoopImpl(); | 127 return new WebKitClientMessageLoopImpl(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void DevToolsAgent::clearBrowserCache() { | 130 void DevToolsAgent::clearBrowserCache() { |
| 131 Send(new DevToolsHostMsg_ClearBrowserCache(routing_id())); | 131 Send(new DevToolsHostMsg_ClearBrowserCache(routing_id())); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void DevToolsAgent::clearBrowserCookies() { | 134 void DevToolsAgent::clearBrowserCookies() { |
| 135 Send(new DevToolsHostMsg_ClearBrowserCookies(routing_id())); | 135 Send(new DevToolsHostMsg_ClearBrowserCookies(routing_id())); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 164 reinterpret_cast<TraceEventCallback>( | 164 reinterpret_cast<TraceEventCallback>( |
| 165 base::subtle::NoBarrier_Load(&event_callback_)); | 165 base::subtle::NoBarrier_Load(&event_callback_)); |
| 166 if (callback) { | 166 if (callback) { |
| 167 double timestamp_seconds = (timestamp - base::TimeTicks()).InSecondsF(); | 167 double timestamp_seconds = (timestamp - base::TimeTicks()).InSecondsF(); |
| 168 callback(phase, category_group_enabled, name, id, num_args, | 168 callback(phase, category_group_enabled, name, id, num_args, |
| 169 arg_names, arg_types, arg_values, flags, timestamp_seconds); | 169 arg_names, arg_types, arg_values, flags, timestamp_seconds); |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 | 172 |
| 173 void DevToolsAgent::enableDeviceEmulation( | 173 void DevToolsAgent::enableDeviceEmulation( |
| 174 const WebKit::WebSize& device_size, | 174 const blink::WebSize& device_size, |
| 175 const WebKit::WebRect& view_rect, | 175 const blink::WebRect& view_rect, |
| 176 float device_scale_factor, | 176 float device_scale_factor, |
| 177 bool fit_to_view) { | 177 bool fit_to_view) { |
| 178 RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view()); | 178 RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view()); |
| 179 impl->webview()->settings()->setForceCompositingMode(true); | 179 impl->webview()->settings()->setForceCompositingMode(true); |
| 180 impl->EnableScreenMetricsEmulation(gfx::Size(device_size), | 180 impl->EnableScreenMetricsEmulation(gfx::Size(device_size), |
| 181 gfx::Rect(view_rect), device_scale_factor, fit_to_view); | 181 gfx::Rect(view_rect), device_scale_factor, fit_to_view); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void DevToolsAgent::disableDeviceEmulation() { | 184 void DevToolsAgent::disableDeviceEmulation() { |
| 185 RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view()); | 185 RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view()); |
| 186 impl->DisableScreenMetricsEmulation(); | 186 impl->DisableScreenMetricsEmulation(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 #if defined(USE_TCMALLOC) && !defined(OS_WIN) | 189 #if defined(USE_TCMALLOC) && !defined(OS_WIN) |
| 190 static void AllocationVisitor(void* data, const void* ptr) { | 190 static void AllocationVisitor(void* data, const void* ptr) { |
| 191 typedef WebKit::WebDevToolsAgentClient::AllocatedObjectVisitor Visitor; | 191 typedef blink::WebDevToolsAgentClient::AllocatedObjectVisitor Visitor; |
| 192 Visitor* visitor = reinterpret_cast<Visitor*>(data); | 192 Visitor* visitor = reinterpret_cast<Visitor*>(data); |
| 193 visitor->visitObject(ptr); | 193 visitor->visitObject(ptr); |
| 194 } | 194 } |
| 195 #endif | 195 #endif |
| 196 | 196 |
| 197 void DevToolsAgent::visitAllocatedObjects(AllocatedObjectVisitor* visitor) { | 197 void DevToolsAgent::visitAllocatedObjects(AllocatedObjectVisitor* visitor) { |
| 198 #if defined(USE_TCMALLOC) && !defined(OS_WIN) | 198 #if defined(USE_TCMALLOC) && !defined(OS_WIN) |
| 199 IterateAllocatedObjects(&AllocationVisitor, visitor); | 199 IterateAllocatedObjects(&AllocationVisitor, visitor); |
| 200 #endif | 200 #endif |
| 201 } | 201 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |