OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef APPS_BENCHMARK_TRACE_COORDINATOR_CLIENT_H_ |
| 6 #define APPS_BENCHMARK_TRACE_COORDINATOR_CLIENT_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "mojo/data_pipe_utils/data_pipe_drainer.h" |
| 13 #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" |
| 14 |
| 15 // Connects to trace collector in tracing.mojo to get traces and returns the |
| 16 // results as a single string to the receiver. |
| 17 class TraceCollectorClient : public mojo::common::DataPipeDrainer::Client { |
| 18 public: |
| 19 class Receiver { |
| 20 public: |
| 21 // |trace_data| will be a JSON list of the collected trace events. |
| 22 virtual void OnTraceCollected(std::string trace_data) = 0; |
| 23 |
| 24 protected: |
| 25 virtual ~Receiver() {} |
| 26 }; |
| 27 |
| 28 TraceCollectorClient(Receiver* receiver, |
| 29 tracing::TraceCollectorPtr collector); |
| 30 ~TraceCollectorClient() override; |
| 31 |
| 32 void Start(const std::string& categories); |
| 33 void Stop(); |
| 34 |
| 35 private: |
| 36 // mojo::common:DataPipeDrainer: |
| 37 void OnDataAvailable(const void* data, size_t num_bytes) override; |
| 38 void OnDataComplete() override; |
| 39 |
| 40 Receiver* receiver_; |
| 41 tracing::TraceCollectorPtr collector_; |
| 42 scoped_ptr<mojo::common::DataPipeDrainer> drainer_; |
| 43 std::string trace_data_; |
| 44 bool currently_tracing_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(TraceCollectorClient); |
| 47 }; |
| 48 |
| 49 #endif // APPS_BENCHMARK_TRACE_COORDINATOR_CLIENT_H_ |
OLD | NEW |