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

Side by Side Diff: sky/tools/debugger/trace_collector.cc

Issue 1151573010: Pull Sky debugger up to services/debugger. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 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 | « sky/tools/debugger/trace_collector.h ('k') | sky/tools/skydb » ('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 2014 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 "sky/tools/debugger/trace_collector.h"
6
7 namespace sky {
8 namespace debugger {
9
10 TraceCollector::TraceCollector(mojo::ScopedDataPipeConsumerHandle source)
11 : drainer_(this, source.Pass()), is_complete_(false) {
12 }
13
14 TraceCollector::~TraceCollector() {
15 }
16
17 void TraceCollector::GetTrace(TraceCallback callback) {
18 DCHECK(callback_.is_null());
19 DCHECK(!callback.is_null());
20 if (is_complete_) {
21 callback.Run(GetTraceAsString());
22 return;
23 }
24 callback_ = callback;
25 }
26
27 void TraceCollector::OnDataAvailable(const void* data, size_t num_bytes) {
28 DCHECK(!is_complete_);
29 const char* chars = static_cast<const char*>(data);
30 trace_.insert(trace_.end(), chars, chars + num_bytes);
31 }
32
33 void TraceCollector::OnDataComplete() {
34 DCHECK(!is_complete_);
35 is_complete_ = true;
36 if (!callback_.is_null())
37 callback_.Run(GetTraceAsString());
38 }
39
40 std::string TraceCollector::GetTraceAsString() {
41 return std::string(&trace_.front(), trace_.size());
42 }
43
44 } // namespace debugger
45 } // namespace sky
OLDNEW
« no previous file with comments | « sky/tools/debugger/trace_collector.h ('k') | sky/tools/skydb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698