OLD | NEW |
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/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "mojo/public/cpp/application/application_connection.h" | 8 #include "mojo/public/cpp/application/application_connection.h" |
9 #include "mojo/public/cpp/application/application_impl.h" | 9 #include "mojo/public/cpp/application/application_impl.h" |
10 | 10 |
11 namespace mojo { | 11 namespace mojo { |
12 | 12 |
13 TraceControllerImpl::TraceControllerImpl( | 13 TraceControllerImpl::TraceControllerImpl( |
14 InterfaceRequest<tracing::TraceController> request) | 14 InterfaceRequest<tracing::TraceController> request) |
15 : binding_(this, request.Pass()) { | 15 : binding_(this, request.Pass()) { |
16 } | 16 } |
17 | 17 |
18 TraceControllerImpl::~TraceControllerImpl() { | 18 TraceControllerImpl::~TraceControllerImpl() { |
19 } | 19 } |
20 | 20 |
21 void TraceControllerImpl::StartTracing( | 21 void TraceControllerImpl::StartTracing( |
22 const String& categories, | 22 const String& categories, |
23 tracing::TraceDataCollectorPtr collector) { | 23 tracing::TraceDataCollectorPtr collector) { |
24 DCHECK(!collector_.get()); | 24 DCHECK(!collector_.get()); |
25 collector_ = collector.Pass(); | 25 collector_ = collector.Pass(); |
26 std::string categories_str = categories.To<std::string>(); | 26 std::string categories_str = categories.To<std::string>(); |
27 base::debug::TraceLog::GetInstance()->SetEnabled( | 27 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
28 base::debug::CategoryFilter(categories_str), | 28 base::trace_event::CategoryFilter(categories_str), |
29 base::debug::TraceLog::RECORDING_MODE, | 29 base::trace_event::TraceLog::RECORDING_MODE, |
30 base::debug::TraceOptions(base::debug::RECORD_UNTIL_FULL)); | 30 base::trace_event::TraceOptions(base::trace_event::RECORD_UNTIL_FULL)); |
31 } | 31 } |
32 | 32 |
33 void TraceControllerImpl::StopTracing() { | 33 void TraceControllerImpl::StopTracing() { |
34 base::debug::TraceLog::GetInstance()->SetDisabled(); | 34 base::trace_event::TraceLog::GetInstance()->SetDisabled(); |
35 | 35 |
36 base::debug::TraceLog::GetInstance()->Flush( | 36 base::trace_event::TraceLog::GetInstance()->Flush( |
37 base::Bind(&TraceControllerImpl::SendChunk, base::Unretained(this))); | 37 base::Bind(&TraceControllerImpl::SendChunk, base::Unretained(this))); |
38 } | 38 } |
39 | 39 |
40 void TraceControllerImpl::SendChunk( | 40 void TraceControllerImpl::SendChunk( |
41 const scoped_refptr<base::RefCountedString>& events_str, | 41 const scoped_refptr<base::RefCountedString>& events_str, |
42 bool has_more_events) { | 42 bool has_more_events) { |
43 collector_->DataCollected(mojo::String(events_str->data())); | 43 collector_->DataCollected(mojo::String(events_str->data())); |
44 if (!has_more_events) { | 44 if (!has_more_events) { |
45 collector_.reset(); | 45 collector_.reset(); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 } // namespace mojo | 49 } // namespace mojo |
OLD | NEW |