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

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

Issue 1644653002: [Tracing] Update sync_id to be string type for clock sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « content/browser/tracing/tracing_controller_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "content/browser/tracing/tracing_controller_impl.h" 4 #include "content/browser/tracing/tracing_controller_impl.h"
5 5
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/cpu.h" 7 #include "base/cpu.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/guid.h"
9 #include "base/json/string_escape.h" 10 #include "base/json/string_escape.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 #include "base/sys_info.h" 13 #include "base/sys_info.h"
13 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 #include "components/tracing/process_metrics_memory_dump_provider.h" 18 #include "components/tracing/process_metrics_memory_dump_provider.h"
18 #include "content/browser/tracing/file_tracing_provider_impl.h" 19 #include "content/browser/tracing/file_tracing_provider_impl.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 151
151 TracingControllerImpl::TracingControllerImpl() 152 TracingControllerImpl::TracingControllerImpl()
152 : pending_start_tracing_ack_count_(0), 153 : pending_start_tracing_ack_count_(0),
153 pending_stop_tracing_ack_count_(0), 154 pending_stop_tracing_ack_count_(0),
154 pending_capture_monitoring_snapshot_ack_count_(0), 155 pending_capture_monitoring_snapshot_ack_count_(0),
155 pending_trace_log_status_ack_count_(0), 156 pending_trace_log_status_ack_count_(0),
156 maximum_trace_buffer_usage_(0), 157 maximum_trace_buffer_usage_(0),
157 approximate_event_count_(0), 158 approximate_event_count_(0),
158 pending_memory_dump_ack_count_(0), 159 pending_memory_dump_ack_count_(0),
159 failed_memory_dump_count_(0), 160 failed_memory_dump_count_(0),
160 clock_sync_id_(0),
161 pending_clock_sync_ack_count_(0), 161 pending_clock_sync_ack_count_(0),
162 is_tracing_(false), 162 is_tracing_(false),
163 is_monitoring_(false) { 163 is_monitoring_(false) {
164 base::trace_event::MemoryDumpManager::GetInstance()->Initialize( 164 base::trace_event::MemoryDumpManager::GetInstance()->Initialize(
165 this /* delegate */, true /* is_coordinator */); 165 this /* delegate */, true /* is_coordinator */);
166 166
167 // Deliberately leaked, like this class. 167 // Deliberately leaked, like this class.
168 base::FileTracing::SetProvider(new FileTracingProviderImpl); 168 base::FileTracing::SetProvider(new FileTracingProviderImpl);
169 } 169 }
170 170
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 else 1020 else
1021 it->SendCancelTracing(); 1021 it->SendCancelTracing();
1022 } 1022 }
1023 } 1023 }
1024 1024
1025 bool TracingControllerImpl::SupportsExplicitClockSync() { 1025 bool TracingControllerImpl::SupportsExplicitClockSync() {
1026 return true; 1026 return true;
1027 } 1027 }
1028 1028
1029 void TracingControllerImpl::RecordClockSyncMarker( 1029 void TracingControllerImpl::RecordClockSyncMarker(
1030 int sync_id, 1030 const std::string& sync_id,
1031 const RecordClockSyncMarkerCallback& callback) { 1031 const RecordClockSyncMarkerCallback& callback) {
1032 DCHECK(SupportsExplicitClockSync()); 1032 DCHECK(SupportsExplicitClockSync());
1033 1033
1034 TRACE_EVENT_CLOCK_SYNC_RECEIVER(sync_id); 1034 TRACE_EVENT_CLOCK_SYNC_RECEIVER(sync_id);
1035 } 1035 }
1036 1036
1037 int TracingControllerImpl::GetUniqueClockSyncID() {
1038 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1039 // There is no need to lock because this function only runs on UI thread.
1040 return ++clock_sync_id_;
1041 }
1042
1043 void TracingControllerImpl::IssueClockSyncMarker() { 1037 void TracingControllerImpl::IssueClockSyncMarker() {
1044 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1038 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1045 DCHECK(pending_clock_sync_ack_count_ == 0); 1039 DCHECK(pending_clock_sync_ack_count_ == 0);
1046 1040
1047 for (const auto& it : additional_tracing_agents_) { 1041 for (const auto& it : additional_tracing_agents_) {
1048 if (it->SupportsExplicitClockSync()) { 1042 if (it->SupportsExplicitClockSync()) {
1049 it->RecordClockSyncMarker( 1043 it->RecordClockSyncMarker(
1050 GetUniqueClockSyncID(), 1044 base::GenerateGUID(),
1051 base::Bind(&TracingControllerImpl::OnClockSyncMarkerRecordedByAgent, 1045 base::Bind(&TracingControllerImpl::OnClockSyncMarkerRecordedByAgent,
1052 base::Unretained(this))); 1046 base::Unretained(this)));
1053 pending_clock_sync_ack_count_++; 1047 pending_clock_sync_ack_count_++;
1054 } 1048 }
1055 } 1049 }
1056 1050
1057 // If no clock sync is needed, stop tracing right away. Otherwise, schedule 1051 // If no clock sync is needed, stop tracing right away. Otherwise, schedule
1058 // to stop tracing after timeout. 1052 // to stop tracing after timeout.
1059 if (pending_clock_sync_ack_count_ == 0) { 1053 if (pending_clock_sync_ack_count_ == 0) {
1060 StopTracingAfterClockSync(); 1054 StopTracingAfterClockSync();
1061 } else { 1055 } else {
1062 clock_sync_timer_.Start( 1056 clock_sync_timer_.Start(
1063 FROM_HERE, base::TimeDelta::FromSeconds(kIssueClockSyncTimeoutSeconds), 1057 FROM_HERE, base::TimeDelta::FromSeconds(kIssueClockSyncTimeoutSeconds),
1064 this, &TracingControllerImpl::StopTracingAfterClockSync); 1058 this, &TracingControllerImpl::StopTracingAfterClockSync);
1065 } 1059 }
1066 } 1060 }
1067 1061
1068 void TracingControllerImpl::OnClockSyncMarkerRecordedByAgent( 1062 void TracingControllerImpl::OnClockSyncMarkerRecordedByAgent(
1069 int sync_id, 1063 const std::string& sync_id,
1070 const base::TimeTicks& issue_ts, 1064 const base::TimeTicks& issue_ts,
1071 const base::TimeTicks& issue_end_ts) { 1065 const base::TimeTicks& issue_end_ts) {
1072 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1066 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1073 1067
1074 TRACE_EVENT_CLOCK_SYNC_ISSUER(sync_id, issue_ts, issue_end_ts); 1068 TRACE_EVENT_CLOCK_SYNC_ISSUER(sync_id, issue_ts, issue_end_ts);
1075 1069
1076 // Timer is not running means that clock sync already timed out. 1070 // Timer is not running means that clock sync already timed out.
1077 if (!clock_sync_timer_.IsRunning()) 1071 if (!clock_sync_timer_.IsRunning())
1078 return; 1072 return;
1079 1073
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 is_monitoring_ = is_monitoring; 1207 is_monitoring_ = is_monitoring;
1214 #if !defined(OS_ANDROID) 1208 #if !defined(OS_ANDROID)
1215 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); 1209 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin();
1216 it != tracing_uis_.end(); it++) { 1210 it != tracing_uis_.end(); it++) {
1217 (*it)->OnMonitoringStateChanged(is_monitoring); 1211 (*it)->OnMonitoringStateChanged(is_monitoring);
1218 } 1212 }
1219 #endif 1213 #endif
1220 } 1214 }
1221 1215
1222 } // namespace content 1216 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/tracing/tracing_controller_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698