Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: apps/benchmark/trace_collector_client.h

Issue 1305193002: Trace-based benchmarking via a mojo app. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Further address Etienne's comments. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « apps/benchmark/run_args.cc ('k') | apps/benchmark/trace_collector_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/benchmark/trace_collector_client.h
diff --git a/apps/benchmark/trace_collector_client.h b/apps/benchmark/trace_collector_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..3e5ba3718f5364847766a4f8bdcf8c30a01d4b10
--- /dev/null
+++ b/apps/benchmark/trace_collector_client.h
@@ -0,0 +1,49 @@
+// 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 APPS_BENCHMARK_TRACE_COORDINATOR_CLIENT_H_
+#define APPS_BENCHMARK_TRACE_COORDINATOR_CLIENT_H_
+
+#include <memory>
+#include <string>
+
+#include "base/memory/scoped_ptr.h"
+#include "mojo/data_pipe_utils/data_pipe_drainer.h"
+#include "mojo/services/tracing/public/interfaces/tracing.mojom.h"
+
+// Connects to trace collector in tracing.mojo to get traces and returns the
+// results as a single string to the receiver.
+class TraceCollectorClient : public mojo::common::DataPipeDrainer::Client {
+ public:
+ class Receiver {
+ public:
+ // |trace_data| will be a JSON list of the collected trace events.
+ virtual void OnTraceCollected(std::string trace_data) = 0;
+
+ protected:
+ virtual ~Receiver() {}
+ };
+
+ TraceCollectorClient(Receiver* receiver,
+ tracing::TraceCollectorPtr collector);
+ ~TraceCollectorClient() override;
+
+ void Start(const std::string& categories);
+ void Stop();
+
+ private:
+ // mojo::common:DataPipeDrainer:
+ void OnDataAvailable(const void* data, size_t num_bytes) override;
+ void OnDataComplete() override;
+
+ Receiver* receiver_;
+ tracing::TraceCollectorPtr collector_;
+ scoped_ptr<mojo::common::DataPipeDrainer> drainer_;
+ std::string trace_data_;
+ bool currently_tracing_;
+
+ DISALLOW_COPY_AND_ASSIGN(TraceCollectorClient);
+};
+
+#endif // APPS_BENCHMARK_TRACE_COORDINATOR_CLIENT_H_
« no previous file with comments | « apps/benchmark/run_args.cc ('k') | apps/benchmark/trace_collector_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698