summaryrefslogtreecommitdiffstats
path: root/content/browser/tracing/power_tracing_agent.h
blob: f29918ccabf669fc044c1c7a4e41654f6e511b49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2015 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_POWER_TRACING_AGENT_H_
#define CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_

#include "base/memory/ref_counted_memory.h"
#include "base/threading/thread.h"

template <typename Type>
struct DefaultSingletonTraits;

namespace content {

class BattorPowerTraceProvider;

class PowerTracingAgent {
 public:
  typedef base::Callback<void(const scoped_refptr<base::RefCountedString>&)>
      OutputCallback;

  bool StartTracing();
  void StopTracing(const OutputCallback& callback);

  // Retrieve the singleton instance.
  static PowerTracingAgent* GetInstance();

 private:
  // This allows constructor and destructor to be private and usable only
  // by the Singleton class.
  friend struct DefaultSingletonTraits<PowerTracingAgent>;

  // Constructor.
  PowerTracingAgent();
  virtual ~PowerTracingAgent();

  void OnStopTracingDone(const OutputCallback& callback,
                         const scoped_refptr<base::RefCountedString>& result);

  void FlushOnThread(const OutputCallback& callback);

  scoped_ptr<BattorPowerTraceProvider> battor_trace_provider_;
  bool is_tracing_;

  DISALLOW_COPY_AND_ASSIGN(PowerTracingAgent);
};

}  // namespace content

#endif  // CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_