Chromium Code Reviews| Index: content/browser/tracing/etw_system_event_consumer_win.h |
| diff --git a/content/browser/tracing/etw_system_event_consumer_win.h b/content/browser/tracing/etw_system_event_consumer_win.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cfd391c0f4411d8bcfac6c5f6bda8c3c6267f9c0 |
| --- /dev/null |
| +++ b/content/browser/tracing/etw_system_event_consumer_win.h |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_TRACING_TRACING_CONSUMER_WIN_H_ |
| +#define CONTENT_BROWSER_TRACING_TRACING_CONSUMER_WIN_H_ |
| + |
| +#include "base/bind.h" |
| +#include "base/memory/ref_counted_memory.h" |
| +#include "base/threading/thread.h" |
| +#include "base/values.h" |
| +#include "base/win/event_trace_consumer.h" |
| +#include "base/win/event_trace_controller.h" |
| + |
| +template <typename Type> |
| +struct DefaultSingletonTraits; |
| + |
| +namespace content { |
| + |
| +class EtwSystemEventConsumer : |
| + public base::win::EtwTraceConsumerBase<EtwSystemEventConsumer> { |
| + public: |
| + typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&)> |
| + OutputCallback; |
| + |
| + bool StartSystemTracing(); |
| + bool StopSystemTracing(const OutputCallback& callback); |
| + |
| + // Retrieve the ETW consumer instance. |
| + static EtwSystemEventConsumer* GetInstance(); |
| + |
| + // Static override of EtwTraceConsumerBase::ProcessEvent. |
|
nduca
2014/02/21 05:22:10
use friends so this is private?
etienneb
2014/02/24 14:59:33
Done.
|
| + // @param event the raw ETW event to process. |
| + static void ProcessEvent(EVENT_TRACE* event); |
| + |
| + private: |
| + // This allows constructor and destructor to be private and usable only |
| + // by the Singleton class. |
| + friend struct DefaultSingletonTraits<EtwSystemEventConsumer>; |
| + |
| + // Constructor. |
| + EtwSystemEventConsumer(); |
| + virtual ~EtwSystemEventConsumer(); |
| + |
| + void AppendEventToBuffer(EVENT_TRACE* event); |
| + |
| + // Request the ETW trace controller to activate the kernel tracing. |
| + // returns true on success, false if the kernel tracing isn't activated. |
| + bool StartKernelSessionTracing(); |
| + |
| + // Request the ETW trace controller to deactivate the kernel tracing. |
| + // @param callback the callback to call with the consumed events. |
| + // returns true on success, false if an error occurred. |
| + bool StopKernelSessionTracing(); |
| + |
| + void OnStopSystemTracingDone( |
| + const OutputCallback& callback, |
| + const scoped_refptr<base::RefCountedString>& result); |
| + |
| + void TraceAndConsumeOnThread(); |
| + void FlushOnThread(const OutputCallback& callback); |
| + |
| + scoped_ptr<base::ListValue> events_; |
| + base::Thread thread_; |
| + TRACEHANDLE session_handle_; |
| + base::win::EtwTraceProperties properties_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(EtwSystemEventConsumer); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_TRACING_TRACING_CONSUMER_WIN_H_ |