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

Side by Side Diff: content/browser/tracing/power_tracing_agent.cc

Issue 1614063005: Adds a callback to TracingAgent::StartAgentTracing() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
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 "base/lazy_instance.h" 5 #include "base/lazy_instance.h"
6 #include "base/memory/singleton.h" 6 #include "base/memory/singleton.h"
7 #include "base/thread_task_runner_handle.h"
7 #include "base/trace_event/trace_event_impl.h" 8 #include "base/trace_event/trace_event_impl.h"
8 #include "content/browser/tracing/battor_power_trace_provider.h" 9 #include "content/browser/tracing/battor_power_trace_provider.h"
9 #include "content/browser/tracing/power_tracing_agent.h" 10 #include "content/browser/tracing/power_tracing_agent.h"
10 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
11 12
12 namespace content { 13 namespace content {
13 14
14 namespace { 15 namespace {
15 16
16 const char kPowerTracingAgentName[] = "battor"; 17 const char kPowerTracingAgentName[] = "battor";
(...skipping 13 matching lines...) Expand all
30 PowerTracingAgent::~PowerTracingAgent() {} 31 PowerTracingAgent::~PowerTracingAgent() {}
31 32
32 std::string PowerTracingAgent::GetTracingAgentName() { 33 std::string PowerTracingAgent::GetTracingAgentName() {
33 return kPowerTracingAgentName; 34 return kPowerTracingAgentName;
34 } 35 }
35 36
36 std::string PowerTracingAgent::GetTraceEventLabel() { 37 std::string PowerTracingAgent::GetTraceEventLabel() {
37 return kPowerTraceLabel; 38 return kPowerTraceLabel;
38 } 39 }
39 40
40 bool PowerTracingAgent::StartAgentTracing( 41 void PowerTracingAgent::StartAgentTracing(
41 const base::trace_event::TraceConfig& trace_config) { 42 const base::trace_event::TraceConfig& trace_config,
43 const StartAgentTracingCallback& callback) {
42 DCHECK_CURRENTLY_ON(BrowserThread::UI); 44 DCHECK_CURRENTLY_ON(BrowserThread::UI);
43 45
44 // TODO(charliea): When system tracing is enabled in about://tracing, it will 46 // TODO(charliea): When system tracing is enabled in about://tracing, it will
45 // trigger power tracing. We need a way of checking if BattOr is connected. 47 // trigger power tracing. We need a way of checking if BattOr is connected.
46 // Currently, IsConnected() always returns false, so that we do not include 48 // Currently, IsConnected() always returns false, so that we do not include
47 // BattOr trace until it is hooked up. 49 // BattOr trace until it is hooked up.
48 if (!battor_trace_provider_->IsConnected()) 50 if (!battor_trace_provider_->IsConnected()) {
Zhen Wang 2016/01/25 20:35:32 This is still a sync call here. Will this be updat
charliea (OOO until 10-5) 2016/01/25 21:15:24 All interaction with the serial classes needs to b
49 return false; 51 base::ThreadTaskRunnerHandle::Get()->PostTask(
50 52 FROM_HERE, base::Bind(callback, GetTracingAgentName(), false));
53 return;
54 }
51 thread_.Start(); 55 thread_.Start();
52 56
53 thread_.task_runner()->PostTask( 57 thread_.task_runner()->PostTask(
54 FROM_HERE, 58 FROM_HERE,
55 base::Bind(&PowerTracingAgent::TraceOnThread, base::Unretained(this))); 59 base::Bind(&PowerTracingAgent::TraceOnThread, base::Unretained(this)));
56 return true; 60 base::ThreadTaskRunnerHandle::Get()->PostTask(
61 FROM_HERE, base::Bind(callback, GetTracingAgentName(), true));
57 } 62 }
58 63
59 void PowerTracingAgent::StopAgentTracing( 64 void PowerTracingAgent::StopAgentTracing(
60 const StopAgentTracingCallback& callback) { 65 const StopAgentTracingCallback& callback) {
61 DCHECK_CURRENTLY_ON(BrowserThread::UI); 66 DCHECK_CURRENTLY_ON(BrowserThread::UI);
62 DCHECK(thread_.IsRunning()); 67 DCHECK(thread_.IsRunning());
63 68
64 thread_.task_runner()->PostTask( 69 thread_.task_runner()->PostTask(
65 FROM_HERE, 70 FROM_HERE,
66 base::Bind(&PowerTracingAgent::FlushOnThread, base::Unretained(this), 71 base::Bind(&PowerTracingAgent::FlushOnThread, base::Unretained(this),
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 base::TimeTicks issue_ts = base::TimeTicks::Now(); 135 base::TimeTicks issue_ts = base::TimeTicks::Now();
131 battor_trace_provider_->RecordClockSyncMarker(sync_id); 136 battor_trace_provider_->RecordClockSyncMarker(sync_id);
132 base::TimeTicks issue_end_ts = base::TimeTicks::Now(); 137 base::TimeTicks issue_end_ts = base::TimeTicks::Now();
133 138
134 BrowserThread::PostTask( 139 BrowserThread::PostTask(
135 BrowserThread::UI, FROM_HERE, 140 BrowserThread::UI, FROM_HERE,
136 base::Bind(callback, sync_id, issue_ts, issue_end_ts)); 141 base::Bind(callback, sync_id, issue_ts, issue_end_ts));
137 } 142 }
138 143
139 } // namespace content 144 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698