| 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 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 struct WhitelistEntry { | 14 struct WhitelistEntry { |
| 15 const char* category_name; | 15 const char* category_name; |
| 16 const char* event_name; | 16 const char* event_name; |
| 17 const char* const* arg_name_filter; | 17 const char* const* arg_name_filter; |
| 18 }; | 18 }; |
| 19 | 19 |
| 20 const char* const kInputLatencyAllowedArgs[] = {"data", nullptr}; | 20 const char* const kInputLatencyAllowedArgs[] = {"data", nullptr}; |
| 21 | 21 |
| 22 const WhitelistEntry kEventArgsWhitelist[] = { | 22 const WhitelistEntry kEventArgsWhitelist[] = { |
| 23 {"__metadata", "thread_name", nullptr}, | 23 {"__metadata", "thread_name", nullptr}, |
| 24 {"ipc", "SyncChannel::Send", nullptr}, | 24 {"ipc", "SyncChannel::Send", nullptr}, |
| 25 {"toplevel", "*", nullptr}, | 25 {"toplevel", "*", nullptr}, |
| 26 {"latencyInfo", "*", kInputLatencyAllowedArgs}, | 26 {"latencyInfo", "*", kInputLatencyAllowedArgs}, |
| 27 {nullptr, nullptr, nullptr}}; | 27 {nullptr, nullptr, nullptr}}; |
| 28 | 28 |
| 29 const char* kMetadataWhitelist[] = { | 29 const char* kMetadataWhitelist[] = { |
| 30 "clock-domain", |
| 30 "command_line", | 31 "command_line", |
| 31 "config", | 32 "config", |
| 32 "cpu-*", | 33 "cpu-*", |
| 33 "field-trials", | 34 "field-trials", |
| 34 "gpu-*", | 35 "gpu-*", |
| 35 "highres-ticks", | 36 "highres-ticks", |
| 36 "network-type", | 37 "network-type", |
| 37 "num-cpus", | 38 "num-cpus", |
| 38 "os-*", | 39 "os-*", |
| 39 "physical-memory", | 40 "physical-memory", |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 84 } |
| 84 | 85 |
| 85 bool IsMetadataWhitelisted(const std::string& metadata_name) { | 86 bool IsMetadataWhitelisted(const std::string& metadata_name) { |
| 86 for (auto key : kMetadataWhitelist) { | 87 for (auto key : kMetadataWhitelist) { |
| 87 if (base::MatchPattern(metadata_name, key)) { | 88 if (base::MatchPattern(metadata_name, key)) { |
| 88 return true; | 89 return true; |
| 89 } | 90 } |
| 90 } | 91 } |
| 91 return false; | 92 return false; |
| 92 } | 93 } |
| OLD | NEW |