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

Side by Side Diff: apps/benchmark/trace_collector_client.cc

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, 3 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 unified diff | Download patch
« no previous file with comments | « apps/benchmark/trace_collector_client.h ('k') | mojo/devtools/common/mojo_benchmark » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "apps/benchmark/trace_collector_client.h"
6
7 TraceCollectorClient::TraceCollectorClient(Receiver* receiver,
8 tracing::TraceCollectorPtr collector)
9 : receiver_(receiver),
10 collector_(collector.Pass()),
11 currently_tracing_(false) {}
12
13 TraceCollectorClient::~TraceCollectorClient() {}
14
15 void TraceCollectorClient::Start(const std::string& categories) {
16 DCHECK(!currently_tracing_);
17 currently_tracing_ = true;
18 mojo::DataPipe data_pipe;
19 collector_->Start(data_pipe.producer_handle.Pass(), categories);
20 drainer_.reset(new mojo::common::DataPipeDrainer(
21 this, data_pipe.consumer_handle.Pass()));
22 trace_data_.clear();
23 trace_data_ += "[";
24 }
25
26 void TraceCollectorClient::Stop() {
27 DCHECK(currently_tracing_);
28 currently_tracing_ = false;
29 collector_->StopAndFlush();
30 }
31
32 void TraceCollectorClient::OnDataAvailable(const void* data, size_t num_bytes) {
33 const char* chars = static_cast<const char*>(data);
34 trace_data_.append(chars, num_bytes);
35 }
36
37 void TraceCollectorClient::OnDataComplete() {
38 drainer_.reset();
39 collector_.reset();
40 trace_data_ += "]";
41 receiver_->OnTraceCollected(trace_data_);
42 }
OLDNEW
« no previous file with comments | « apps/benchmark/trace_collector_client.h ('k') | mojo/devtools/common/mojo_benchmark » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698