Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: chrome/common/trace_event_args_whitelist.cc

Issue 1502583003: [Tracing] Add metadata filter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile failure on win Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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", "ChannelProxy::Context::OnDispatchMessage", nullptr}, 24 {"ipc", "ChannelProxy::Context::OnDispatchMessage", nullptr},
25 {"ipc", "SyncChannel::Send", nullptr}, 25 {"ipc", "SyncChannel::Send", nullptr},
26 {"toplevel", "*", nullptr}, 26 {"toplevel", "*", nullptr},
27 {"latencyInfo", "*", kInputLatencyAllowedArgs}, 27 {"latencyInfo", "*", kInputLatencyAllowedArgs},
28 {nullptr, nullptr, nullptr}}; 28 {nullptr, nullptr, nullptr}};
29 29
30 const char* kMetadataWhitelist[] = {
31 "command_line",
32 "cpu-*",
33 "field-trials",
34 "gpu-*",
35 "highres-ticks",
36 "network-type",
37 "num-cpus",
38 "os-*",
39 "physical-memory",
40 "product-version",
41 "user-agent"
42 };
43
30 } // namespace 44 } // namespace
31 45
32 bool IsTraceArgumentNameWhitelisted(const char* const* granular_filter, 46 bool IsTraceArgumentNameWhitelisted(const char* const* granular_filter,
33 const char* arg_name) { 47 const char* arg_name) {
34 for (int i = 0; granular_filter[i] != nullptr; ++i) { 48 for (int i = 0; granular_filter[i] != nullptr; ++i) {
35 if (base::MatchPattern(arg_name, granular_filter[i])) 49 if (base::MatchPattern(arg_name, granular_filter[i]))
36 return true; 50 return true;
37 } 51 }
38 52
39 return false; 53 return false;
(...skipping 20 matching lines...) Expand all
60 *arg_name_filter = base::Bind(&IsTraceArgumentNameWhitelisted, 74 *arg_name_filter = base::Bind(&IsTraceArgumentNameWhitelisted,
61 whitelist_entry.arg_name_filter); 75 whitelist_entry.arg_name_filter);
62 } 76 }
63 return true; 77 return true;
64 } 78 }
65 } 79 }
66 } 80 }
67 81
68 return false; 82 return false;
69 } 83 }
84
85 bool IsMetadataWhitelisted(const std::string& metadata_name) {
86 for (auto key : kMetadataWhitelist) {
87 if (base::MatchPattern(metadata_name, key)) {
88 return true;
89 }
90 }
91 return false;
92 }
OLDNEW
« no previous file with comments | « chrome/common/trace_event_args_whitelist.h ('k') | content/browser/tracing/tracing_controller_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698