Chromium Code Reviews| 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/debug/trace_event_impl.h" | 5 #include "base/debug/trace_event_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 | 51 |
| 52 namespace base { | 52 namespace base { |
| 53 namespace debug { | 53 namespace debug { |
| 54 | 54 |
| 55 namespace { | 55 namespace { |
| 56 | 56 |
| 57 // The overhead of TraceEvent above this threshold will be reported in the | 57 // The overhead of TraceEvent above this threshold will be reported in the |
| 58 // trace. | 58 // trace. |
| 59 const int kOverheadReportThresholdInMicroseconds = 50; | 59 const int kOverheadReportThresholdInMicroseconds = 50; |
| 60 | 60 |
| 61 // String options that can be used to initialize TraceOptions. | |
| 62 const char kRecordUntilFull[] = "record-until-full"; | |
| 63 const char kRecordContinuously[] = "record-continuously"; | |
| 64 const char kTraceToConsole[] = "trace-to-console"; | |
| 65 const char kEnableSampling[] = "enable-sampling"; | |
| 66 const char kEnableSystrace[] = "enable-systrace"; | |
| 67 | |
| 61 // Controls the number of trace events we will buffer in-memory | 68 // Controls the number of trace events we will buffer in-memory |
| 62 // before throwing them away. | 69 // before throwing them away. |
| 63 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize; | 70 const size_t kTraceBufferChunkSize = TraceBufferChunk::kTraceBufferChunkSize; |
| 64 const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize; | 71 const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize; |
| 65 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4; | 72 const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4; |
| 66 const size_t kTraceEventBatchChunks = 1000 / kTraceBufferChunkSize; | 73 const size_t kTraceEventBatchChunks = 1000 / kTraceBufferChunkSize; |
| 67 // Can store results for 30 seconds with 1 ms sampling interval. | 74 // Can store results for 30 seconds with 1 ms sampling interval. |
| 68 const size_t kMonitorTraceEventBufferChunks = 30000 / kTraceBufferChunkSize; | 75 const size_t kMonitorTraceEventBufferChunks = 30000 / kTraceBufferChunkSize; |
| 69 // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events. | 76 // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events. |
| 70 const size_t kEchoToConsoleTraceEventBufferChunks = 256; | 77 const size_t kEchoToConsoleTraceEventBufferChunks = 256; |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 963 : bucket(bucket), | 970 : bucket(bucket), |
| 964 bucket_name(name), | 971 bucket_name(name), |
| 965 callback(callback) { | 972 callback(callback) { |
| 966 } | 973 } |
| 967 | 974 |
| 968 TraceBucketData::~TraceBucketData() { | 975 TraceBucketData::~TraceBucketData() { |
| 969 } | 976 } |
| 970 | 977 |
| 971 //////////////////////////////////////////////////////////////////////////////// | 978 //////////////////////////////////////////////////////////////////////////////// |
| 972 // | 979 // |
| 980 // TraceOptions | |
| 981 // | |
| 982 //////////////////////////////////////////////////////////////////////////////// | |
| 983 | |
| 984 TraceOptions::TraceOptions(const std::string& options_string) | |
| 985 : record_mode(RECORD_UNTIL_FULL), | |
| 986 enable_sampling(false), | |
| 987 enable_systrace(false) { | |
| 988 std::vector<std::string> split; | |
| 989 std::vector<std::string>::iterator iter; | |
| 990 | |
| 991 base::SplitString(options_string, ',', &split); | |
| 992 for (iter = split.begin(); iter != split.end(); ++iter) { | |
| 993 if (*iter == kRecordUntilFull) { | |
| 994 record_mode = RECORD_UNTIL_FULL; | |
| 995 } else if (*iter == kRecordContinuously) { | |
| 996 record_mode = RECORD_CONTINUOUSLY; | |
| 997 } else if (*iter == kTraceToConsole) { | |
| 998 record_mode = ECHO_TO_CONSOLE; | |
| 999 } else if (*iter == kEnableSampling) { | |
| 1000 enable_sampling = true; | |
| 1001 } else if (*iter == kEnableSystrace) { | |
| 1002 enable_systrace = true; | |
| 1003 } | |
| 1004 } | |
| 1005 } | |
| 1006 | |
| 1007 std::string TraceOptions::ToString() const { | |
| 1008 std::string ret; | |
| 1009 switch (record_mode) { | |
| 1010 case RECORD_UNTIL_FULL: | |
| 1011 ret = kRecordUntilFull; | |
| 1012 break; | |
| 1013 case RECORD_CONTINUOUSLY: | |
| 1014 ret = kRecordContinuously; | |
| 1015 break; | |
| 1016 case ECHO_TO_CONSOLE: | |
| 1017 ret = kTraceToConsole; | |
| 1018 break; | |
| 1019 default: | |
| 1020 NOTREACHED(); | |
| 1021 } | |
| 1022 if (enable_sampling) | |
| 1023 ret = ret + "," + kEnableSampling; | |
| 1024 if (enable_systrace) | |
| 1025 ret = ret + "," + kEnableSystrace; | |
| 1026 return ret; | |
| 1027 } | |
| 1028 | |
| 1029 //////////////////////////////////////////////////////////////////////////////// | |
| 1030 // | |
| 973 // TraceLog | 1031 // TraceLog |
| 974 // | 1032 // |
| 975 //////////////////////////////////////////////////////////////////////////////// | 1033 //////////////////////////////////////////////////////////////////////////////// |
| 976 | 1034 |
| 977 class TraceLog::ThreadLocalEventBuffer | 1035 class TraceLog::ThreadLocalEventBuffer |
| 978 : public MessageLoop::DestructionObserver { | 1036 : public MessageLoop::DestructionObserver { |
| 979 public: | 1037 public: |
| 980 ThreadLocalEventBuffer(TraceLog* trace_log); | 1038 ThreadLocalEventBuffer(TraceLog* trace_log); |
| 981 virtual ~ThreadLocalEventBuffer(); | 1039 virtual ~ThreadLocalEventBuffer(); |
| 982 | 1040 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1130 | 1188 |
| 1131 TraceLog::TraceLog() | 1189 TraceLog::TraceLog() |
| 1132 : mode_(DISABLED), | 1190 : mode_(DISABLED), |
| 1133 num_traces_recorded_(0), | 1191 num_traces_recorded_(0), |
| 1134 event_callback_(0), | 1192 event_callback_(0), |
| 1135 dispatching_to_observer_list_(false), | 1193 dispatching_to_observer_list_(false), |
| 1136 process_sort_index_(0), | 1194 process_sort_index_(0), |
| 1137 process_id_hash_(0), | 1195 process_id_hash_(0), |
| 1138 process_id_(0), | 1196 process_id_(0), |
| 1139 watch_category_(0), | 1197 watch_category_(0), |
| 1140 trace_options_(RECORD_UNTIL_FULL), | 1198 trace_options_(kInternalRecordUntilFull), |
|
dsinclair
2014/07/30 14:25:24
RECORD_UNTIL_FULL is the default value, shouldn't
nednguyen
2014/07/30 16:51:12
It's the default value of TraceOptions, not the in
| |
| 1141 sampling_thread_handle_(0), | 1199 sampling_thread_handle_(0), |
| 1142 category_filter_(CategoryFilter::kDefaultCategoryFilterString), | 1200 category_filter_(CategoryFilter::kDefaultCategoryFilterString), |
| 1143 event_callback_category_filter_( | 1201 event_callback_category_filter_( |
| 1144 CategoryFilter::kDefaultCategoryFilterString), | 1202 CategoryFilter::kDefaultCategoryFilterString), |
| 1145 thread_shared_chunk_index_(0), | 1203 thread_shared_chunk_index_(0), |
| 1146 generation_(0) { | 1204 generation_(0) { |
| 1147 // Trace is enabled or disabled on one thread while other threads are | 1205 // Trace is enabled or disabled on one thread while other threads are |
| 1148 // accessing the enabled flag. We don't care whether edge-case events are | 1206 // accessing the enabled flag. We don't care whether edge-case events are |
| 1149 // traced or not, so we allow races on the enabled flag to keep the trace | 1207 // traced or not, so we allow races on the enabled flag to keep the trace |
| 1150 // macros fast. | 1208 // macros fast. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1168 switches::kTraceToConsole); | 1226 switches::kTraceToConsole); |
| 1169 if (filter.empty()) { | 1227 if (filter.empty()) { |
| 1170 filter = kEchoToConsoleCategoryFilter; | 1228 filter = kEchoToConsoleCategoryFilter; |
| 1171 } else { | 1229 } else { |
| 1172 filter.append(","); | 1230 filter.append(","); |
| 1173 filter.append(kEchoToConsoleCategoryFilter); | 1231 filter.append(kEchoToConsoleCategoryFilter); |
| 1174 } | 1232 } |
| 1175 | 1233 |
| 1176 LOG(ERROR) << "Start " << switches::kTraceToConsole | 1234 LOG(ERROR) << "Start " << switches::kTraceToConsole |
| 1177 << " with CategoryFilter '" << filter << "'."; | 1235 << " with CategoryFilter '" << filter << "'."; |
| 1178 SetEnabled(CategoryFilter(filter), RECORDING_MODE, ECHO_TO_CONSOLE); | 1236 SetEnabled(CategoryFilter(filter), |
| 1237 RECORDING_MODE, | |
| 1238 TraceOptions(ECHO_TO_CONSOLE)); | |
| 1179 } | 1239 } |
| 1180 #endif | 1240 #endif |
| 1181 | 1241 |
| 1182 logged_events_.reset(CreateTraceBuffer()); | 1242 logged_events_.reset(CreateTraceBuffer()); |
| 1183 } | 1243 } |
| 1184 | 1244 |
| 1185 TraceLog::~TraceLog() { | 1245 TraceLog::~TraceLog() { |
| 1186 } | 1246 } |
| 1187 | 1247 |
| 1188 const unsigned char* TraceLog::GetCategoryGroupEnabled( | 1248 const unsigned char* TraceLog::GetCategoryGroupEnabled( |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1318 AutoLock lock(lock_); | 1378 AutoLock lock(lock_); |
| 1319 category_groups->push_back( | 1379 category_groups->push_back( |
| 1320 g_category_groups[g_category_trace_event_overhead]); | 1380 g_category_groups[g_category_trace_event_overhead]); |
| 1321 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); | 1381 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); |
| 1322 for (size_t i = g_num_builtin_categories; i < category_index; i++) | 1382 for (size_t i = g_num_builtin_categories; i < category_index; i++) |
| 1323 category_groups->push_back(g_category_groups[i]); | 1383 category_groups->push_back(g_category_groups[i]); |
| 1324 } | 1384 } |
| 1325 | 1385 |
| 1326 void TraceLog::SetEnabled(const CategoryFilter& category_filter, | 1386 void TraceLog::SetEnabled(const CategoryFilter& category_filter, |
| 1327 Mode mode, | 1387 Mode mode, |
| 1328 Options options) { | 1388 const TraceOptions& options) { |
| 1329 std::vector<EnabledStateObserver*> observer_list; | 1389 std::vector<EnabledStateObserver*> observer_list; |
| 1330 { | 1390 { |
| 1331 AutoLock lock(lock_); | 1391 AutoLock lock(lock_); |
| 1332 | 1392 |
| 1333 // Can't enable tracing when Flush() is in progress. | 1393 // Can't enable tracing when Flush() is in progress. |
| 1334 DCHECK(!flush_message_loop_proxy_.get()); | 1394 DCHECK(!flush_message_loop_proxy_.get()); |
| 1335 | 1395 |
| 1336 Options old_options = trace_options(); | 1396 InternalTraceOptions new_options = |
| 1397 GetInternalOptionsFromTraceOptions(options); | |
| 1398 | |
| 1399 InternalTraceOptions old_options = trace_options(); | |
| 1337 | 1400 |
| 1338 if (IsEnabled()) { | 1401 if (IsEnabled()) { |
| 1339 if (options != old_options) { | 1402 if (new_options != old_options) { |
| 1340 DLOG(ERROR) << "Attempting to re-enable tracing with a different " | 1403 DLOG(ERROR) << "Attempting to re-enable tracing with a different " |
| 1341 << "set of options."; | 1404 << "set of options."; |
| 1342 } | 1405 } |
| 1343 | 1406 |
| 1344 if (mode != mode_) { | 1407 if (mode != mode_) { |
| 1345 DLOG(ERROR) << "Attempting to re-enable tracing with a different mode."; | 1408 DLOG(ERROR) << "Attempting to re-enable tracing with a different mode."; |
| 1346 } | 1409 } |
| 1347 | 1410 |
| 1348 category_filter_.Merge(category_filter); | 1411 category_filter_.Merge(category_filter); |
| 1349 UpdateCategoryGroupEnabledFlags(); | 1412 UpdateCategoryGroupEnabledFlags(); |
| 1350 return; | 1413 return; |
| 1351 } | 1414 } |
| 1352 | 1415 |
| 1353 if (dispatching_to_observer_list_) { | 1416 if (dispatching_to_observer_list_) { |
| 1354 DLOG(ERROR) << | 1417 DLOG(ERROR) << |
| 1355 "Cannot manipulate TraceLog::Enabled state from an observer."; | 1418 "Cannot manipulate TraceLog::Enabled state from an observer."; |
| 1356 return; | 1419 return; |
| 1357 } | 1420 } |
| 1358 | 1421 |
| 1359 mode_ = mode; | 1422 mode_ = mode; |
| 1360 | 1423 |
| 1361 if (options != old_options) { | 1424 if (new_options != old_options) { |
| 1362 subtle::NoBarrier_Store(&trace_options_, options); | 1425 subtle::NoBarrier_Store(&trace_options_, new_options); |
| 1363 UseNextTraceBuffer(); | 1426 UseNextTraceBuffer(); |
| 1364 } | 1427 } |
| 1365 | 1428 |
| 1366 num_traces_recorded_++; | 1429 num_traces_recorded_++; |
| 1367 | 1430 |
| 1368 category_filter_ = CategoryFilter(category_filter); | 1431 category_filter_ = CategoryFilter(category_filter); |
| 1369 UpdateCategoryGroupEnabledFlags(); | 1432 UpdateCategoryGroupEnabledFlags(); |
| 1370 UpdateSyntheticDelaysFromCategoryFilter(); | 1433 UpdateSyntheticDelaysFromCategoryFilter(); |
| 1371 | 1434 |
| 1372 if (options & ENABLE_SAMPLING) { | 1435 if (new_options & kInternalEnableSampling) { |
| 1373 sampling_thread_.reset(new TraceSamplingThread); | 1436 sampling_thread_.reset(new TraceSamplingThread); |
| 1374 sampling_thread_->RegisterSampleBucket( | 1437 sampling_thread_->RegisterSampleBucket( |
| 1375 &g_trace_state[0], | 1438 &g_trace_state[0], |
| 1376 "bucket0", | 1439 "bucket0", |
| 1377 Bind(&TraceSamplingThread::DefaultSamplingCallback)); | 1440 Bind(&TraceSamplingThread::DefaultSamplingCallback)); |
| 1378 sampling_thread_->RegisterSampleBucket( | 1441 sampling_thread_->RegisterSampleBucket( |
| 1379 &g_trace_state[1], | 1442 &g_trace_state[1], |
| 1380 "bucket1", | 1443 "bucket1", |
| 1381 Bind(&TraceSamplingThread::DefaultSamplingCallback)); | 1444 Bind(&TraceSamplingThread::DefaultSamplingCallback)); |
| 1382 sampling_thread_->RegisterSampleBucket( | 1445 sampling_thread_->RegisterSampleBucket( |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1395 // Notify observers outside the lock in case they trigger trace events. | 1458 // Notify observers outside the lock in case they trigger trace events. |
| 1396 for (size_t i = 0; i < observer_list.size(); ++i) | 1459 for (size_t i = 0; i < observer_list.size(); ++i) |
| 1397 observer_list[i]->OnTraceLogEnabled(); | 1460 observer_list[i]->OnTraceLogEnabled(); |
| 1398 | 1461 |
| 1399 { | 1462 { |
| 1400 AutoLock lock(lock_); | 1463 AutoLock lock(lock_); |
| 1401 dispatching_to_observer_list_ = false; | 1464 dispatching_to_observer_list_ = false; |
| 1402 } | 1465 } |
| 1403 } | 1466 } |
| 1404 | 1467 |
| 1468 TraceLog::InternalTraceOptions TraceLog::GetInternalOptionsFromTraceOptions( | |
| 1469 const TraceOptions& options) { | |
| 1470 InternalTraceOptions ret = | |
| 1471 options.enable_sampling ? kInternalEnableSampling : kInternalNone; | |
|
dsinclair
2014/07/30 14:25:24
What about systrace?
nednguyen
2014/07/30 16:51:12
Systrace is not handled here.
| |
| 1472 switch (options.record_mode) { | |
| 1473 case RECORD_UNTIL_FULL: | |
| 1474 return ret | kInternalRecordUntilFull; | |
| 1475 case RECORD_CONTINUOUSLY: | |
| 1476 return ret | kInternalRecordContinuously; | |
| 1477 case ECHO_TO_CONSOLE: | |
| 1478 return ret | kInternalEchoToConsole; | |
| 1479 } | |
| 1480 NOTREACHED(); | |
| 1481 return kInternalNone; | |
| 1482 } | |
| 1483 | |
| 1405 CategoryFilter TraceLog::GetCurrentCategoryFilter() { | 1484 CategoryFilter TraceLog::GetCurrentCategoryFilter() { |
| 1406 AutoLock lock(lock_); | 1485 AutoLock lock(lock_); |
| 1407 return category_filter_; | 1486 return category_filter_; |
| 1408 } | 1487 } |
| 1409 | 1488 |
| 1489 TraceOptions TraceLog::GetCurrentTraceOptions() const { | |
| 1490 TraceOptions ret; | |
| 1491 InternalTraceOptions option = trace_options(); | |
| 1492 ret.enable_sampling = (option & kInternalEnableSampling) != 0; | |
|
dsinclair
2014/07/30 14:25:24
What about systrace?
nednguyen
2014/07/30 16:51:12
ditto
| |
| 1493 if (option & kInternalRecordUntilFull) | |
| 1494 ret.record_mode = RECORD_UNTIL_FULL; | |
| 1495 else if (option & kInternalRecordContinuously) | |
| 1496 ret.record_mode = RECORD_CONTINUOUSLY; | |
| 1497 else if (option & kInternalEchoToConsole) | |
| 1498 ret.record_mode = ECHO_TO_CONSOLE; | |
| 1499 else | |
| 1500 NOTREACHED(); | |
| 1501 return ret; | |
| 1502 } | |
| 1503 | |
| 1410 void TraceLog::SetDisabled() { | 1504 void TraceLog::SetDisabled() { |
| 1411 AutoLock lock(lock_); | 1505 AutoLock lock(lock_); |
| 1412 SetDisabledWhileLocked(); | 1506 SetDisabledWhileLocked(); |
| 1413 } | 1507 } |
| 1414 | 1508 |
| 1415 void TraceLog::SetDisabledWhileLocked() { | 1509 void TraceLog::SetDisabledWhileLocked() { |
| 1416 lock_.AssertAcquired(); | 1510 lock_.AssertAcquired(); |
| 1417 | 1511 |
| 1418 if (!IsEnabled()) | 1512 if (!IsEnabled()) |
| 1419 return; | 1513 return; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1489 return static_cast<float>(static_cast<double>(logged_events_->Size()) / | 1583 return static_cast<float>(static_cast<double>(logged_events_->Size()) / |
| 1490 logged_events_->Capacity()); | 1584 logged_events_->Capacity()); |
| 1491 } | 1585 } |
| 1492 | 1586 |
| 1493 bool TraceLog::BufferIsFull() const { | 1587 bool TraceLog::BufferIsFull() const { |
| 1494 AutoLock lock(lock_); | 1588 AutoLock lock(lock_); |
| 1495 return logged_events_->IsFull(); | 1589 return logged_events_->IsFull(); |
| 1496 } | 1590 } |
| 1497 | 1591 |
| 1498 TraceBuffer* TraceLog::CreateTraceBuffer() { | 1592 TraceBuffer* TraceLog::CreateTraceBuffer() { |
| 1499 Options options = trace_options(); | 1593 InternalTraceOptions options = trace_options(); |
| 1500 if (options & RECORD_CONTINUOUSLY) | 1594 if (options & kInternalRecordContinuously) |
| 1501 return new TraceBufferRingBuffer(kTraceEventRingBufferChunks); | 1595 return new TraceBufferRingBuffer(kTraceEventRingBufferChunks); |
| 1502 else if ((options & ENABLE_SAMPLING) && mode_ == MONITORING_MODE) | 1596 else if ((options & kInternalEnableSampling) && mode_ == MONITORING_MODE) |
| 1503 return new TraceBufferRingBuffer(kMonitorTraceEventBufferChunks); | 1597 return new TraceBufferRingBuffer(kMonitorTraceEventBufferChunks); |
| 1504 else if (options & ECHO_TO_CONSOLE) | 1598 else if (options & kInternalEchoToConsole) |
| 1505 return new TraceBufferRingBuffer(kEchoToConsoleTraceEventBufferChunks); | 1599 return new TraceBufferRingBuffer(kEchoToConsoleTraceEventBufferChunks); |
| 1506 return CreateTraceBufferVectorOfSize(kTraceEventVectorBufferChunks); | 1600 return CreateTraceBufferVectorOfSize(kTraceEventVectorBufferChunks); |
| 1507 } | 1601 } |
| 1508 | 1602 |
| 1509 TraceBuffer* TraceLog::CreateTraceBufferVectorOfSize(size_t max_chunks) { | 1603 TraceBuffer* TraceLog::CreateTraceBufferVectorOfSize(size_t max_chunks) { |
| 1510 return new TraceBufferVector(max_chunks); | 1604 return new TraceBufferVector(max_chunks); |
| 1511 } | 1605 } |
| 1512 | 1606 |
| 1513 TraceEvent* TraceLog::AddEventToThreadSharedChunkWhileLocked( | 1607 TraceEvent* TraceLog::AddEventToThreadSharedChunkWhileLocked( |
| 1514 TraceEventHandle* handle, bool check_buffer_is_full) { | 1608 TraceEventHandle* handle, bool check_buffer_is_full) { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1867 trace_event->Initialize(thread_id, now, thread_now, phase, | 1961 trace_event->Initialize(thread_id, now, thread_now, phase, |
| 1868 category_group_enabled, name, id, | 1962 category_group_enabled, name, id, |
| 1869 num_args, arg_names, arg_types, arg_values, | 1963 num_args, arg_names, arg_types, arg_values, |
| 1870 convertable_values, flags); | 1964 convertable_values, flags); |
| 1871 | 1965 |
| 1872 #if defined(OS_ANDROID) | 1966 #if defined(OS_ANDROID) |
| 1873 trace_event->SendToATrace(); | 1967 trace_event->SendToATrace(); |
| 1874 #endif | 1968 #endif |
| 1875 } | 1969 } |
| 1876 | 1970 |
| 1877 if (trace_options() & ECHO_TO_CONSOLE) { | 1971 if (trace_options() & kInternalEchoToConsole) { |
| 1878 console_message = EventToConsoleMessage( | 1972 console_message = EventToConsoleMessage( |
| 1879 phase == TRACE_EVENT_PHASE_COMPLETE ? TRACE_EVENT_PHASE_BEGIN : phase, | 1973 phase == TRACE_EVENT_PHASE_COMPLETE ? TRACE_EVENT_PHASE_BEGIN : phase, |
| 1880 timestamp, trace_event); | 1974 timestamp, trace_event); |
| 1881 } | 1975 } |
| 1882 } | 1976 } |
| 1883 | 1977 |
| 1884 if (console_message.size()) | 1978 if (console_message.size()) |
| 1885 LOG(ERROR) << console_message; | 1979 LOG(ERROR) << console_message; |
| 1886 | 1980 |
| 1887 if (reinterpret_cast<const unsigned char*>(subtle::NoBarrier_Load( | 1981 if (reinterpret_cast<const unsigned char*>(subtle::NoBarrier_Load( |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2010 | 2104 |
| 2011 TraceEvent* trace_event = GetEventByHandleInternal(handle, &lock); | 2105 TraceEvent* trace_event = GetEventByHandleInternal(handle, &lock); |
| 2012 if (trace_event) { | 2106 if (trace_event) { |
| 2013 DCHECK(trace_event->phase() == TRACE_EVENT_PHASE_COMPLETE); | 2107 DCHECK(trace_event->phase() == TRACE_EVENT_PHASE_COMPLETE); |
| 2014 trace_event->UpdateDuration(now, thread_now); | 2108 trace_event->UpdateDuration(now, thread_now); |
| 2015 #if defined(OS_ANDROID) | 2109 #if defined(OS_ANDROID) |
| 2016 trace_event->SendToATrace(); | 2110 trace_event->SendToATrace(); |
| 2017 #endif | 2111 #endif |
| 2018 } | 2112 } |
| 2019 | 2113 |
| 2020 if (trace_options() & ECHO_TO_CONSOLE) { | 2114 if (trace_options() & kInternalEchoToConsole) { |
| 2021 console_message = EventToConsoleMessage(TRACE_EVENT_PHASE_END, | 2115 console_message = EventToConsoleMessage(TRACE_EVENT_PHASE_END, |
| 2022 now, trace_event); | 2116 now, trace_event); |
| 2023 } | 2117 } |
| 2024 } | 2118 } |
| 2025 | 2119 |
| 2026 if (console_message.size()) | 2120 if (console_message.size()) |
| 2027 LOG(ERROR) << console_message; | 2121 LOG(ERROR) << console_message; |
| 2028 | 2122 |
| 2029 if (*category_group_enabled & ENABLED_FOR_EVENT_CALLBACK) { | 2123 if (*category_group_enabled & ENABLED_FOR_EVENT_CALLBACK) { |
| 2030 EventCallback event_callback = reinterpret_cast<EventCallback>( | 2124 EventCallback event_callback = reinterpret_cast<EventCallback>( |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2447 } | 2541 } |
| 2448 | 2542 |
| 2449 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 2543 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 2450 if (*category_group_enabled_) { | 2544 if (*category_group_enabled_) { |
| 2451 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, | 2545 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, |
| 2452 name_, event_handle_); | 2546 name_, event_handle_); |
| 2453 } | 2547 } |
| 2454 } | 2548 } |
| 2455 | 2549 |
| 2456 } // namespace trace_event_internal | 2550 } // namespace trace_event_internal |
| OLD | NEW |