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

Side by Side Diff: mojo/common/trace_controller_impl.cc

Issue 1105773002: Teach the mojo_shell --trace-startup flag to gather data from services (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: buffer data from tracing service to avoid needing to frame it or add extra commas Created 5 years, 7 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 | « mojo/common/trace_controller_impl.h ('k') | mojo/common/tracing_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/common/trace_controller_impl.h" 5 #include "mojo/common/trace_controller_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "mojo/public/cpp/application/application_connection.h" 9 #include "mojo/public/cpp/application/application_connection.h"
10 #include "mojo/public/cpp/application/application_impl.h" 10 #include "mojo/public/cpp/application/application_impl.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 13
14 TraceControllerImpl::TraceControllerImpl( 14 TraceControllerImpl::TraceControllerImpl(
15 InterfaceRequest<tracing::TraceController> request) 15 InterfaceRequest<tracing::TraceController> request)
16 : binding_(this, request.Pass()) { 16 : tracing_already_started_(false), binding_(this, request.Pass()) {
etiennej 2015/09/11 09:43:15 I am currently looking at this code. Was there a r
17 } 17 }
18 18
19 TraceControllerImpl::~TraceControllerImpl() { 19 TraceControllerImpl::~TraceControllerImpl() {
20 } 20 }
21 21
22 void TraceControllerImpl::StartTracing( 22 void TraceControllerImpl::StartTracing(
23 const String& categories, 23 const String& categories,
24 tracing::TraceDataCollectorPtr collector) { 24 tracing::TraceDataCollectorPtr collector) {
25 DCHECK(!collector_.get()); 25 DCHECK(!collector_.get());
26 collector_ = collector.Pass(); 26 collector_ = collector.Pass();
27 std::string categories_str = categories.To<std::string>(); 27 if (!tracing_already_started_) {
28 base::trace_event::TraceLog::GetInstance()->SetEnabled( 28 std::string categories_str = categories.To<std::string>();
29 base::trace_event::CategoryFilter(categories_str), 29 base::trace_event::TraceLog::GetInstance()->SetEnabled(
30 base::trace_event::TraceLog::RECORDING_MODE, 30 base::trace_event::CategoryFilter(categories_str),
31 base::trace_event::TraceOptions(base::trace_event::RECORD_UNTIL_FULL)); 31 base::trace_event::TraceLog::RECORDING_MODE,
32 base::trace_event::TraceOptions(base::trace_event::RECORD_UNTIL_FULL));
33 }
32 } 34 }
33 35
34 void TraceControllerImpl::StopTracing() { 36 void TraceControllerImpl::StopTracing() {
35 DCHECK(collector_); 37 DCHECK(collector_);
36 base::trace_event::TraceLog::GetInstance()->SetDisabled(); 38 base::trace_event::TraceLog::GetInstance()->SetDisabled();
37 39
38 base::trace_event::TraceLog::GetInstance()->Flush( 40 base::trace_event::TraceLog::GetInstance()->Flush(
39 base::Bind(&TraceControllerImpl::SendChunk, base::Unretained(this))); 41 base::Bind(&TraceControllerImpl::SendChunk, base::Unretained(this)));
40 } 42 }
41 43
42 void TraceControllerImpl::SendChunk( 44 void TraceControllerImpl::SendChunk(
43 const scoped_refptr<base::RefCountedString>& events_str, 45 const scoped_refptr<base::RefCountedString>& events_str,
44 bool has_more_events) { 46 bool has_more_events) {
45 DCHECK(collector_); 47 DCHECK(collector_);
46 collector_->DataCollected(mojo::String(events_str->data())); 48 collector_->DataCollected(mojo::String(events_str->data()));
47 if (!has_more_events) { 49 if (!has_more_events) {
48 collector_.reset(); 50 collector_.reset();
49 } 51 }
50 } 52 }
51 53
52 } // namespace mojo 54 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/common/trace_controller_impl.h ('k') | mojo/common/tracing_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698