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

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

Issue 171143002: Implements Windows system tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tracing
Patch Set: fix android build Created 6 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/tracing/etw_system_event_consumer_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_TRACING_TRACING_CONSUMER_WIN_H_
6 #define CONTENT_BROWSER_TRACING_TRACING_CONSUMER_WIN_H_
7
8 #include "base/bind.h"
9 #include "base/memory/ref_counted_memory.h"
10 #include "base/threading/thread.h"
11 #include "base/values.h"
12 #include "base/win/event_trace_consumer.h"
13 #include "base/win/event_trace_controller.h"
14
15 template <typename Type>
16 struct DefaultSingletonTraits;
17
18 namespace content {
19
20 class EtwSystemEventConsumer :
21 public base::win::EtwTraceConsumerBase<EtwSystemEventConsumer> {
22 public:
23 typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&)>
24 OutputCallback;
25
26 bool StartSystemTracing();
27 void StopSystemTracing(const OutputCallback& callback);
28
29 // Retrieve the ETW consumer instance.
30 static EtwSystemEventConsumer* GetInstance();
31
32 private:
33 // This allows constructor and destructor to be private and usable only
34 // by the Singleton class.
35 friend struct DefaultSingletonTraits<EtwSystemEventConsumer>;
36
37 // Constructor.
38 EtwSystemEventConsumer();
39 virtual ~EtwSystemEventConsumer();
40
41 void AddSyncEventToBuffer();
42 void AppendEventToBuffer(EVENT_TRACE* event);
43
44 // Static override of EtwTraceConsumerBase::ProcessEvent.
45 // @param event the raw ETW event to process.
46 friend class base::win::EtwTraceConsumerBase<EtwSystemEventConsumer>;
47 static void ProcessEvent(EVENT_TRACE* event);
48
49 // Request the ETW trace controller to activate the kernel tracing.
50 // returns true on success, false if the kernel tracing isn't activated.
51 bool StartKernelSessionTracing();
52
53 // Request the ETW trace controller to deactivate the kernel tracing.
54 // @param callback the callback to call with the consumed events.
55 // @returns true on success, false if an error occurred.
56 bool StopKernelSessionTracing();
57
58 void OnStopSystemTracingDone(
59 const OutputCallback& callback,
60 const scoped_refptr<base::RefCountedString>& result);
61
62 void TraceAndConsumeOnThread();
63 void FlushOnThread(const OutputCallback& callback);
64
65 scoped_ptr<base::ListValue> events_;
66 base::Thread thread_;
67 TRACEHANDLE session_handle_;
68 base::win::EtwTraceProperties properties_;
69
70 DISALLOW_COPY_AND_ASSIGN(EtwSystemEventConsumer);
71 };
72
73 } // namespace content
74
75 #endif // CONTENT_BROWSER_TRACING_TRACING_CONSUMER_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/tracing/etw_system_event_consumer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698