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