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

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: 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
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..b5e9f8cb3a3e84bbb9936e226333ff0198bf287b
--- /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/common/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_

Powered by Google App Engine
This is Rietveld 408576698