OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/tracing/etw_system_event_consumer_win.h" | 5 #include "content/browser/tracing/etw_system_event_consumer_win.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/thread_task_runner_handle.h" | |
14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
15 #include "base/trace_event/trace_event_impl.h" | 16 #include "base/trace_event/trace_event_impl.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 const char kETWTracingAgentName[] = "etw"; | 23 const char kETWTracingAgentName[] = "etw"; |
23 const char kETWTraceLabel[] = "systemTraceEvents"; | 24 const char kETWTraceLabel[] = "systemTraceEvents"; |
(...skipping 18 matching lines...) Expand all Loading... | |
42 } | 43 } |
43 | 44 |
44 std::string EtwSystemEventConsumer::GetTracingAgentName() { | 45 std::string EtwSystemEventConsumer::GetTracingAgentName() { |
45 return kETWTracingAgentName; | 46 return kETWTracingAgentName; |
46 } | 47 } |
47 | 48 |
48 std::string EtwSystemEventConsumer::GetTraceEventLabel() { | 49 std::string EtwSystemEventConsumer::GetTraceEventLabel() { |
49 return kETWTraceLabel; | 50 return kETWTraceLabel; |
50 } | 51 } |
51 | 52 |
52 bool EtwSystemEventConsumer::StartAgentTracing( | 53 void EtwSystemEventConsumer::StartAgentTracing( |
53 const base::trace_event::TraceConfig& trace_config) { | 54 const base::trace_event::TraceConfig& trace_config, |
55 const StartAgentTracingCallback& callback) { | |
54 // Activate kernel tracing. | 56 // Activate kernel tracing. |
55 if (!StartKernelSessionTracing()) | 57 if (!StartKernelSessionTracing()) { |
56 return false; | 58 base::ThreadTaskRunnerHandle::Get()->PostTask( |
59 FROM_HERE, base::Bind(callback, GetTracingAgentName(), false)); | |
stevenjb
2016/01/26 20:11:19
/* success */
charliea (OOO until 10-5)
2016/01/26 20:29:56
Done.
| |
60 return; | |
61 } | |
57 | 62 |
58 // Start the consumer thread and start consuming events. | 63 // Start the consumer thread and start consuming events. |
59 thread_.Start(); | 64 thread_.Start(); |
60 thread_.message_loop()->PostTask( | 65 thread_.message_loop()->PostTask( |
61 FROM_HERE, | 66 FROM_HERE, |
62 base::Bind(&EtwSystemEventConsumer::TraceAndConsumeOnThread, | 67 base::Bind(&EtwSystemEventConsumer::TraceAndConsumeOnThread, |
63 base::Unretained(this))); | 68 base::Unretained(this))); |
64 | 69 |
65 return true; | 70 base::ThreadTaskRunnerHandle::Get()->PostTask( |
71 FROM_HERE, base::Bind(callback, GetTracingAgentName(), true)); | |
stevenjb
2016/01/26 20:11:19
/* success */
charliea (OOO until 10-5)
2016/01/26 20:29:56
Done.
| |
66 } | 72 } |
67 | 73 |
68 void EtwSystemEventConsumer::StopAgentTracing( | 74 void EtwSystemEventConsumer::StopAgentTracing( |
69 const StopAgentTracingCallback& callback) { | 75 const StopAgentTracingCallback& callback) { |
70 // Deactivate kernel tracing. | 76 // Deactivate kernel tracing. |
71 if (!StopKernelSessionTracing()) { | 77 if (!StopKernelSessionTracing()) { |
72 LOG(FATAL) << "Could not stop system tracing."; | 78 LOG(FATAL) << "Could not stop system tracing."; |
73 } | 79 } |
74 | 80 |
75 // Stop consuming and flush events. | 81 // Stop consuming and flush events. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 base::RefCountedString::TakeString(&output); | 244 base::RefCountedString::TakeString(&output); |
239 BrowserThread::PostTask( | 245 BrowserThread::PostTask( |
240 BrowserThread::UI, FROM_HERE, | 246 BrowserThread::UI, FROM_HERE, |
241 base::Bind(&EtwSystemEventConsumer::OnStopSystemTracingDone, | 247 base::Bind(&EtwSystemEventConsumer::OnStopSystemTracingDone, |
242 base::Unretained(this), | 248 base::Unretained(this), |
243 callback, | 249 callback, |
244 result)); | 250 result)); |
245 } | 251 } |
246 | 252 |
247 } // namespace content | 253 } // namespace content |
OLD | NEW |