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

Unified Diff: content/browser/tracing/etw_system_event_consumer_win.cc

Issue 1468173003: [Tracing Clock Sync] Add TracingAgent interface in Chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review fix 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/tracing/etw_system_event_consumer_win.cc
diff --git a/content/browser/tracing/etw_system_event_consumer_win.cc b/content/browser/tracing/etw_system_event_consumer_win.cc
index 529800f2202c48f7efce6795e2475e7acf20e0aa..d1a12cc0ff7aab9a889dc9bd21138a161fc820db 100644
--- a/content/browser/tracing/etw_system_event_consumer_win.cc
+++ b/content/browser/tracing/etw_system_event_consumer_win.cc
@@ -17,6 +17,9 @@ namespace content {
namespace {
+const char kETWTracingAgentName[] = "etw";
+const char kETWTraceLabel[] = "systemTraceEvents";
+
const int kEtwBufferSizeInKBytes = 16;
const int kEtwBufferFlushTimeoutInSeconds = 1;
@@ -36,8 +39,16 @@ EtwSystemEventConsumer::EtwSystemEventConsumer()
EtwSystemEventConsumer::~EtwSystemEventConsumer() {
}
-bool EtwSystemEventConsumer::StartSystemTracing() {
+std::string EtwSystemEventConsumer::GetTracingAgentName() {
+ return kETWTracingAgentName;
+}
+std::string EtwSystemEventConsumer::GetTraceEventLabel() {
+ return kETWTraceLabel;
+}
+
+bool EtwSystemEventConsumer::StartAgentTracing(
+ const base::trace_event::TraceConfig& trace_config) {
// Activate kernel tracing.
if (!StartKernelSessionTracing())
return false;
@@ -52,31 +63,29 @@ bool EtwSystemEventConsumer::StartSystemTracing() {
return true;
}
-void EtwSystemEventConsumer::StopSystemTracing(const OutputCallback& callback) {
+void EtwSystemEventConsumer::StopAgentTracing(
+ const StopAgentTracingCallback& callback) {
// Deactivate kernel tracing.
if (!StopKernelSessionTracing()) {
LOG(FATAL) << "Could not stop system tracing.";
}
// Stop consuming and flush events.
- OutputCallback on_stop_system_tracing_done_callback =
- base::Bind(&EtwSystemEventConsumer::OnStopSystemTracingDone,
- base::Unretained(this),
- callback);
thread_.message_loop()->PostTask(FROM_HERE,
base::Bind(&EtwSystemEventConsumer::FlushOnThread,
- base::Unretained(this), on_stop_system_tracing_done_callback));
+ base::Unretained(this),
+ callback));
}
void EtwSystemEventConsumer::OnStopSystemTracingDone(
- const OutputCallback& callback,
+ const StopAgentTracingCallback& callback,
const scoped_refptr<base::RefCountedString>& result) {
// Stop the consumer thread.
thread_.Stop();
// Pass the serialized events.
- callback.Run(result);
+ callback.Run(GetTracingAgentName(), GetTraceEventLabel(), result);
}
bool EtwSystemEventConsumer::StartKernelSessionTracing() {
@@ -209,7 +218,8 @@ void EtwSystemEventConsumer::TraceAndConsumeOnThread() {
Close();
}
-void EtwSystemEventConsumer::FlushOnThread(const OutputCallback& callback) {
+void EtwSystemEventConsumer::FlushOnThread(
+ const StopAgentTracingCallback& callback) {
// Add the header information to the stream.
scoped_ptr<base::DictionaryValue> header(new base::DictionaryValue());
header->Set("name", new base::StringValue("ETW"));
@@ -225,8 +235,12 @@ void EtwSystemEventConsumer::FlushOnThread(const OutputCallback& callback) {
// Pass the result to the UI Thread.
scoped_refptr<base::RefCountedString> result =
base::RefCountedString::TakeString(&output);
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(callback, result));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&EtwSystemEventConsumer::OnStopSystemTracingDone,
+ base::Unretained(this),
+ callback,
+ result));
}
} // namespace content
« no previous file with comments | « content/browser/tracing/etw_system_event_consumer_win.h ('k') | content/browser/tracing/power_tracing_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698