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

Unified Diff: chrome/gpu/gpu_thread.cc

Issue 6551019: Trace_event upgrades (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More gooder js thanks to arv. Created 9 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/gpu/gpu_thread.cc
diff --git a/chrome/gpu/gpu_thread.cc b/chrome/gpu/gpu_thread.cc
index f9f33417c61234e40bbbc05de785eb6b14216fbe..e73f2bf5ed920850a06df46a5eb5c501d7646084 100644
--- a/chrome/gpu/gpu_thread.cc
+++ b/chrome/gpu/gpu_thread.cc
@@ -11,6 +11,7 @@
#include "app/gfx/gl/gl_implementation.h"
#include "app/win/scoped_com_initializer.h"
#include "base/command_line.h"
+#include "base/debug/trace_event.h"
#include "base/threading/worker_pool.h"
#include "build/build_config.h"
#include "chrome/common/child_process.h"
@@ -52,7 +53,12 @@ GpuThread::GpuThread(const std::string& channel_id)
}
GpuThread::~GpuThread() {
- logging::SetLogMessageHandler(NULL);
+ bool single_process = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSingleProcess);
+ if (!single_process) {
+ logging::SetLogMessageHandler(NULL);
+ base::debug::TraceLog::GetInstance()->SetOutputCallback(NULL);
+ }
}
void GpuThread::Init(const base::Time& process_start_time) {
@@ -74,6 +80,8 @@ bool GpuThread::OnControlMessageReceived(const IPC::Message& msg) {
OnCreateViewCommandBuffer);
IPC_MESSAGE_HANDLER(GpuMsg_Synchronize, OnSynchronize)
IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo)
+ IPC_MESSAGE_HANDLER(GpuMsg_SetTraceEnabled,
+ OnSetTraceEnabled)
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(GpuMsg_AcceleratedSurfaceBuffersSwappedACK,
OnAcceleratedSurfaceBuffersSwappedACK)
@@ -103,12 +111,18 @@ bool GpuProcessLogMessageHandler(int severity,
} // namespace
void GpuThread::OnInitialize() {
- // Redirect LOG messages to the GpuProcessHost
+
bool single_process = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSingleProcess);
- if (!single_process)
+ if (!single_process) {
+ // Redirect LOG messages to the GpuProcessHost
logging::SetLogMessageHandler(GpuProcessLogMessageHandler);
+ // Forward trace data
+ base::debug::TraceLog::GetInstance()->SetOutputCallback(NewCallback(this,
+ &GpuThread::OnTraceDataCollected));
+ }
+
// Load the GL implementation and locate the bindings before starting the GPU
// watchdog because this can take a lot of time and the GPU watchdog might
// terminate the GPU process.
@@ -117,6 +131,7 @@ void GpuThread::OnInitialize() {
MessageLoop::current()->Quit();
return;
}
+
gpu_info_collector::CollectGraphicsInfo(&gpu_info_);
child_process_logging::SetGpuInfo(gpu_info_);
LOG(INFO) << "gpu_info_collector::CollectGraphicsInfo complete";
@@ -218,6 +233,14 @@ void GpuThread::OnCloseChannel(const IPC::ChannelHandle& channel_handle) {
}
}
+void GpuThread::OnSetTraceEnabled(bool enabled) {
+ base::debug::TraceLog::GetInstance()->SetEnabled(enabled);
+ if (!enabled) {
+ std::string json_complete("['TRACE_ENDED']");
+ Send(new GpuHostMsg_TraceDataCollectedRemotely(json_complete));
+ }
+}
+
void GpuThread::OnSynchronize() {
Send(new GpuHostMsg_SynchronizeReply());
}
@@ -281,6 +304,8 @@ void GpuThread::OnDidDestroyAcceleratedSurface(
void GpuThread::OnCrash() {
LOG(INFO) << "GPU: Simulating GPU crash";
+ TRACE_EVENT_INSTANT0("GPU_CRITICAL", "GpuThread::OnCrash");
+
// Good bye, cruel world.
volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL;
*it_s_the_end_of_the_world_as_we_know_it = 0xdead;
@@ -288,12 +313,17 @@ void GpuThread::OnCrash() {
void GpuThread::OnHang() {
LOG(INFO) << "GPU: Simulating GPU hang";
+ TRACE_EVENT_INSTANT0("GPU_CRITICAL", "GpuThread::OnHang");
for (;;) {
// Do not sleep here. The GPU watchdog timer tracks the amount of user
// time this thread is using and it doesn't use much while calling Sleep.
}
}
+void GpuThread::OnTraceDataCollected(const std::string& json_events) {
+ Send(new GpuHostMsg_TraceDataCollectedRemotely(json_events));
+}
+
#if defined(OS_WIN)
// Runs on a worker thread. The GpuThread never terminates voluntarily so it is

Powered by Google App Engine
This is Rietveld 408576698