| 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 "chrome/common/trace_event_args_whitelist.h" | 5 #include "chrome/common/trace_event_args_whitelist.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/pattern.h" | 8 #include "base/strings/pattern.h" |
| 9 #include "base/strings/string_tokenizer.h" | 9 #include "base/strings/string_tokenizer.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 struct WhitelistEntry { | 15 struct WhitelistEntry { |
| 16 const char* category_name; | 16 const char* category_name; |
| 17 const char* event_name; | 17 const char* event_name; |
| 18 const char* const* arg_name_filter; | 18 const char* const* arg_name_filter; |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 const char* const kInputLatencyAllowedArgs[] = {"data", nullptr}; | 21 const char* const kInputLatencyAllowedArgs[] = {"data", nullptr}; |
| 22 const char* const kMemoryDumpAllowedArgs[] = {"dumps", nullptr}; | 22 const char* const kMemoryDumpAllowedArgs[] = {"dumps", nullptr}; |
| 23 | 23 |
| 24 const WhitelistEntry kEventArgsWhitelist[] = { | 24 const WhitelistEntry kEventArgsWhitelist[] = { |
| 25 {"__metadata", "thread_name", nullptr}, | 25 {"__metadata", "thread_name", nullptr}, |
| 26 {"__metadata", "process_name", nullptr}, | 26 {"__metadata", "process_name", nullptr}, |
| 27 {"__metadata", "process_runtime_sec", nullptr}, | |
| 28 {"ipc", "SyncChannel::Send", nullptr}, | 27 {"ipc", "SyncChannel::Send", nullptr}, |
| 29 {"toplevel", "*", nullptr}, | 28 {"toplevel", "*", nullptr}, |
| 30 {"latencyInfo", "*", kInputLatencyAllowedArgs}, | 29 {"latencyInfo", "*", kInputLatencyAllowedArgs}, |
| 31 // Redefined the string since MemoryDumpManager::kTraceCategory causes | 30 // Redefined the string since MemoryDumpManager::kTraceCategory causes |
| 32 // static initialization of this struct. | 31 // static initialization of this struct. |
| 33 {TRACE_DISABLED_BY_DEFAULT("memory-infra"), "*", kMemoryDumpAllowedArgs}, | 32 {TRACE_DISABLED_BY_DEFAULT("memory-infra"), "*", kMemoryDumpAllowedArgs}, |
| 34 {nullptr, nullptr, nullptr}}; | 33 {nullptr, nullptr, nullptr}}; |
| 35 | 34 |
| 36 const char* kMetadataWhitelist[] = { | 35 const char* kMetadataWhitelist[] = { |
| 37 "clock-domain", | 36 "clock-domain", |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 90 } |
| 92 | 91 |
| 93 bool IsMetadataWhitelisted(const std::string& metadata_name) { | 92 bool IsMetadataWhitelisted(const std::string& metadata_name) { |
| 94 for (auto* key : kMetadataWhitelist) { | 93 for (auto* key : kMetadataWhitelist) { |
| 95 if (base::MatchPattern(metadata_name, key)) { | 94 if (base::MatchPattern(metadata_name, key)) { |
| 96 return true; | 95 return true; |
| 97 } | 96 } |
| 98 } | 97 } |
| 99 return false; | 98 return false; |
| 100 } | 99 } |
| OLD | NEW |