OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/trace_event/trace_event_impl.h" | 5 #include "base/trace_event/trace_event_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 : mode_(DISABLED), | 1147 : mode_(DISABLED), |
1148 num_traces_recorded_(0), | 1148 num_traces_recorded_(0), |
1149 event_callback_(0), | 1149 event_callback_(0), |
1150 dispatching_to_observer_list_(false), | 1150 dispatching_to_observer_list_(false), |
1151 process_sort_index_(0), | 1151 process_sort_index_(0), |
1152 process_id_hash_(0), | 1152 process_id_hash_(0), |
1153 process_id_(0), | 1153 process_id_(0), |
1154 watch_category_(0), | 1154 watch_category_(0), |
1155 trace_options_(kInternalRecordUntilFull), | 1155 trace_options_(kInternalRecordUntilFull), |
1156 sampling_thread_handle_(0), | 1156 sampling_thread_handle_(0), |
1157 category_filter_(CategoryFilter::kDefaultCategoryFilterString), | 1157 trace_config_(TraceConfig()), |
1158 event_callback_category_filter_( | 1158 event_callback_trace_config_(TraceConfig()), |
1159 CategoryFilter::kDefaultCategoryFilterString), | |
1160 thread_shared_chunk_index_(0), | 1159 thread_shared_chunk_index_(0), |
1161 generation_(0), | 1160 generation_(0), |
1162 use_worker_thread_(false) { | 1161 use_worker_thread_(false) { |
1163 // Trace is enabled or disabled on one thread while other threads are | 1162 // Trace is enabled or disabled on one thread while other threads are |
1164 // accessing the enabled flag. We don't care whether edge-case events are | 1163 // accessing the enabled flag. We don't care whether edge-case events are |
1165 // traced or not, so we allow races on the enabled flag to keep the trace | 1164 // traced or not, so we allow races on the enabled flag to keep the trace |
1166 // macros fast. | 1165 // macros fast. |
1167 // TODO(jbates): ANNOTATE_BENIGN_RACE_SIZED crashes windows TSAN bots: | 1166 // TODO(jbates): ANNOTATE_BENIGN_RACE_SIZED crashes windows TSAN bots: |
1168 // ANNOTATE_BENIGN_RACE_SIZED(g_category_group_enabled, | 1167 // ANNOTATE_BENIGN_RACE_SIZED(g_category_group_enabled, |
1169 // sizeof(g_category_group_enabled), | 1168 // sizeof(g_category_group_enabled), |
(...skipping 14 matching lines...) Expand all Loading... |
1184 switches::kTraceToConsole); | 1183 switches::kTraceToConsole); |
1185 if (filter.empty()) { | 1184 if (filter.empty()) { |
1186 filter = kEchoToConsoleCategoryFilter; | 1185 filter = kEchoToConsoleCategoryFilter; |
1187 } else { | 1186 } else { |
1188 filter.append(","); | 1187 filter.append(","); |
1189 filter.append(kEchoToConsoleCategoryFilter); | 1188 filter.append(kEchoToConsoleCategoryFilter); |
1190 } | 1189 } |
1191 | 1190 |
1192 LOG(ERROR) << "Start " << switches::kTraceToConsole | 1191 LOG(ERROR) << "Start " << switches::kTraceToConsole |
1193 << " with CategoryFilter '" << filter << "'."; | 1192 << " with CategoryFilter '" << filter << "'."; |
1194 SetEnabled(CategoryFilter(filter), | 1193 SetEnabled(TraceConfig(filter, ECHO_TO_CONSOLE), RECORDING_MODE); |
1195 RECORDING_MODE, | |
1196 TraceOptions(ECHO_TO_CONSOLE)); | |
1197 } | 1194 } |
1198 #endif | 1195 #endif |
1199 | 1196 |
1200 logged_events_.reset(CreateTraceBuffer()); | 1197 logged_events_.reset(CreateTraceBuffer()); |
1201 } | 1198 } |
1202 | 1199 |
1203 TraceLog::~TraceLog() { | 1200 TraceLog::~TraceLog() { |
1204 } | 1201 } |
1205 | 1202 |
1206 const unsigned char* TraceLog::GetCategoryGroupEnabled( | 1203 const unsigned char* TraceLog::GetCategoryGroupEnabled( |
(...skipping 19 matching lines...) Expand all Loading... |
1226 "out of bounds category pointer"; | 1223 "out of bounds category pointer"; |
1227 uintptr_t category_index = | 1224 uintptr_t category_index = |
1228 (category_ptr - category_begin) / sizeof(g_category_group_enabled[0]); | 1225 (category_ptr - category_begin) / sizeof(g_category_group_enabled[0]); |
1229 return g_category_groups[category_index]; | 1226 return g_category_groups[category_index]; |
1230 } | 1227 } |
1231 | 1228 |
1232 void TraceLog::UpdateCategoryGroupEnabledFlag(size_t category_index) { | 1229 void TraceLog::UpdateCategoryGroupEnabledFlag(size_t category_index) { |
1233 unsigned char enabled_flag = 0; | 1230 unsigned char enabled_flag = 0; |
1234 const char* category_group = g_category_groups[category_index]; | 1231 const char* category_group = g_category_groups[category_index]; |
1235 if (mode_ == RECORDING_MODE && | 1232 if (mode_ == RECORDING_MODE && |
1236 category_filter_.IsCategoryGroupEnabled(category_group)) | 1233 trace_config_.IsCategoryGroupEnabled(category_group)) |
1237 enabled_flag |= ENABLED_FOR_RECORDING; | 1234 enabled_flag |= ENABLED_FOR_RECORDING; |
1238 else if (mode_ == MONITORING_MODE && | 1235 else if (mode_ == MONITORING_MODE && |
1239 category_filter_.IsCategoryGroupEnabled(category_group)) | 1236 trace_config_.IsCategoryGroupEnabled(category_group)) |
1240 enabled_flag |= ENABLED_FOR_MONITORING; | 1237 enabled_flag |= ENABLED_FOR_MONITORING; |
1241 if (event_callback_ && | 1238 if (event_callback_ && |
1242 event_callback_category_filter_.IsCategoryGroupEnabled(category_group)) | 1239 event_callback_trace_config_.IsCategoryGroupEnabled(category_group)) |
1243 enabled_flag |= ENABLED_FOR_EVENT_CALLBACK; | 1240 enabled_flag |= ENABLED_FOR_EVENT_CALLBACK; |
1244 #if defined(OS_WIN) | 1241 #if defined(OS_WIN) |
1245 if (base::trace_event::TraceEventETWExport::isETWExportEnabled()) | 1242 if (base::trace_event::TraceEventETWExport::isETWExportEnabled()) |
1246 enabled_flag |= ENABLED_FOR_ETW_EXPORT; | 1243 enabled_flag |= ENABLED_FOR_ETW_EXPORT; |
1247 #endif | 1244 #endif |
1248 | 1245 |
1249 g_category_group_enabled[category_index] = enabled_flag; | 1246 g_category_group_enabled[category_index] = enabled_flag; |
1250 } | 1247 } |
1251 | 1248 |
1252 void TraceLog::UpdateCategoryGroupEnabledFlags() { | 1249 void TraceLog::UpdateCategoryGroupEnabledFlags() { |
1253 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); | 1250 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); |
1254 for (size_t i = 0; i < category_index; i++) | 1251 for (size_t i = 0; i < category_index; i++) |
1255 UpdateCategoryGroupEnabledFlag(i); | 1252 UpdateCategoryGroupEnabledFlag(i); |
1256 } | 1253 } |
1257 | 1254 |
1258 void TraceLog::UpdateSyntheticDelaysFromCategoryFilter() { | 1255 void TraceLog::UpdateSyntheticDelaysFromTraceConfig() { |
1259 ResetTraceEventSyntheticDelays(); | 1256 ResetTraceEventSyntheticDelays(); |
1260 const CategoryFilter::StringList& delays = | 1257 const TraceConfig::StringList& delays = |
1261 category_filter_.GetSyntheticDelayValues(); | 1258 trace_config_.GetSyntheticDelayValues(); |
1262 CategoryFilter::StringList::const_iterator ci; | 1259 TraceConfig::StringList::const_iterator ci; |
1263 for (ci = delays.begin(); ci != delays.end(); ++ci) { | 1260 for (ci = delays.begin(); ci != delays.end(); ++ci) { |
1264 StringTokenizer tokens(*ci, ";"); | 1261 StringTokenizer tokens(*ci, ";"); |
1265 if (!tokens.GetNext()) | 1262 if (!tokens.GetNext()) |
1266 continue; | 1263 continue; |
1267 TraceEventSyntheticDelay* delay = | 1264 TraceEventSyntheticDelay* delay = |
1268 TraceEventSyntheticDelay::Lookup(tokens.token()); | 1265 TraceEventSyntheticDelay::Lookup(tokens.token()); |
1269 while (tokens.GetNext()) { | 1266 while (tokens.GetNext()) { |
1270 std::string token = tokens.token(); | 1267 std::string token = tokens.token(); |
1271 char* duration_end; | 1268 char* duration_end; |
1272 double target_duration = strtod(token.c_str(), &duration_end); | 1269 double target_duration = strtod(token.c_str(), &duration_end); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 "must increase MAX_CATEGORY_GROUPS"; | 1313 "must increase MAX_CATEGORY_GROUPS"; |
1317 if (category_index < MAX_CATEGORY_GROUPS) { | 1314 if (category_index < MAX_CATEGORY_GROUPS) { |
1318 // Don't hold on to the category_group pointer, so that we can create | 1315 // Don't hold on to the category_group pointer, so that we can create |
1319 // category groups with strings not known at compile time (this is | 1316 // category groups with strings not known at compile time (this is |
1320 // required by SetWatchEvent). | 1317 // required by SetWatchEvent). |
1321 const char* new_group = strdup(category_group); | 1318 const char* new_group = strdup(category_group); |
1322 ANNOTATE_LEAKING_OBJECT_PTR(new_group); | 1319 ANNOTATE_LEAKING_OBJECT_PTR(new_group); |
1323 g_category_groups[category_index] = new_group; | 1320 g_category_groups[category_index] = new_group; |
1324 DCHECK(!g_category_group_enabled[category_index]); | 1321 DCHECK(!g_category_group_enabled[category_index]); |
1325 // Note that if both included and excluded patterns in the | 1322 // Note that if both included and excluded patterns in the |
1326 // CategoryFilter are empty, we exclude nothing, | 1323 // TraceConfig are empty, we exclude nothing, |
1327 // thereby enabling this category group. | 1324 // thereby enabling this category group. |
1328 UpdateCategoryGroupEnabledFlag(category_index); | 1325 UpdateCategoryGroupEnabledFlag(category_index); |
1329 category_group_enabled = &g_category_group_enabled[category_index]; | 1326 category_group_enabled = &g_category_group_enabled[category_index]; |
1330 // Update the max index now. | 1327 // Update the max index now. |
1331 base::subtle::Release_Store(&g_category_index, category_index + 1); | 1328 base::subtle::Release_Store(&g_category_index, category_index + 1); |
1332 } else { | 1329 } else { |
1333 category_group_enabled = | 1330 category_group_enabled = |
1334 &g_category_group_enabled[g_category_categories_exhausted]; | 1331 &g_category_group_enabled[g_category_categories_exhausted]; |
1335 } | 1332 } |
1336 return category_group_enabled; | 1333 return category_group_enabled; |
1337 } | 1334 } |
1338 | 1335 |
1339 void TraceLog::GetKnownCategoryGroups( | 1336 void TraceLog::GetKnownCategoryGroups( |
1340 std::vector<std::string>* category_groups) { | 1337 std::vector<std::string>* category_groups) { |
1341 AutoLock lock(lock_); | 1338 AutoLock lock(lock_); |
1342 category_groups->push_back( | 1339 category_groups->push_back( |
1343 g_category_groups[g_category_trace_event_overhead]); | 1340 g_category_groups[g_category_trace_event_overhead]); |
1344 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); | 1341 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); |
1345 for (size_t i = g_num_builtin_categories; i < category_index; i++) | 1342 for (size_t i = g_num_builtin_categories; i < category_index; i++) |
1346 category_groups->push_back(g_category_groups[i]); | 1343 category_groups->push_back(g_category_groups[i]); |
1347 } | 1344 } |
1348 | 1345 |
1349 void TraceLog::SetEnabled(const CategoryFilter& category_filter, | 1346 void TraceLog::SetEnabled(const TraceConfig& trace_config, Mode mode) { |
1350 Mode mode, | |
1351 const TraceOptions& options) { | |
1352 std::vector<EnabledStateObserver*> observer_list; | 1347 std::vector<EnabledStateObserver*> observer_list; |
1353 { | 1348 { |
1354 AutoLock lock(lock_); | 1349 AutoLock lock(lock_); |
1355 | 1350 |
1356 // Can't enable tracing when Flush() is in progress. | 1351 // Can't enable tracing when Flush() is in progress. |
1357 DCHECK(!flush_task_runner_); | 1352 DCHECK(!flush_task_runner_); |
1358 | 1353 |
1359 InternalTraceOptions new_options = | 1354 InternalTraceOptions new_options = |
1360 GetInternalOptionsFromTraceOptions(options); | 1355 GetInternalOptionsFromTraceConfig(trace_config); |
1361 | 1356 |
1362 InternalTraceOptions old_options = trace_options(); | 1357 InternalTraceOptions old_options = trace_options(); |
1363 | 1358 |
1364 if (IsEnabled()) { | 1359 if (IsEnabled()) { |
1365 if (new_options != old_options) { | 1360 if (new_options != old_options) { |
1366 DLOG(ERROR) << "Attempting to re-enable tracing with a different " | 1361 DLOG(ERROR) << "Attempting to re-enable tracing with a different " |
1367 << "set of options."; | 1362 << "set of options."; |
1368 } | 1363 } |
1369 | 1364 |
1370 if (mode != mode_) { | 1365 if (mode != mode_) { |
1371 DLOG(ERROR) << "Attempting to re-enable tracing with a different mode."; | 1366 DLOG(ERROR) << "Attempting to re-enable tracing with a different mode."; |
1372 } | 1367 } |
1373 | 1368 |
1374 category_filter_.Merge(category_filter); | 1369 trace_config_.Merge(trace_config); |
1375 UpdateCategoryGroupEnabledFlags(); | 1370 UpdateCategoryGroupEnabledFlags(); |
1376 return; | 1371 return; |
1377 } | 1372 } |
1378 | 1373 |
1379 if (dispatching_to_observer_list_) { | 1374 if (dispatching_to_observer_list_) { |
1380 DLOG(ERROR) << | 1375 DLOG(ERROR) << |
1381 "Cannot manipulate TraceLog::Enabled state from an observer."; | 1376 "Cannot manipulate TraceLog::Enabled state from an observer."; |
1382 return; | 1377 return; |
1383 } | 1378 } |
1384 | 1379 |
1385 mode_ = mode; | 1380 mode_ = mode; |
1386 | 1381 |
1387 if (new_options != old_options) { | 1382 if (new_options != old_options) { |
1388 subtle::NoBarrier_Store(&trace_options_, new_options); | 1383 subtle::NoBarrier_Store(&trace_options_, new_options); |
1389 UseNextTraceBuffer(); | 1384 UseNextTraceBuffer(); |
1390 } | 1385 } |
1391 | 1386 |
1392 num_traces_recorded_++; | 1387 num_traces_recorded_++; |
1393 | 1388 |
1394 category_filter_ = CategoryFilter(category_filter); | 1389 trace_config_ = TraceConfig(trace_config); |
1395 UpdateCategoryGroupEnabledFlags(); | 1390 UpdateCategoryGroupEnabledFlags(); |
1396 UpdateSyntheticDelaysFromCategoryFilter(); | 1391 UpdateSyntheticDelaysFromTraceConfig(); |
1397 | 1392 |
1398 if (new_options & kInternalEnableSampling) { | 1393 if (new_options & kInternalEnableSampling) { |
1399 sampling_thread_.reset(new TraceSamplingThread); | 1394 sampling_thread_.reset(new TraceSamplingThread); |
1400 sampling_thread_->RegisterSampleBucket( | 1395 sampling_thread_->RegisterSampleBucket( |
1401 &g_trace_state[0], | 1396 &g_trace_state[0], |
1402 "bucket0", | 1397 "bucket0", |
1403 Bind(&TraceSamplingThread::DefaultSamplingCallback)); | 1398 Bind(&TraceSamplingThread::DefaultSamplingCallback)); |
1404 sampling_thread_->RegisterSampleBucket( | 1399 sampling_thread_->RegisterSampleBucket( |
1405 &g_trace_state[1], | 1400 &g_trace_state[1], |
1406 "bucket1", | 1401 "bucket1", |
(...skipping 22 matching lines...) Expand all Loading... |
1429 } | 1424 } |
1430 | 1425 |
1431 void TraceLog::SetArgumentFilterPredicate( | 1426 void TraceLog::SetArgumentFilterPredicate( |
1432 const TraceEvent::ArgumentFilterPredicate& argument_filter_predicate) { | 1427 const TraceEvent::ArgumentFilterPredicate& argument_filter_predicate) { |
1433 AutoLock lock(lock_); | 1428 AutoLock lock(lock_); |
1434 DCHECK(!argument_filter_predicate.is_null()); | 1429 DCHECK(!argument_filter_predicate.is_null()); |
1435 DCHECK(argument_filter_predicate_.is_null()); | 1430 DCHECK(argument_filter_predicate_.is_null()); |
1436 argument_filter_predicate_ = argument_filter_predicate; | 1431 argument_filter_predicate_ = argument_filter_predicate; |
1437 } | 1432 } |
1438 | 1433 |
1439 TraceLog::InternalTraceOptions TraceLog::GetInternalOptionsFromTraceOptions( | 1434 TraceLog::InternalTraceOptions TraceLog::GetInternalOptionsFromTraceConfig( |
1440 const TraceOptions& options) { | 1435 const TraceConfig& config) { |
1441 InternalTraceOptions ret = | 1436 InternalTraceOptions ret = |
1442 options.enable_sampling ? kInternalEnableSampling : kInternalNone; | 1437 config.IsSamplingEnabled() ? kInternalEnableSampling : kInternalNone; |
1443 if (options.enable_argument_filter) | 1438 if (config.IsArgumentFilterEnabled()) |
1444 ret |= kInternalEnableArgumentFilter; | 1439 ret |= kInternalEnableArgumentFilter; |
1445 switch (options.record_mode) { | 1440 switch (config.GetTraceRecordMode()) { |
1446 case RECORD_UNTIL_FULL: | 1441 case RECORD_UNTIL_FULL: |
1447 return ret | kInternalRecordUntilFull; | 1442 return ret | kInternalRecordUntilFull; |
1448 case RECORD_CONTINUOUSLY: | 1443 case RECORD_CONTINUOUSLY: |
1449 return ret | kInternalRecordContinuously; | 1444 return ret | kInternalRecordContinuously; |
1450 case ECHO_TO_CONSOLE: | 1445 case ECHO_TO_CONSOLE: |
1451 return ret | kInternalEchoToConsole; | 1446 return ret | kInternalEchoToConsole; |
1452 case RECORD_AS_MUCH_AS_POSSIBLE: | 1447 case RECORD_AS_MUCH_AS_POSSIBLE: |
1453 return ret | kInternalRecordAsMuchAsPossible; | 1448 return ret | kInternalRecordAsMuchAsPossible; |
1454 } | 1449 } |
1455 NOTREACHED(); | 1450 NOTREACHED(); |
1456 return kInternalNone; | 1451 return kInternalNone; |
1457 } | 1452 } |
1458 | 1453 |
1459 CategoryFilter TraceLog::GetCurrentCategoryFilter() { | 1454 TraceConfig TraceLog::GetCurrentTraceConfig() const { |
1460 AutoLock lock(lock_); | 1455 AutoLock lock(lock_); |
1461 return category_filter_; | 1456 return trace_config_; |
1462 } | |
1463 | |
1464 TraceOptions TraceLog::GetCurrentTraceOptions() const { | |
1465 TraceOptions ret; | |
1466 InternalTraceOptions option = trace_options(); | |
1467 ret.enable_sampling = (option & kInternalEnableSampling) != 0; | |
1468 ret.enable_argument_filter = (option & kInternalEnableArgumentFilter) != 0; | |
1469 if (option & kInternalRecordUntilFull) | |
1470 ret.record_mode = RECORD_UNTIL_FULL; | |
1471 else if (option & kInternalRecordContinuously) | |
1472 ret.record_mode = RECORD_CONTINUOUSLY; | |
1473 else if (option & kInternalEchoToConsole) | |
1474 ret.record_mode = ECHO_TO_CONSOLE; | |
1475 else if (option & kInternalRecordAsMuchAsPossible) | |
1476 ret.record_mode = RECORD_AS_MUCH_AS_POSSIBLE; | |
1477 else | |
1478 NOTREACHED(); | |
1479 return ret; | |
1480 } | 1457 } |
1481 | 1458 |
1482 void TraceLog::SetDisabled() { | 1459 void TraceLog::SetDisabled() { |
1483 AutoLock lock(lock_); | 1460 AutoLock lock(lock_); |
1484 SetDisabledWhileLocked(); | 1461 SetDisabledWhileLocked(); |
1485 } | 1462 } |
1486 | 1463 |
1487 void TraceLog::SetDisabledWhileLocked() { | 1464 void TraceLog::SetDisabledWhileLocked() { |
1488 lock_.AssertAcquired(); | 1465 lock_.AssertAcquired(); |
1489 | 1466 |
(...skipping 11 matching lines...) Expand all Loading... |
1501 if (sampling_thread_.get()) { | 1478 if (sampling_thread_.get()) { |
1502 // Stop the sampling thread. | 1479 // Stop the sampling thread. |
1503 sampling_thread_->Stop(); | 1480 sampling_thread_->Stop(); |
1504 lock_.Release(); | 1481 lock_.Release(); |
1505 PlatformThread::Join(sampling_thread_handle_); | 1482 PlatformThread::Join(sampling_thread_handle_); |
1506 lock_.Acquire(); | 1483 lock_.Acquire(); |
1507 sampling_thread_handle_ = PlatformThreadHandle(); | 1484 sampling_thread_handle_ = PlatformThreadHandle(); |
1508 sampling_thread_.reset(); | 1485 sampling_thread_.reset(); |
1509 } | 1486 } |
1510 | 1487 |
1511 category_filter_.Clear(); | 1488 trace_config_.Clear(); |
1512 subtle::NoBarrier_Store(&watch_category_, 0); | 1489 subtle::NoBarrier_Store(&watch_category_, 0); |
1513 watch_event_name_ = ""; | 1490 watch_event_name_ = ""; |
1514 UpdateCategoryGroupEnabledFlags(); | 1491 UpdateCategoryGroupEnabledFlags(); |
1515 AddMetadataEventsWhileLocked(); | 1492 AddMetadataEventsWhileLocked(); |
1516 | 1493 |
1517 dispatching_to_observer_list_ = true; | 1494 dispatching_to_observer_list_ = true; |
1518 std::vector<EnabledStateObserver*> observer_list = | 1495 std::vector<EnabledStateObserver*> observer_list = |
1519 enabled_state_observer_list_; | 1496 enabled_state_observer_list_; |
1520 | 1497 |
1521 { | 1498 { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 void TraceLog::CheckIfBufferIsFullWhileLocked() { | 1593 void TraceLog::CheckIfBufferIsFullWhileLocked() { |
1617 lock_.AssertAcquired(); | 1594 lock_.AssertAcquired(); |
1618 if (logged_events_->IsFull()) { | 1595 if (logged_events_->IsFull()) { |
1619 if (buffer_limit_reached_timestamp_.is_null()) { | 1596 if (buffer_limit_reached_timestamp_.is_null()) { |
1620 buffer_limit_reached_timestamp_ = OffsetNow(); | 1597 buffer_limit_reached_timestamp_ = OffsetNow(); |
1621 } | 1598 } |
1622 SetDisabledWhileLocked(); | 1599 SetDisabledWhileLocked(); |
1623 } | 1600 } |
1624 } | 1601 } |
1625 | 1602 |
1626 void TraceLog::SetEventCallbackEnabled(const CategoryFilter& category_filter, | 1603 void TraceLog::SetEventCallbackEnabled(const TraceConfig& trace_config, |
1627 EventCallback cb) { | 1604 EventCallback cb) { |
1628 AutoLock lock(lock_); | 1605 AutoLock lock(lock_); |
1629 subtle::NoBarrier_Store(&event_callback_, | 1606 subtle::NoBarrier_Store(&event_callback_, |
1630 reinterpret_cast<subtle::AtomicWord>(cb)); | 1607 reinterpret_cast<subtle::AtomicWord>(cb)); |
1631 event_callback_category_filter_ = category_filter; | 1608 event_callback_trace_config_ = trace_config; |
1632 UpdateCategoryGroupEnabledFlags(); | 1609 UpdateCategoryGroupEnabledFlags(); |
1633 }; | 1610 }; |
1634 | 1611 |
1635 void TraceLog::SetEventCallbackDisabled() { | 1612 void TraceLog::SetEventCallbackDisabled() { |
1636 AutoLock lock(lock_); | 1613 AutoLock lock(lock_); |
1637 subtle::NoBarrier_Store(&event_callback_, 0); | 1614 subtle::NoBarrier_Store(&event_callback_, 0); |
1638 UpdateCategoryGroupEnabledFlags(); | 1615 UpdateCategoryGroupEnabledFlags(); |
1639 } | 1616 } |
1640 | 1617 |
1641 // Flush() works as the following: | 1618 // Flush() works as the following: |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2382 } | 2359 } |
2383 | 2360 |
2384 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 2361 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
2385 if (*category_group_enabled_) { | 2362 if (*category_group_enabled_) { |
2386 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, | 2363 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, |
2387 name_, event_handle_); | 2364 name_, event_handle_); |
2388 } | 2365 } |
2389 } | 2366 } |
2390 | 2367 |
2391 } // namespace trace_event_internal | 2368 } // namespace trace_event_internal |
OLD | NEW |