| 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 std::string GetTracingAgentName() override; |
| 27 bool StartAgentTracing( |
| 28 const base::trace_event::TraceConfig& trace_config) override; |
| 29 void StopAgentTracing(const StopAgentTracingCallback& callback) override; |
| 30 |
| 31 bool SupportsExplicitClockSync() override; |
| 32 void RecordClockSyncMarker(scoped_ptr<base::DictionaryValue> marker) override; |
| 33 void IssueClockSyncMarker() override; |
| 34 |
| 31 private: | 35 private: |
| 32 // This allows constructor and destructor to be private and usable only | 36 // This allows constructor and destructor to be private and usable only |
| 33 // by the Singleton class. | 37 // by the Singleton class. |
| 34 friend struct base::DefaultSingletonTraits<PowerTracingAgent>; | 38 friend struct base::DefaultSingletonTraits<PowerTracingAgent>; |
| 35 | 39 |
| 36 // Constructor. | 40 // Constructor. |
| 37 PowerTracingAgent(); | 41 PowerTracingAgent(); |
| 38 virtual ~PowerTracingAgent(); | 42 ~PowerTracingAgent() override; |
| 39 | 43 |
| 40 void OnStopTracingDone(const OutputCallback& callback, | 44 void OnStopTracingDone(const StopAgentTracingCallback& callback, |
| 41 const scoped_refptr<base::RefCountedString>& result); | 45 const scoped_refptr<base::RefCountedString>& result); |
| 42 | 46 |
| 43 void FlushOnThread(const OutputCallback& callback); | 47 void FlushOnThread(const StopAgentTracingCallback& callback); |
| 44 | 48 |
| 45 scoped_ptr<BattorPowerTraceProvider> battor_trace_provider_; | 49 scoped_ptr<BattorPowerTraceProvider> battor_trace_provider_; |
| 46 bool is_tracing_; | 50 bool is_tracing_; |
| 47 | 51 |
| 48 DISALLOW_COPY_AND_ASSIGN(PowerTracingAgent); | 52 DISALLOW_COPY_AND_ASSIGN(PowerTracingAgent); |
| 49 }; | 53 }; |
| 50 | 54 |
| 51 } // namespace content | 55 } // namespace content |
| 52 | 56 |
| 53 #endif // CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_ | 57 #endif // CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_ |
| OLD | NEW |