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 "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/thread_task_runner_handle.h" |
8 #include "base/trace_event/trace_event_impl.h" | 8 #include "base/trace_event/trace_event_impl.h" |
9 #include "content/browser/tracing/battor_power_trace_provider.h" | 9 #include "content/browser/tracing/battor_power_trace_provider.h" |
10 #include "content/browser/tracing/power_tracing_agent.h" | 10 #include "content/browser/tracing/power_tracing_agent.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 base::Unretained(this), | 108 base::Unretained(this), |
109 callback, | 109 callback, |
110 result)); | 110 result)); |
111 } | 111 } |
112 | 112 |
113 bool PowerTracingAgent::SupportsExplicitClockSync() { | 113 bool PowerTracingAgent::SupportsExplicitClockSync() { |
114 return true; | 114 return true; |
115 } | 115 } |
116 | 116 |
117 void PowerTracingAgent::RecordClockSyncMarker( | 117 void PowerTracingAgent::RecordClockSyncMarker( |
118 int sync_id, | 118 const std::string& sync_id, |
119 const RecordClockSyncMarkerCallback& callback) { | 119 const RecordClockSyncMarkerCallback& callback) { |
120 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 120 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
121 DCHECK(SupportsExplicitClockSync()); | 121 DCHECK(SupportsExplicitClockSync()); |
122 | 122 |
123 thread_.task_runner()->PostTask( | 123 thread_.task_runner()->PostTask( |
124 FROM_HERE, | 124 FROM_HERE, |
125 base::Bind(&PowerTracingAgent::RecordClockSyncMarkerOnThread, | 125 base::Bind(&PowerTracingAgent::RecordClockSyncMarkerOnThread, |
126 base::Unretained(this), | 126 base::Unretained(this), |
127 sync_id, | 127 sync_id, |
128 callback)); | 128 callback)); |
129 } | 129 } |
130 | 130 |
131 void PowerTracingAgent::RecordClockSyncMarkerOnThread( | 131 void PowerTracingAgent::RecordClockSyncMarkerOnThread( |
132 int sync_id, | 132 const std::string& sync_id, |
133 const RecordClockSyncMarkerCallback& callback) { | 133 const RecordClockSyncMarkerCallback& callback) { |
134 DCHECK(thread_.task_runner()->BelongsToCurrentThread()); | 134 DCHECK(thread_.task_runner()->BelongsToCurrentThread()); |
135 DCHECK(SupportsExplicitClockSync()); | 135 DCHECK(SupportsExplicitClockSync()); |
136 | 136 |
137 base::TimeTicks issue_ts = base::TimeTicks::Now(); | 137 base::TimeTicks issue_ts = base::TimeTicks::Now(); |
138 battor_trace_provider_->RecordClockSyncMarker(sync_id); | 138 battor_trace_provider_->RecordClockSyncMarker(sync_id); |
139 base::TimeTicks issue_end_ts = base::TimeTicks::Now(); | 139 base::TimeTicks issue_end_ts = base::TimeTicks::Now(); |
140 | 140 |
141 BrowserThread::PostTask( | 141 BrowserThread::PostTask( |
142 BrowserThread::UI, FROM_HERE, | 142 BrowserThread::UI, FROM_HERE, |
143 base::Bind(callback, sync_id, issue_ts, issue_end_ts)); | 143 base::Bind(callback, sync_id, issue_ts, issue_end_ts)); |
144 } | 144 } |
145 | 145 |
146 } // namespace content | 146 } // namespace content |
OLD | NEW |