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

Side by Side Diff: content/browser/tracing/etw_system_event_consumer_win.h

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 unified diff | Download patch
OLDNEW
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 #ifndef CONTENT_BROWSER_TRACING_ETW_SYSTEM_EVENT_CONSUMER_WIN_H_ 5 #ifndef CONTENT_BROWSER_TRACING_ETW_SYSTEM_EVENT_CONSUMER_WIN_H_
6 #define CONTENT_BROWSER_TRACING_ETW_SYSTEM_EVENT_CONSUMER_WIN_H_ 6 #define CONTENT_BROWSER_TRACING_ETW_SYSTEM_EVENT_CONSUMER_WIN_H_
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "base/trace_event/tracing_agent.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "base/win/event_trace_consumer.h" 13 #include "base/win/event_trace_consumer.h"
13 #include "base/win/event_trace_controller.h" 14 #include "base/win/event_trace_controller.h"
14 15
15 namespace base { 16 namespace base {
16 template <typename Type> 17 template <typename Type>
17 struct DefaultSingletonTraits; 18 struct DefaultSingletonTraits;
18 } 19 }
19 20
20 namespace content { 21 namespace content {
21 22
22 class EtwSystemEventConsumer : 23 class EtwSystemEventConsumer
23 public base::win::EtwTraceConsumerBase<EtwSystemEventConsumer> { 24 : public base::win::EtwTraceConsumerBase<EtwSystemEventConsumer>,
25 public base::trace_event::TracingAgent {
24 public: 26 public:
25 typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&)> 27 // base::trace_event::TracingAgent implementation.
26 OutputCallback; 28 std::string GetTracingAgentName() override;
27 29 std::string GetTraceEventLabel() override;
28 bool StartSystemTracing(); 30 bool StartAgentTracing(
29 void StopSystemTracing(const OutputCallback& callback); 31 const base::trace_event::TraceConfig& trace_config) override;
32 void StopAgentTracing(const StopAgentTracingCallback& callback) override;
30 33
31 // Retrieve the ETW consumer instance. 34 // Retrieve the ETW consumer instance.
32 static EtwSystemEventConsumer* GetInstance(); 35 static EtwSystemEventConsumer* GetInstance();
33 36
34 private: 37 private:
35 // This allows constructor and destructor to be private and usable only 38 // This allows constructor and destructor to be private and usable only
36 // by the Singleton class. 39 // by the Singleton class.
37 friend struct base::DefaultSingletonTraits<EtwSystemEventConsumer>; 40 friend struct base::DefaultSingletonTraits<EtwSystemEventConsumer>;
38 41
39 // Constructor. 42 // Constructor.
40 EtwSystemEventConsumer(); 43 EtwSystemEventConsumer();
41 virtual ~EtwSystemEventConsumer(); 44 ~EtwSystemEventConsumer() override;
42 45
43 void AddSyncEventToBuffer(); 46 void AddSyncEventToBuffer();
44 void AppendEventToBuffer(EVENT_TRACE* event); 47 void AppendEventToBuffer(EVENT_TRACE* event);
45 48
46 // Static override of EtwTraceConsumerBase::ProcessEvent. 49 // Static override of EtwTraceConsumerBase::ProcessEvent.
47 // @param event the raw ETW event to process. 50 // @param event the raw ETW event to process.
48 friend class base::win::EtwTraceConsumerBase<EtwSystemEventConsumer>; 51 friend class base::win::EtwTraceConsumerBase<EtwSystemEventConsumer>;
49 static void ProcessEvent(EVENT_TRACE* event); 52 static void ProcessEvent(EVENT_TRACE* event);
50 53
51 // Request the ETW trace controller to activate the kernel tracing. 54 // Request the ETW trace controller to activate the kernel tracing.
52 // returns true on success, false if the kernel tracing isn't activated. 55 // returns true on success, false if the kernel tracing isn't activated.
53 bool StartKernelSessionTracing(); 56 bool StartKernelSessionTracing();
54 57
55 // Request the ETW trace controller to deactivate the kernel tracing. 58 // Request the ETW trace controller to deactivate the kernel tracing.
56 // @param callback the callback to call with the consumed events. 59 // @param callback the callback to call with the consumed events.
57 // @returns true on success, false if an error occurred. 60 // @returns true on success, false if an error occurred.
58 bool StopKernelSessionTracing(); 61 bool StopKernelSessionTracing();
59 62
60 void OnStopSystemTracingDone( 63 void OnStopSystemTracingDone(
61 const OutputCallback& callback, 64 const StopAgentTracingCallback& callback,
62 const scoped_refptr<base::RefCountedString>& result); 65 const scoped_refptr<base::RefCountedString>& result);
63 66
64 void TraceAndConsumeOnThread(); 67 void TraceAndConsumeOnThread();
65 void FlushOnThread(const OutputCallback& callback); 68 void FlushOnThread(const StopAgentTracingCallback& callback);
66 69
67 scoped_ptr<base::ListValue> events_; 70 scoped_ptr<base::ListValue> events_;
68 base::Thread thread_; 71 base::Thread thread_;
69 TRACEHANDLE session_handle_; 72 TRACEHANDLE session_handle_;
70 base::win::EtwTraceProperties properties_; 73 base::win::EtwTraceProperties properties_;
71 74
72 DISALLOW_COPY_AND_ASSIGN(EtwSystemEventConsumer); 75 DISALLOW_COPY_AND_ASSIGN(EtwSystemEventConsumer);
73 }; 76 };
74 77
75 } // namespace content 78 } // namespace content
76 79
77 #endif // CONTENT_BROWSER_TRACING_ETW_SYSTEM_EVENT_CONSUMER_WIN_H_ 80 #endif // CONTENT_BROWSER_TRACING_ETW_SYSTEM_EVENT_CONSUMER_WIN_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_debug_daemon_client.cc ('k') | content/browser/tracing/etw_system_event_consumer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698