Chromium Code Reviews| 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/trace_event/trace_log.h" | 5 #include "base/trace_event/trace_log.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/base_switches.h" | 12 #include "base/base_switches.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/debug/leak_annotations.h" | 15 #include "base/debug/leak_annotations.h" |
| 16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 17 #include "base/location.h" | 17 #include "base/location.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/ptr_util.h" | |
| 19 #include "base/memory/ref_counted_memory.h" | 20 #include "base/memory/ref_counted_memory.h" |
| 20 #include "base/memory/singleton.h" | 21 #include "base/memory/singleton.h" |
| 21 #include "base/process/process_metrics.h" | 22 #include "base/process/process_metrics.h" |
| 22 #include "base/stl_util.h" | 23 #include "base/stl_util.h" |
| 23 #include "base/strings/string_split.h" | 24 #include "base/strings/string_split.h" |
| 24 #include "base/strings/string_tokenizer.h" | 25 #include "base/strings/string_tokenizer.h" |
| 25 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
| 26 #include "base/sys_info.h" | 27 #include "base/sys_info.h" |
| 27 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 28 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 28 #include "base/threading/platform_thread.h" | 29 #include "base/threading/platform_thread.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 // convert internally to determine the category name from the char enabled | 96 // convert internally to determine the category name from the char enabled |
| 96 // pointer. | 97 // pointer. |
| 97 const char* g_category_groups[MAX_CATEGORY_GROUPS] = { | 98 const char* g_category_groups[MAX_CATEGORY_GROUPS] = { |
| 98 "toplevel", | 99 "toplevel", |
| 99 "tracing already shutdown", | 100 "tracing already shutdown", |
| 100 "tracing categories exhausted; must increase MAX_CATEGORY_GROUPS", | 101 "tracing categories exhausted; must increase MAX_CATEGORY_GROUPS", |
| 101 "__metadata"}; | 102 "__metadata"}; |
| 102 | 103 |
| 103 // The enabled flag is char instead of bool so that the API can be used from C. | 104 // The enabled flag is char instead of bool so that the API can be used from C. |
| 104 unsigned char g_category_group_enabled[MAX_CATEGORY_GROUPS] = {0}; | 105 unsigned char g_category_group_enabled[MAX_CATEGORY_GROUPS] = {0}; |
| 106 | |
| 107 class EventNameFilter : public TraceLog::TraceEventFilter { | |
| 108 public: | |
| 109 EventNameFilter(const base::DictionaryValue* filter_args) { | |
| 110 const base::ListValue* whitelist = nullptr; | |
| 111 if (filter_args->GetList("event_name_whitelist", &whitelist)) { | |
|
shatch
2016/08/15 21:25:47
nit: maybe just define these at the top like you d
oystein (OOO til 10th of July)
2016/08/16 22:17:52
Done.
| |
| 112 for (size_t i = 0; i < whitelist->GetSize(); ++i) { | |
| 113 std::string event_name; | |
| 114 if (!whitelist->GetString(i, &event_name)) | |
| 115 continue; | |
| 116 | |
| 117 whitelist_.insert(event_name); | |
| 118 } | |
| 119 } | |
| 120 } | |
| 121 | |
| 122 bool FilterTraceEvent(const TraceEvent& trace_event) const override { | |
| 123 return ContainsKey(whitelist_, trace_event.name()); | |
| 124 } | |
| 125 | |
| 126 private: | |
| 127 std::unordered_set<std::string> whitelist_; | |
| 128 }; | |
| 129 | |
| 130 base::LazyInstance< | |
| 131 std::list<std::unique_ptr<TraceLog::TraceEventFilter>>>::Leaky | |
| 132 g_category_group_filter[MAX_CATEGORY_GROUPS] = {LAZY_INSTANCE_INITIALIZER}; | |
| 133 | |
| 134 TraceLog::TraceEventFilterConstructorForTesting | |
| 135 g_trace_event_filter_constructor_for_testing = nullptr; | |
| 136 | |
| 105 // Indexes here have to match the g_category_groups array indexes above. | 137 // Indexes here have to match the g_category_groups array indexes above. |
| 106 const int kCategoryAlreadyShutdown = 1; | 138 const int kCategoryAlreadyShutdown = 1; |
| 107 const int kCategoryCategoriesExhausted = 2; | 139 const int kCategoryCategoriesExhausted = 2; |
| 108 const int kCategoryMetadata = 3; | 140 const int kCategoryMetadata = 3; |
| 109 const int kNumBuiltinCategories = 4; | 141 const int kNumBuiltinCategories = 4; |
| 110 // Skip default categories. | 142 // Skip default categories. |
| 111 base::subtle::AtomicWord g_category_index = kNumBuiltinCategories; | 143 base::subtle::AtomicWord g_category_index = kNumBuiltinCategories; |
| 112 | 144 |
| 113 // The name of the current thread. This is used to decide if the current | 145 // The name of the current thread. This is used to decide if the current |
| 114 // thread name has changed. We combine all the seen thread names into the | 146 // thread name has changed. We combine all the seen thread names into the |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 size_t event_index, | 204 size_t event_index, |
| 173 TraceEventHandle* handle) { | 205 TraceEventHandle* handle) { |
| 174 DCHECK(chunk_seq); | 206 DCHECK(chunk_seq); |
| 175 DCHECK(chunk_index <= TraceBufferChunk::kMaxChunkIndex); | 207 DCHECK(chunk_index <= TraceBufferChunk::kMaxChunkIndex); |
| 176 DCHECK(event_index < TraceBufferChunk::kTraceBufferChunkSize); | 208 DCHECK(event_index < TraceBufferChunk::kTraceBufferChunkSize); |
| 177 handle->chunk_seq = chunk_seq; | 209 handle->chunk_seq = chunk_seq; |
| 178 handle->chunk_index = static_cast<uint16_t>(chunk_index); | 210 handle->chunk_index = static_cast<uint16_t>(chunk_index); |
| 179 handle->event_index = static_cast<uint16_t>(event_index); | 211 handle->event_index = static_cast<uint16_t>(event_index); |
| 180 } | 212 } |
| 181 | 213 |
| 214 uintptr_t GetCategoryIndex(const unsigned char* category_group_enabled) { | |
| 215 // Calculate the index of the category group by finding | |
| 216 // category_group_enabled in g_category_group_enabled array. | |
| 217 uintptr_t category_begin = | |
| 218 reinterpret_cast<uintptr_t>(g_category_group_enabled); | |
| 219 uintptr_t category_ptr = reinterpret_cast<uintptr_t>(category_group_enabled); | |
| 220 DCHECK(category_ptr >= category_begin); | |
| 221 DCHECK(category_ptr < reinterpret_cast<uintptr_t>(g_category_group_enabled + | |
| 222 MAX_CATEGORY_GROUPS)) | |
| 223 << "out of bounds category pointer"; | |
| 224 uintptr_t category_index = | |
| 225 (category_ptr - category_begin) / sizeof(g_category_group_enabled[0]); | |
| 226 | |
| 227 return category_index; | |
| 228 } | |
| 229 | |
| 182 } // namespace | 230 } // namespace |
| 183 | 231 |
| 184 // A helper class that allows the lock to be acquired in the middle of the scope | 232 // A helper class that allows the lock to be acquired in the middle of the scope |
| 185 // and unlocks at the end of scope if locked. | 233 // and unlocks at the end of scope if locked. |
| 186 class TraceLog::OptionalAutoLock { | 234 class TraceLog::OptionalAutoLock { |
| 187 public: | 235 public: |
| 188 explicit OptionalAutoLock(Lock* lock) : lock_(lock), locked_(false) {} | 236 explicit OptionalAutoLock(Lock* lock) : lock_(lock), locked_(false) {} |
| 189 | 237 |
| 190 ~OptionalAutoLock() { | 238 ~OptionalAutoLock() { |
| 191 if (locked_) | 239 if (locked_) |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 TraceLog* tracelog = GetInstance(); | 486 TraceLog* tracelog = GetInstance(); |
| 439 if (!tracelog) { | 487 if (!tracelog) { |
| 440 DCHECK(!g_category_group_enabled[kCategoryAlreadyShutdown]); | 488 DCHECK(!g_category_group_enabled[kCategoryAlreadyShutdown]); |
| 441 return &g_category_group_enabled[kCategoryAlreadyShutdown]; | 489 return &g_category_group_enabled[kCategoryAlreadyShutdown]; |
| 442 } | 490 } |
| 443 return tracelog->GetCategoryGroupEnabledInternal(category_group); | 491 return tracelog->GetCategoryGroupEnabledInternal(category_group); |
| 444 } | 492 } |
| 445 | 493 |
| 446 const char* TraceLog::GetCategoryGroupName( | 494 const char* TraceLog::GetCategoryGroupName( |
| 447 const unsigned char* category_group_enabled) { | 495 const unsigned char* category_group_enabled) { |
| 448 // Calculate the index of the category group by finding | 496 return g_category_groups[GetCategoryIndex(category_group_enabled)]; |
| 449 // category_group_enabled in g_category_group_enabled array. | 497 } |
| 450 uintptr_t category_begin = | 498 |
| 451 reinterpret_cast<uintptr_t>(g_category_group_enabled); | 499 std::list<std::unique_ptr<TraceLog::TraceEventFilter>>* GetCategoryGroupFilter( |
| 452 uintptr_t category_ptr = reinterpret_cast<uintptr_t>(category_group_enabled); | 500 const unsigned char* category_group_enabled) { |
| 453 DCHECK(category_ptr >= category_begin); | 501 return g_category_group_filter[GetCategoryIndex(category_group_enabled)] |
| 454 DCHECK(category_ptr < reinterpret_cast<uintptr_t>(g_category_group_enabled + | 502 .Pointer(); |
| 455 MAX_CATEGORY_GROUPS)) | |
| 456 << "out of bounds category pointer"; | |
| 457 uintptr_t category_index = | |
| 458 (category_ptr - category_begin) / sizeof(g_category_group_enabled[0]); | |
| 459 return g_category_groups[category_index]; | |
| 460 } | 503 } |
| 461 | 504 |
| 462 void TraceLog::UpdateCategoryGroupEnabledFlag(size_t category_index) { | 505 void TraceLog::UpdateCategoryGroupEnabledFlag(size_t category_index) { |
| 463 unsigned char enabled_flag = 0; | 506 unsigned char enabled_flag = 0; |
| 464 const char* category_group = g_category_groups[category_index]; | 507 const char* category_group = g_category_groups[category_index]; |
| 465 if (mode_ == RECORDING_MODE && | 508 if (mode_ == RECORDING_MODE && |
| 466 trace_config_.IsCategoryGroupEnabled(category_group)) { | 509 trace_config_.IsCategoryGroupEnabled(category_group)) { |
| 467 enabled_flag |= ENABLED_FOR_RECORDING; | 510 enabled_flag |= ENABLED_FOR_RECORDING; |
| 468 } | 511 } |
| 469 | 512 |
| 470 if (event_callback_ && | 513 if (event_callback_ && |
| 471 event_callback_trace_config_.IsCategoryGroupEnabled(category_group)) { | 514 event_callback_trace_config_.IsCategoryGroupEnabled(category_group)) { |
| 472 enabled_flag |= ENABLED_FOR_EVENT_CALLBACK; | 515 enabled_flag |= ENABLED_FOR_EVENT_CALLBACK; |
| 473 } | 516 } |
| 474 | 517 |
| 475 #if defined(OS_WIN) | 518 #if defined(OS_WIN) |
| 476 if (base::trace_event::TraceEventETWExport::IsCategoryGroupEnabled( | 519 if (base::trace_event::TraceEventETWExport::IsCategoryGroupEnabled( |
| 477 category_group)) { | 520 category_group)) { |
| 478 enabled_flag |= ENABLED_FOR_ETW_EXPORT; | 521 enabled_flag |= ENABLED_FOR_ETW_EXPORT; |
| 479 } | 522 } |
| 480 #endif | 523 #endif |
| 481 | 524 |
| 482 // TODO(primiano): this is a temporary workaround for catapult:#2341, | 525 // TODO(primiano): this is a temporary workaround for catapult:#2341, |
| 483 // to guarantee that metadata events are always added even if the category | 526 // to guarantee that metadata events are always added even if the category |
| 484 // filter is "-*". See crbug.com/618054 for more details and long-term fix. | 527 // filter is "-*". See crbug.com/618054 for more details and long-term fix. |
| 485 if (mode_ == RECORDING_MODE && !strcmp(category_group, "__metadata")) | 528 if (mode_ == RECORDING_MODE && !strcmp(category_group, "__metadata")) |
| 486 enabled_flag |= ENABLED_FOR_RECORDING; | 529 enabled_flag |= ENABLED_FOR_RECORDING; |
| 487 | 530 |
| 531 // Having a filter is an exceptional case, so we avoid | |
| 532 // the LazyInstance creation in the common case. | |
| 533 if (!(g_category_group_filter[category_index] == nullptr)) | |
| 534 g_category_group_filter[category_index].Get().clear(); | |
| 535 | |
| 536 for (const auto& event_filter : trace_config_.event_filters()) { | |
| 537 if (event_filter.IsCategoryGroupEnabled(category_group)) { | |
| 538 std::unique_ptr<TraceEventFilter> new_filter; | |
| 539 | |
| 540 if (event_filter.predicate_name() == "event_whitelist_predicate") { | |
| 541 new_filter = | |
| 542 WrapUnique(new EventNameFilter(event_filter.filter_args())); | |
| 543 } else if (event_filter.predicate_name() == "testing_predicate") { | |
| 544 CHECK(g_trace_event_filter_constructor_for_testing); | |
| 545 new_filter = g_trace_event_filter_constructor_for_testing(); | |
| 546 } | |
| 547 | |
| 548 if (new_filter) { | |
| 549 g_category_group_filter[category_index].Get().push_back( | |
| 550 std::move(new_filter)); | |
| 551 enabled_flag |= ENABLED_FOR_FILTERING; | |
| 552 } | |
| 553 } | |
| 554 } | |
| 555 | |
| 488 g_category_group_enabled[category_index] = enabled_flag; | 556 g_category_group_enabled[category_index] = enabled_flag; |
| 489 } | 557 } |
| 490 | 558 |
| 491 void TraceLog::UpdateCategoryGroupEnabledFlags() { | 559 void TraceLog::UpdateCategoryGroupEnabledFlags() { |
| 492 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); | 560 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); |
| 493 for (size_t i = 0; i < category_index; i++) | 561 for (size_t i = 0; i < category_index; i++) |
| 494 UpdateCategoryGroupEnabledFlag(i); | 562 UpdateCategoryGroupEnabledFlag(i); |
| 495 } | 563 } |
| 496 | 564 |
| 497 void TraceLog::UpdateSyntheticDelaysFromTraceConfig() { | 565 void TraceLog::UpdateSyntheticDelaysFromTraceConfig() { |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1264 #if defined(OS_WIN) | 1332 #if defined(OS_WIN) |
| 1265 // This is done sooner rather than later, to avoid creating the event and | 1333 // This is done sooner rather than later, to avoid creating the event and |
| 1266 // acquiring the lock, which is not needed for ETW as it's already threadsafe. | 1334 // acquiring the lock, which is not needed for ETW as it's already threadsafe. |
| 1267 if (*category_group_enabled & ENABLED_FOR_ETW_EXPORT) | 1335 if (*category_group_enabled & ENABLED_FOR_ETW_EXPORT) |
| 1268 TraceEventETWExport::AddEvent(phase, category_group_enabled, name, id, | 1336 TraceEventETWExport::AddEvent(phase, category_group_enabled, name, id, |
| 1269 num_args, arg_names, arg_types, arg_values, | 1337 num_args, arg_names, arg_types, arg_values, |
| 1270 convertable_values); | 1338 convertable_values); |
| 1271 #endif // OS_WIN | 1339 #endif // OS_WIN |
| 1272 | 1340 |
| 1273 std::string console_message; | 1341 std::string console_message; |
| 1274 if (*category_group_enabled & ENABLED_FOR_RECORDING) { | 1342 std::unique_ptr<TraceEvent> filtered_trace_event; |
| 1343 if (*category_group_enabled & ENABLED_FOR_FILTERING) { | |
| 1344 std::unique_ptr<TraceEvent> new_trace_event(new TraceEvent); | |
| 1345 new_trace_event->Initialize(thread_id, offset_event_timestamp, thread_now, | |
| 1346 phase, category_group_enabled, name, scope, id, | |
| 1347 bind_id, num_args, arg_names, arg_types, | |
| 1348 arg_values, convertable_values, flags); | |
| 1349 | |
| 1350 auto filter_list = GetCategoryGroupFilter(category_group_enabled); | |
| 1351 DCHECK(!filter_list->empty()); | |
| 1352 | |
| 1353 bool should_add_event = false; | |
| 1354 for (const auto& trace_event_filter : *filter_list) { | |
| 1355 if (trace_event_filter->FilterTraceEvent(*new_trace_event)) | |
| 1356 should_add_event = true; | |
| 1357 } | |
| 1358 | |
| 1359 if (should_add_event) | |
| 1360 filtered_trace_event = std::move(new_trace_event); | |
| 1361 } | |
| 1362 | |
| 1363 // Add the trace event if we're either *just* recording (and not filtering) | |
| 1364 // or if we one of our filters indicates the event should be added. | |
| 1365 if (((*category_group_enabled & ENABLED_FOR_RECORDING) && | |
| 1366 (*category_group_enabled & ENABLED_FOR_FILTERING) == 0) || | |
| 1367 filtered_trace_event) { | |
| 1275 OptionalAutoLock lock(&lock_); | 1368 OptionalAutoLock lock(&lock_); |
| 1276 | 1369 |
| 1277 TraceEvent* trace_event = NULL; | 1370 TraceEvent* trace_event = NULL; |
| 1278 if (thread_local_event_buffer) { | 1371 if (thread_local_event_buffer) { |
| 1279 trace_event = thread_local_event_buffer->AddTraceEvent(&handle); | 1372 trace_event = thread_local_event_buffer->AddTraceEvent(&handle); |
| 1280 } else { | 1373 } else { |
| 1281 lock.EnsureAcquired(); | 1374 lock.EnsureAcquired(); |
| 1282 trace_event = AddEventToThreadSharedChunkWhileLocked(&handle, true); | 1375 trace_event = AddEventToThreadSharedChunkWhileLocked(&handle, true); |
| 1283 } | 1376 } |
| 1284 | 1377 |
| 1285 if (trace_event) { | 1378 if (trace_event) { |
| 1286 trace_event->Initialize(thread_id, | 1379 if (filtered_trace_event) { |
| 1287 offset_event_timestamp, | 1380 trace_event->MoveFrom(std::move(filtered_trace_event)); |
| 1288 thread_now, | 1381 } else { |
| 1289 phase, | 1382 trace_event->Initialize(thread_id, offset_event_timestamp, thread_now, |
| 1290 category_group_enabled, | 1383 phase, category_group_enabled, name, scope, id, |
| 1291 name, | 1384 bind_id, num_args, arg_names, arg_types, |
| 1292 scope, | 1385 arg_values, convertable_values, flags); |
| 1293 id, | 1386 } |
| 1294 bind_id, | |
| 1295 num_args, | |
| 1296 arg_names, | |
| 1297 arg_types, | |
| 1298 arg_values, | |
| 1299 convertable_values, | |
| 1300 flags); | |
| 1301 | 1387 |
| 1302 #if defined(OS_ANDROID) | 1388 #if defined(OS_ANDROID) |
| 1303 trace_event->SendToATrace(); | 1389 trace_event->SendToATrace(); |
| 1304 #endif | 1390 #endif |
| 1305 } | 1391 } |
| 1306 | 1392 |
| 1307 if (trace_options() & kInternalEchoToConsole) { | 1393 if (trace_options() & kInternalEchoToConsole) { |
| 1308 console_message = EventToConsoleMessage( | 1394 console_message = EventToConsoleMessage( |
| 1309 phase == TRACE_EVENT_PHASE_COMPLETE ? TRACE_EVENT_PHASE_BEGIN : phase, | 1395 phase == TRACE_EVENT_PHASE_COMPLETE ? TRACE_EVENT_PHASE_BEGIN : phase, |
| 1310 timestamp, trace_event); | 1396 timestamp, trace_event); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1428 log << base::StringPrintf(" (%.3f ms)", duration.InMillisecondsF()); | 1514 log << base::StringPrintf(" (%.3f ms)", duration.InMillisecondsF()); |
| 1429 | 1515 |
| 1430 log << "\x1b[0;m"; | 1516 log << "\x1b[0;m"; |
| 1431 | 1517 |
| 1432 if (phase == TRACE_EVENT_PHASE_BEGIN) | 1518 if (phase == TRACE_EVENT_PHASE_BEGIN) |
| 1433 thread_event_start_times_[thread_id].push(timestamp); | 1519 thread_event_start_times_[thread_id].push(timestamp); |
| 1434 | 1520 |
| 1435 return log.str(); | 1521 return log.str(); |
| 1436 } | 1522 } |
| 1437 | 1523 |
| 1524 void TraceLog::EndFilteredEvent(const unsigned char* category_group_enabled, | |
| 1525 const char* name, | |
| 1526 TraceEventHandle handle) { | |
| 1527 auto filter_list = GetCategoryGroupFilter(category_group_enabled); | |
| 1528 DCHECK(!filter_list->empty()); | |
| 1529 | |
| 1530 for (const auto& trace_event_filter : *filter_list) { | |
| 1531 trace_event_filter->EndEvent(name, | |
| 1532 GetCategoryGroupName(category_group_enabled)); | |
| 1533 } | |
| 1534 } | |
| 1535 | |
| 1438 void TraceLog::UpdateTraceEventDuration( | 1536 void TraceLog::UpdateTraceEventDuration( |
| 1439 const unsigned char* category_group_enabled, | 1537 const unsigned char* category_group_enabled, |
| 1440 const char* name, | 1538 const char* name, |
| 1441 TraceEventHandle handle) { | 1539 TraceEventHandle handle) { |
| 1442 char category_group_enabled_local = *category_group_enabled; | 1540 char category_group_enabled_local = *category_group_enabled; |
| 1443 if (!category_group_enabled_local) | 1541 if (!category_group_enabled_local) |
| 1444 return; | 1542 return; |
| 1445 | 1543 |
| 1446 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when | 1544 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when |
| 1447 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> | 1545 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1592 void TraceLog::WaitSamplingEventForTesting() { | 1690 void TraceLog::WaitSamplingEventForTesting() { |
| 1593 if (!sampling_thread_) | 1691 if (!sampling_thread_) |
| 1594 return; | 1692 return; |
| 1595 sampling_thread_->WaitSamplingEventForTesting(); | 1693 sampling_thread_->WaitSamplingEventForTesting(); |
| 1596 } | 1694 } |
| 1597 | 1695 |
| 1598 void TraceLog::DeleteForTesting() { | 1696 void TraceLog::DeleteForTesting() { |
| 1599 internal::DeleteTraceLogForTesting::Delete(); | 1697 internal::DeleteTraceLogForTesting::Delete(); |
| 1600 } | 1698 } |
| 1601 | 1699 |
| 1700 void TraceLog::SetTraceEventFilterConstructorForTesting( | |
| 1701 TraceEventFilterConstructorForTesting predicate) { | |
| 1702 g_trace_event_filter_constructor_for_testing = predicate; | |
| 1703 } | |
| 1704 | |
| 1602 TraceEvent* TraceLog::GetEventByHandle(TraceEventHandle handle) { | 1705 TraceEvent* TraceLog::GetEventByHandle(TraceEventHandle handle) { |
| 1603 return GetEventByHandleInternal(handle, NULL); | 1706 return GetEventByHandleInternal(handle, NULL); |
| 1604 } | 1707 } |
| 1605 | 1708 |
| 1606 TraceEvent* TraceLog::GetEventByHandleInternal(TraceEventHandle handle, | 1709 TraceEvent* TraceLog::GetEventByHandleInternal(TraceEventHandle handle, |
| 1607 OptionalAutoLock* lock) { | 1710 OptionalAutoLock* lock) { |
| 1608 if (!handle.chunk_seq) | 1711 if (!handle.chunk_seq) |
| 1609 return NULL; | 1712 return NULL; |
| 1610 | 1713 |
| 1611 if (thread_local_event_buffer_.Get()) { | 1714 if (thread_local_event_buffer_.Get()) { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1779 } | 1882 } |
| 1780 | 1883 |
| 1781 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1884 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 1782 if (*category_group_enabled_) { | 1885 if (*category_group_enabled_) { |
| 1783 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1886 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
| 1784 event_handle_); | 1887 event_handle_); |
| 1785 } | 1888 } |
| 1786 } | 1889 } |
| 1787 | 1890 |
| 1788 } // namespace trace_event_internal | 1891 } // namespace trace_event_internal |
| OLD | NEW |