#include "base/process/process.h"
#include "base/strings/string_number_conversions.h"
#include "content/common/devtools_messages.h"
+#include "content/common/frame_messages.h"
+#include "content/common/gpu/gpu_messages.h"
#include "content/common/view_messages.h"
#include "content/renderer/devtools/devtools_agent_filter.h"
#include "content/renderer/devtools/devtools_client.h"
+#include "content/renderer/render_thread_impl.h"
#include "content/renderer/render_view_impl.h"
#include "third_party/WebKit/public/platform/WebPoint.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
#endif
-using WebKit::WebConsoleMessage;
-using WebKit::WebDevToolsAgent;
-using WebKit::WebDevToolsAgentClient;
-using WebKit::WebFrame;
-using WebKit::WebPoint;
-using WebKit::WebString;
-using WebKit::WebCString;
-using WebKit::WebVector;
-using WebKit::WebView;
+using blink::WebConsoleMessage;
+using blink::WebDevToolsAgent;
+using blink::WebDevToolsAgentClient;
+using blink::WebFrame;
+using blink::WebPoint;
+using blink::WebString;
+using blink::WebCString;
+using blink::WebVector;
+using blink::WebView;
using base::debug::TraceLog;
DevToolsAgent::DevToolsAgent(RenderViewImpl* render_view)
: RenderViewObserver(render_view),
is_attached_(false),
- is_devtools_client_(false) {
+ is_devtools_client_(false),
+ gpu_route_id_(MSG_ROUTING_NONE) {
g_agent_for_routing_id.Get()[routing_id()] = this;
render_view->webview()->setDevToolsAgentClient(this);
DevToolsAgent::~DevToolsAgent() {
g_agent_for_routing_id.Get().erase(routing_id());
+ setTraceEventCallback(NULL);
}
// Called on the Renderer thread.
IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement)
IPC_MESSAGE_HANDLER(DevToolsAgentMsg_AddMessageToConsole,
OnAddMessageToConsole)
+ IPC_MESSAGE_HANDLER(DevToolsAgentMsg_GpuTasksChunk, OnGpuTasksChunk)
IPC_MESSAGE_HANDLER(DevToolsMsg_SetupDevToolsClient, OnSetupDevToolsClient)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
- if (message.type() == ViewMsg_Navigate::ID ||
+ if (message.type() == FrameMsg_Navigate::ID ||
message.type() == ViewMsg_Close::ID)
ContinueProgram(); // Don't want to swallow the message.
}
void DevToolsAgent::sendMessageToInspectorFrontend(
- const WebKit::WebString& message) {
+ const blink::WebString& message) {
Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(routing_id(),
message.utf8()));
}
}
void DevToolsAgent::saveAgentRuntimeState(
- const WebKit::WebString& state) {
+ const blink::WebString& state) {
Send(new DevToolsHostMsg_SaveAgentRuntimeState(routing_id(), state.utf8()));
}
-WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop*
+blink::WebDevToolsAgentClient::WebKitClientMessageLoop*
DevToolsAgent::createClientMessageLoop() {
return new WebKitClientMessageLoopImpl();
}
void DevToolsAgent::setTraceEventCallback(TraceEventCallback cb) {
TraceLog* trace_log = TraceLog::GetInstance();
- trace_log->SetEventCallback(cb ? TraceEventCallbackWrapper : 0);
base::subtle::NoBarrier_Store(&event_callback_,
reinterpret_cast<base::subtle::AtomicWord>(cb));
if (!!cb) {
- trace_log->SetEnabled(base::debug::CategoryFilter(
+ trace_log->SetEventCallbackEnabled(base::debug::CategoryFilter(
base::debug::CategoryFilter::kDefaultCategoryFilterString),
- TraceLog::RECORD_UNTIL_FULL);
+ TraceEventCallbackWrapper);
} else {
- trace_log->SetDisabled();
+ trace_log->SetEventCallbackDisabled();
}
}
+// static
void DevToolsAgent::TraceEventCallbackWrapper(
base::TimeTicks timestamp,
char phase,
}
}
+void DevToolsAgent::startGPUEventsRecording() {
+ GpuChannelHost* gpu_channel_host =
+ RenderThreadImpl::current()->GetGpuChannel();
+ if (!gpu_channel_host)
+ return;
+ DCHECK(gpu_route_id_ == MSG_ROUTING_NONE);
+ gpu_channel_host->Send(
+ new GpuChannelMsg_DevToolsStartEventsRecording(&gpu_route_id_));
+ DCHECK(gpu_route_id_ != MSG_ROUTING_NONE);
+ if (gpu_route_id_ != MSG_ROUTING_NONE) {
+ gpu_channel_host->AddRoute(gpu_route_id_, AsWeakPtr());
+ }
+}
+
+void DevToolsAgent::stopGPUEventsRecording() {
+ GpuChannelHost* gpu_channel_host =
+ RenderThreadImpl::current()->GetGpuChannel();
+ if (!gpu_channel_host || gpu_route_id_ == MSG_ROUTING_NONE)
+ return;
+ gpu_channel_host->Send(new GpuChannelMsg_DevToolsStopEventsRecording());
+ gpu_channel_host->RemoveRoute(gpu_route_id_);
+ gpu_route_id_ = MSG_ROUTING_NONE;
+}
+
+void DevToolsAgent::OnGpuTasksChunk(const std::vector<GpuTaskInfo>& tasks) {
+ WebDevToolsAgent* web_agent = GetWebAgent();
+ if (!web_agent)
+ return;
+ for (size_t i = 0; i < tasks.size(); i++) {
+ const GpuTaskInfo& task = tasks[i];
+ WebDevToolsAgent::GPUEvent event(task.timestamp, task.phase, task.foreign,
+ static_cast<size_t>(task.used_gpu_memory_bytes));
+ web_agent->processGPUEvent(event);
+ }
+}
+
void DevToolsAgent::enableDeviceEmulation(
- const WebKit::WebSize& device_size,
- const WebKit::WebRect& view_rect,
+ const blink::WebRect& device_rect,
+ const blink::WebRect& view_rect,
float device_scale_factor,
bool fit_to_view) {
RenderViewImpl* impl = static_cast<RenderViewImpl*>(render_view());
impl->webview()->settings()->setForceCompositingMode(true);
- impl->EnableScreenMetricsEmulation(gfx::Size(device_size),
+ impl->EnableScreenMetricsEmulation(gfx::Rect(device_rect),
gfx::Rect(view_rect), device_scale_factor, fit_to_view);
}
#if defined(USE_TCMALLOC) && !defined(OS_WIN)
static void AllocationVisitor(void* data, const void* ptr) {
- typedef WebKit::WebDevToolsAgentClient::AllocatedObjectVisitor Visitor;
+ typedef blink::WebDevToolsAgentClient::AllocatedObjectVisitor Visitor;
Visitor* visitor = reinterpret_cast<Visitor*>(data);
visitor->visitObject(ptr);
}