OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/memory_infra_background_whitelist.h" | 5 #include "base/trace_event/memory_infra_background_whitelist.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/strings/string_util.h" | |
13 | |
12 namespace base { | 14 namespace base { |
13 namespace trace_event { | 15 namespace trace_event { |
14 namespace { | 16 namespace { |
15 | 17 |
16 // The names of dump providers whitelisted for background tracing. Dump | 18 // The names of dump providers whitelisted for background tracing. Dump |
17 // providers can be added here only if the background mode dump has very | 19 // providers can be added here only if the background mode dump has very |
18 // less performance and memory overhead. | 20 // less performance and memory overhead. |
19 const char* const kDumpProviderWhitelist[] = { | 21 const char* const kDumpProviderWhitelist[] = { |
20 "android::ResourceManagerImpl", | 22 "android::ResourceManagerImpl", |
21 "BlinkGC", | 23 "BlinkGC", |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 "malloc", | 64 "malloc", |
63 "malloc/allocated_objects", | 65 "malloc/allocated_objects", |
64 "malloc/metadata_fragmentation_caches", | 66 "malloc/metadata_fragmentation_caches", |
65 "net/http_network_session_0x?", | 67 "net/http_network_session_0x?", |
66 "net/http_network_session_0x?/quic_stream_factory", | 68 "net/http_network_session_0x?/quic_stream_factory", |
67 "net/http_network_session_0x?/socket_pool", | 69 "net/http_network_session_0x?/socket_pool", |
68 "net/http_network_session_0x?/spdy_session_pool", | 70 "net/http_network_session_0x?/spdy_session_pool", |
69 "net/http_network_session_0x?/stream_factory", | 71 "net/http_network_session_0x?/stream_factory", |
70 "net/sdch_manager_0x?", | 72 "net/sdch_manager_0x?", |
71 "net/ssl_session_cache", | 73 "net/ssl_session_cache", |
72 "net/url_request_context_0x?", | 74 "net/url_request_context", |
73 "net/url_request_context_0x?/http_cache", | 75 "net/url_request_context/%s", |
74 "net/url_request_context_0x?/http_network_session", | 76 "net/url_request_context/%s/0x?", |
ssid
2017/03/27 18:43:15
I'd say just add all the strings here instead of s
xunjieli
2017/03/27 19:24:55
Done. Though it feels a bit verbose to list all th
ssid
2017/03/27 20:15:11
Ahh, sorry I see why you did this now. I thought i
xunjieli
2017/03/27 20:27:14
Done.
| |
75 "net/url_request_context_0x?/sdch_manager", | 77 "net/url_request_context/%s/0x?/http_cache", |
78 "net/url_request_context/%s/0x?/http_network_session", | |
79 "net/url_request_context/%s/0x?/sdch_manager", | |
76 "web_cache/Image_resources", | 80 "web_cache/Image_resources", |
77 "web_cache/CSS stylesheet_resources", | 81 "web_cache/CSS stylesheet_resources", |
78 "web_cache/Script_resources", | 82 "web_cache/Script_resources", |
79 "web_cache/XSL stylesheet_resources", | 83 "web_cache/XSL stylesheet_resources", |
80 "web_cache/Font_resources", | 84 "web_cache/Font_resources", |
81 "web_cache/Other_resources", | 85 "web_cache/Other_resources", |
82 "partition_alloc/allocated_objects", | 86 "partition_alloc/allocated_objects", |
83 "partition_alloc/partitions", | 87 "partition_alloc/partitions", |
84 "partition_alloc/partitions/array_buffer", | 88 "partition_alloc/partitions/array_buffer", |
85 "partition_alloc/partitions/buffer", | 89 "partition_alloc/partitions/buffer", |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 parsing_hex = false; | 175 parsing_hex = false; |
172 if (i + 1 < length && name[i] == '0' && name[i + 1] == 'x') { | 176 if (i + 1 < length && name[i] == '0' && name[i + 1] == 'x') { |
173 parsing_hex = true; | 177 parsing_hex = true; |
174 stripped_str.append("0x?"); | 178 stripped_str.append("0x?"); |
175 ++i; | 179 ++i; |
176 } else { | 180 } else { |
177 stripped_str.push_back(name[i]); | 181 stripped_str.push_back(name[i]); |
178 } | 182 } |
179 } | 183 } |
180 | 184 |
185 std::string url_request_context_prefix = "url_request_context/"; | |
186 size_t pos = stripped_str.find(url_request_context_prefix); | |
187 if (pos != std::string::npos) { | |
188 const std::string names[] = {"system", "proxy", "app_request", | |
ssid
2017/03/27 20:26:02
nit: /s/std::string/const char* const/
s/names/kRe
xunjieli
2017/03/28 01:04:56
Done.
| |
189 "main", "extensions", "safe_browsing", | |
190 "unknown"}; | |
191 for (const auto& name : names) { | |
192 base::ReplaceSubstringsAfterOffset( | |
193 &stripped_str, pos + url_request_context_prefix.length(), name, "%s"); | |
194 } | |
195 } | |
196 | |
181 for (size_t i = 0; g_allocator_dump_name_whitelist[i] != nullptr; ++i) { | 197 for (size_t i = 0; g_allocator_dump_name_whitelist[i] != nullptr; ++i) { |
182 if (stripped_str == g_allocator_dump_name_whitelist[i]) { | 198 if (stripped_str == g_allocator_dump_name_whitelist[i]) { |
183 return true; | 199 return true; |
184 } | 200 } |
185 } | 201 } |
186 return false; | 202 return false; |
187 } | 203 } |
188 | 204 |
189 void SetDumpProviderWhitelistForTesting(const char* const* list) { | 205 void SetDumpProviderWhitelistForTesting(const char* const* list) { |
190 g_dump_provider_whitelist = list; | 206 g_dump_provider_whitelist = list; |
191 } | 207 } |
192 | 208 |
193 void SetAllocatorDumpNameWhitelistForTesting(const char* const* list) { | 209 void SetAllocatorDumpNameWhitelistForTesting(const char* const* list) { |
194 g_allocator_dump_name_whitelist = list; | 210 g_allocator_dump_name_whitelist = list; |
195 } | 211 } |
196 | 212 |
197 } // namespace trace_event | 213 } // namespace trace_event |
198 } // namespace base | 214 } // namespace base |
OLD | NEW |