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

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

Issue 1682113003: Mojo C++ bindings: Generate InterfaceHandle<> instead of InterfacePtr<>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase ontop of master, address trung's comments Created 4 years, 10 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_provider_impl.h ('k') | mojo/gles2/command_buffer_client_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_provider_impl.h" 5 #include "mojo/common/trace_provider_impl.h"
6 6
7 #include <utility>
8
7 #include "base/callback.h" 9 #include "base/callback.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
10 #include "base/time/time.h" 12 #include "base/time/time.h"
11 #include "base/trace_event/trace_config.h" 13 #include "base/trace_event/trace_config.h"
12 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
13 #include "mojo/public/cpp/application/application_connection.h" 15 #include "mojo/public/cpp/application/application_connection.h"
14 #include "mojo/public/cpp/application/application_impl.h" 16 #include "mojo/public/cpp/application/application_impl.h"
15 17
16 namespace mojo { 18 namespace mojo {
17 19
18 TraceProviderImpl::TraceProviderImpl() 20 TraceProviderImpl::TraceProviderImpl()
19 : binding_(this), tracing_forced_(false), weak_factory_(this) {} 21 : binding_(this), tracing_forced_(false), weak_factory_(this) {}
20 22
21 TraceProviderImpl::~TraceProviderImpl() {} 23 TraceProviderImpl::~TraceProviderImpl() {}
22 24
23 void TraceProviderImpl::Bind(InterfaceRequest<tracing::TraceProvider> request) { 25 void TraceProviderImpl::Bind(InterfaceRequest<tracing::TraceProvider> request) {
24 if (!binding_.is_bound()) { 26 if (!binding_.is_bound()) {
25 binding_.Bind(request.Pass()); 27 binding_.Bind(request.Pass());
26 } else { 28 } else {
27 LOG(ERROR) << "Cannot accept two connections to TraceProvider."; 29 LOG(ERROR) << "Cannot accept two connections to TraceProvider.";
28 } 30 }
29 } 31 }
30 32
31 void TraceProviderImpl::StartTracing(const String& categories, 33 void TraceProviderImpl::StartTracing(
32 tracing::TraceRecorderPtr recorder) { 34 const String& categories,
35 mojo::InterfaceHandle<tracing::TraceRecorder> recorder) {
33 DCHECK(!recorder_.get()); 36 DCHECK(!recorder_.get());
34 recorder_ = recorder.Pass(); 37 recorder_ = tracing::TraceRecorderPtr::Create(std::move(recorder));
35 tracing_forced_ = false; 38 tracing_forced_ = false;
36 if (!base::trace_event::TraceLog::GetInstance()->IsEnabled()) { 39 if (!base::trace_event::TraceLog::GetInstance()->IsEnabled()) {
37 std::string categories_str = categories.To<std::string>(); 40 std::string categories_str = categories.To<std::string>();
38 base::trace_event::TraceLog::GetInstance()->SetEnabled( 41 base::trace_event::TraceLog::GetInstance()->SetEnabled(
39 base::trace_event::TraceConfig(categories_str, 42 base::trace_event::TraceConfig(categories_str,
40 base::trace_event::RECORD_UNTIL_FULL), 43 base::trace_event::RECORD_UNTIL_FULL),
41 base::trace_event::TraceLog::RECORDING_MODE); 44 base::trace_event::TraceLog::RECORDING_MODE);
42 } 45 }
43 } 46 }
44 47
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // events. Empty string is not a valid chunk to record so skip in this case. 92 // events. Empty string is not a valid chunk to record so skip in this case.
90 if (!events_str->data().empty()) { 93 if (!events_str->data().empty()) {
91 recorder_->Record(mojo::String(events_str->data())); 94 recorder_->Record(mojo::String(events_str->data()));
92 } 95 }
93 if (!has_more_events) { 96 if (!has_more_events) {
94 recorder_.reset(); 97 recorder_.reset();
95 } 98 }
96 } 99 }
97 100
98 } // namespace mojo 101 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/common/trace_provider_impl.h ('k') | mojo/gles2/command_buffer_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698