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_event_etw_export_win.h" | 5 #include "base/trace_event/trace_event_etw_export_win.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 void TraceEventETWExport::AddCompleteEndEvent(const char* name) { | 341 void TraceEventETWExport::AddCompleteEndEvent(const char* name) { |
342 auto* instance = GetInstance(); | 342 auto* instance = GetInstance(); |
343 if (!instance || !instance->etw_export_enabled_ || !EventEnabledChromeEvent()) | 343 if (!instance || !instance->etw_export_enabled_ || !EventEnabledChromeEvent()) |
344 return; | 344 return; |
345 | 345 |
346 EventWriteChromeEvent(name, "Complete End", "", "", "", "", "", ""); | 346 EventWriteChromeEvent(name, "Complete End", "", "", "", "", "", ""); |
347 } | 347 } |
348 | 348 |
349 // static | 349 // static |
350 bool TraceEventETWExport::IsCategoryGroupEnabled( | 350 bool TraceEventETWExport::IsCategoryGroupEnabled( |
351 StringPiece category_group_name) { | 351 const char* category_group_name) { |
352 DCHECK(!category_group_name.empty()); | 352 DCHECK(category_group_name); |
353 auto* instance = GetInstance(); | 353 auto* instance = GetInstance(); |
354 if (instance == nullptr) | 354 if (instance == nullptr) |
355 return false; | 355 return false; |
356 | 356 |
357 if (!instance->IsETWExportEnabled()) | 357 if (!instance->IsETWExportEnabled()) |
358 return false; | 358 return false; |
359 | 359 |
360 CStringTokenizer category_group_tokens(category_group_name.begin(), | 360 CStringTokenizer category_group_tokens( |
361 category_group_name.end(), ","); | 361 category_group_name, category_group_name + strlen(category_group_name), |
| 362 ","); |
362 while (category_group_tokens.GetNext()) { | 363 while (category_group_tokens.GetNext()) { |
363 StringPiece category_group_token = category_group_tokens.token_piece(); | 364 std::string category_group_token = category_group_tokens.token(); |
364 if (instance->IsCategoryEnabled(category_group_token)) { | 365 if (instance->IsCategoryEnabled(category_group_token.c_str())) { |
365 return true; | 366 return true; |
366 } | 367 } |
367 } | 368 } |
368 return false; | 369 return false; |
369 } | 370 } |
370 | 371 |
371 bool TraceEventETWExport::UpdateEnabledCategories() { | 372 bool TraceEventETWExport::UpdateEnabledCategories() { |
372 if (etw_match_any_keyword_ == CHROME_Context.MatchAnyKeyword) | 373 if (etw_match_any_keyword_ == CHROME_Context.MatchAnyKeyword) |
373 return false; | 374 return false; |
374 | 375 |
(...skipping 23 matching lines...) Expand all Loading... |
398 } | 399 } |
399 | 400 |
400 DCHECK_EQ(kNumberOfCategories, categories_status_.size()); | 401 DCHECK_EQ(kNumberOfCategories, categories_status_.size()); |
401 | 402 |
402 // Update the categories in TraceLog. | 403 // Update the categories in TraceLog. |
403 TraceLog::GetInstance()->UpdateETWCategoryGroupEnabledFlags(); | 404 TraceLog::GetInstance()->UpdateETWCategoryGroupEnabledFlags(); |
404 | 405 |
405 return true; | 406 return true; |
406 } | 407 } |
407 | 408 |
408 bool TraceEventETWExport::IsCategoryEnabled(StringPiece category_name) const { | 409 bool TraceEventETWExport::IsCategoryEnabled(const char* category_name) const { |
409 DCHECK_EQ(kNumberOfCategories, categories_status_.size()); | 410 DCHECK_EQ(kNumberOfCategories, categories_status_.size()); |
410 // Try to find the category and return its status if found | 411 // Try to find the category and return its status if found |
411 auto it = categories_status_.find(category_name); | 412 auto it = categories_status_.find(category_name); |
412 if (it != categories_status_.end()) | 413 if (it != categories_status_.end()) |
413 return it->second; | 414 return it->second; |
414 | 415 |
415 // Otherwise return the corresponding default status by first checking if the | 416 // Otherwise return the corresponding default status by first checking if the |
416 // category is disabled by default. | 417 // category is disabled by default. |
417 if (category_name.starts_with("disabled-by-default")) { | 418 if (StringPiece(category_name).starts_with("disabled-by-default")) { |
418 DCHECK(categories_status_.find(kDisabledOtherEventsGroupName) != | 419 DCHECK(categories_status_.find(kDisabledOtherEventsGroupName) != |
419 categories_status_.end()); | 420 categories_status_.end()); |
420 return categories_status_.find(kDisabledOtherEventsGroupName)->second; | 421 return categories_status_.find(kDisabledOtherEventsGroupName)->second; |
421 } else { | 422 } else { |
422 DCHECK(categories_status_.find(kOtherEventsGroupName) != | 423 DCHECK(categories_status_.find(kOtherEventsGroupName) != |
423 categories_status_.end()); | 424 categories_status_.end()); |
424 return categories_status_.find(kOtherEventsGroupName)->second; | 425 return categories_status_.find(kOtherEventsGroupName)->second; |
425 } | 426 } |
426 } | 427 } |
427 | 428 |
428 // static | 429 // static |
429 void TraceEventETWExport::UpdateETWKeyword() { | 430 void TraceEventETWExport::UpdateETWKeyword() { |
430 if (!IsETWExportEnabled()) | 431 if (!IsETWExportEnabled()) |
431 return; | 432 return; |
432 auto* instance = GetInstance(); | 433 auto* instance = GetInstance(); |
433 DCHECK(instance); | 434 DCHECK(instance); |
434 instance->UpdateEnabledCategories(); | 435 instance->UpdateEnabledCategories(); |
435 } | 436 } |
436 } // namespace trace_event | 437 } // namespace trace_event |
437 } // namespace base | 438 } // namespace base |
OLD | NEW |