OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_POWER_TRACING_AGENT_H_ | 5 #ifndef CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_ |
6 #define CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_ | 6 #define CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_ |
7 | 7 |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "base/trace_event/tracing_agent.h" |
10 | 11 |
11 namespace base { | 12 namespace base { |
12 template <typename Type> | 13 template <typename Type> |
13 struct DefaultSingletonTraits; | 14 struct DefaultSingletonTraits; |
14 } // namespace base | 15 } // namespace base |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 class BattorPowerTraceProvider; | 19 class BattorPowerTraceProvider; |
19 | 20 |
20 class PowerTracingAgent { | 21 class PowerTracingAgent : public base::trace_event::TracingAgent { |
21 public: | 22 public: |
22 typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&)> | |
23 OutputCallback; | |
24 | |
25 bool StartTracing(); | |
26 void StopTracing(const OutputCallback& callback); | |
27 | |
28 // Retrieve the singleton instance. | 23 // Retrieve the singleton instance. |
29 static PowerTracingAgent* GetInstance(); | 24 static PowerTracingAgent* GetInstance(); |
30 | 25 |
| 26 // base::trace_event::TracingAgent implementation. |
| 27 std::string GetTracingAgentName() override; |
| 28 std::string GetTraceEventLabel() override; |
| 29 |
| 30 bool StartAgentTracing( |
| 31 const base::trace_event::TraceConfig& trace_config) override; |
| 32 void StopAgentTracing(const StopAgentTracingCallback& callback) override; |
| 33 |
| 34 bool SupportsExplicitClockSync() override; |
| 35 void RecordClockSyncMarker( |
| 36 int sync_id, |
| 37 const RecordClockSyncMarkerCallback& callback) override; |
| 38 |
31 private: | 39 private: |
32 // This allows constructor and destructor to be private and usable only | 40 // This allows constructor and destructor to be private and usable only |
33 // by the Singleton class. | 41 // by the Singleton class. |
34 friend struct base::DefaultSingletonTraits<PowerTracingAgent>; | 42 friend struct base::DefaultSingletonTraits<PowerTracingAgent>; |
35 | 43 |
36 // Constructor. | 44 // Constructor. |
37 PowerTracingAgent(); | 45 PowerTracingAgent(); |
38 virtual ~PowerTracingAgent(); | 46 ~PowerTracingAgent() override; |
39 | 47 |
40 void OnStopTracingDone(const OutputCallback& callback, | 48 void OnStopTracingDone(const StopAgentTracingCallback& callback, |
41 const scoped_refptr<base::RefCountedString>& result); | 49 const scoped_refptr<base::RefCountedString>& result); |
42 | 50 |
43 void FlushOnThread(const OutputCallback& callback); | 51 void FlushOnThread(const StopAgentTracingCallback& callback); |
44 | 52 |
45 scoped_ptr<BattorPowerTraceProvider> battor_trace_provider_; | 53 scoped_ptr<BattorPowerTraceProvider> battor_trace_provider_; |
46 bool is_tracing_; | 54 bool is_tracing_; |
47 | 55 |
48 DISALLOW_COPY_AND_ASSIGN(PowerTracingAgent); | 56 DISALLOW_COPY_AND_ASSIGN(PowerTracingAgent); |
49 }; | 57 }; |
50 | 58 |
51 } // namespace content | 59 } // namespace content |
52 | 60 |
53 #endif // CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_ | 61 #endif // CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_ |
OLD | NEW |