Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / tracing / etw_system_event_consumer_win.h
blob3611bee7c6037560cb65dad4c9f62a6f79267dc6
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_TRACING_ETW_SYSTEM_EVENT_CONSUMER_WIN_H_
6 #define CONTENT_BROWSER_TRACING_ETW_SYSTEM_EVENT_CONSUMER_WIN_H_
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"
15 template <typename Type>
16 struct DefaultSingletonTraits;
18 namespace content {
20 class EtwSystemEventConsumer :
21 public base::win::EtwTraceConsumerBase<EtwSystemEventConsumer> {
22 public:
23 typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&)>
24 OutputCallback;
26 bool StartSystemTracing();
27 void StopSystemTracing(const OutputCallback& callback);
29 // Retrieve the ETW consumer instance.
30 static EtwSystemEventConsumer* GetInstance();
32 private:
33 // This allows constructor and destructor to be private and usable only
34 // by the Singleton class.
35 friend struct DefaultSingletonTraits<EtwSystemEventConsumer>;
37 // Constructor.
38 EtwSystemEventConsumer();
39 virtual ~EtwSystemEventConsumer();
41 void AddSyncEventToBuffer();
42 void AppendEventToBuffer(EVENT_TRACE* event);
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);
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();
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();
58 void OnStopSystemTracingDone(
59 const OutputCallback& callback,
60 const scoped_refptr<base::RefCountedString>& result);
62 void TraceAndConsumeOnThread();
63 void FlushOnThread(const OutputCallback& callback);
65 scoped_ptr<base::ListValue> events_;
66 base::Thread thread_;
67 TRACEHANDLE session_handle_;
68 base::win::EtwTraceProperties properties_;
70 DISALLOW_COPY_AND_ASSIGN(EtwSystemEventConsumer);
73 } // namespace content
75 #endif // CONTENT_BROWSER_TRACING_ETW_SYSTEM_EVENT_CONSUMER_WIN_H_