summaryrefslogtreecommitdiff
path: root/chromium/content/browser/tracing/cast_tracing_agent.h
blob: 7b90f2abedc4bac247b1258c4ed851d0bc67188b (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
52
53
54
55
56
57
// Copyright 2017 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_CAST_TRACING_AGENT_H_
#define CONTENT_BROWSER_TRACING_CAST_TRACING_AGENT_H_

#include <memory>
#include <string>

#include "chromecast/tracing/system_tracer.h"
#include "services/tracing/public/cpp/base_agent.h"
#include "services/tracing/public/mojom/tracing.mojom.h"

namespace chromecast {
class SystemTracer;
}

namespace content {

class CastSystemTracingSession;

// TODO(crbug.com/839086): Remove once we have replaced the legacy tracing
// service with perfetto.
class CastTracingAgent : public tracing::BaseAgent {
 public:
  CastTracingAgent();
  ~CastTracingAgent() override;

 private:
  // tracing::BaseAgent implementation.
  void GetCategories(std::set<std::string>* category_set) override;

  // tracing::mojom::Agent. Called by Mojo internals on the UI thread.
  void StartTracing(const std::string& config,
                    base::TimeTicks coordinator_time,
                    Agent::StartTracingCallback callback) override;
  void StopAndFlush(tracing::mojom::RecorderPtr recorder) override;

  void StartTracingCallbackProxy(Agent::StartTracingCallback callback,
                                 bool success);
  void HandleTraceData(chromecast::SystemTracer::Status status,
                       std::string trace_data);

  tracing::mojom::RecorderPtr recorder_;

  // Task runner for collecting traces in a worker thread.
  scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;

  std::unique_ptr<CastSystemTracingSession> session_;

  DISALLOW_COPY_AND_ASSIGN(CastTracingAgent);
};

}  // namespace content

#endif  // CONTENT_BROWSER_TRACING_CAST_TRACING_AGENT_H_