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

Side by Side Diff: base/trace_event/memory_infra_background_whitelist.cc

Issue 2876543002: memory-infra: Don't invoke all dump providers in SUMMARY_ONLY mode (Closed)
Patch Set: address comments Created 3 years, 7 months 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 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>
(...skipping 22 matching lines...) Expand all
33 "Skia", 33 "Skia",
34 "Sql", 34 "Sql",
35 "URLRequestContext", 35 "URLRequestContext",
36 "V8Isolate", 36 "V8Isolate",
37 "WinHeap", 37 "WinHeap",
38 "SyncDirectory", 38 "SyncDirectory",
39 "TabRestoreServiceHelper", 39 "TabRestoreServiceHelper",
40 nullptr // End of list marker. 40 nullptr // End of list marker.
41 }; 41 };
42 42
43 // The names of dump providers whitelisted for summary tracing.
44 const char* const kDumpProviderSummaryWhitelist[] = {
45 "Malloc", "PartitionAlloc", "ProcessMemoryMetrics", "V8Isolate",
46 nullptr // End of list marker.
47 };
48
43 // A list of string names that are allowed for the memory allocator dumps in 49 // A list of string names that are allowed for the memory allocator dumps in
44 // background mode. 50 // background mode.
45 const char* const kAllocatorDumpNameWhitelist[] = { 51 const char* const kAllocatorDumpNameWhitelist[] = {
46 "blink_gc", 52 "blink_gc",
47 "blink_gc/allocated_objects", 53 "blink_gc/allocated_objects",
48 "discardable", 54 "discardable",
49 "discardable/child_0x?", 55 "discardable/child_0x?",
50 "dom_storage/0x?/cache_size", 56 "dom_storage/0x?/cache_size",
51 "dom_storage/session_storage_0x?", 57 "dom_storage/session_storage_0x?",
52 "java_heap", 58 "java_heap",
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 "sync/0x?/model_type/TYPED_URL", 204 "sync/0x?/model_type/TYPED_URL",
199 "sync/0x?/model_type/WALLET_METADATA", 205 "sync/0x?/model_type/WALLET_METADATA",
200 "sync/0x?/model_type/WIFI_CREDENTIAL", 206 "sync/0x?/model_type/WIFI_CREDENTIAL",
201 "tab_restore/service_helper_0x?/entries", 207 "tab_restore/service_helper_0x?/entries",
202 "tab_restore/service_helper_0x?/entries/tab_0x?", 208 "tab_restore/service_helper_0x?/entries/tab_0x?",
203 "tab_restore/service_helper_0x?/entries/window_0x?", 209 "tab_restore/service_helper_0x?/entries/window_0x?",
204 nullptr // End of list marker. 210 nullptr // End of list marker.
205 }; 211 };
206 212
207 const char* const* g_dump_provider_whitelist = kDumpProviderWhitelist; 213 const char* const* g_dump_provider_whitelist = kDumpProviderWhitelist;
214 const char* const* g_dump_provider_whitelist_for_summary =
215 kDumpProviderSummaryWhitelist;
208 const char* const* g_allocator_dump_name_whitelist = 216 const char* const* g_allocator_dump_name_whitelist =
209 kAllocatorDumpNameWhitelist; 217 kAllocatorDumpNameWhitelist;
210 218
211 } // namespace 219 bool IsMemoryDumpProviderInList(const char* mdp_name, const char* const* list) {
212 220 for (size_t i = 0; list[i] != nullptr; ++i) {
213 bool IsMemoryDumpProviderWhitelisted(const char* mdp_name) { 221 if (strcmp(mdp_name, list[i]) == 0)
214 for (size_t i = 0; g_dump_provider_whitelist[i] != nullptr; ++i) {
215 if (strcmp(mdp_name, g_dump_provider_whitelist[i]) == 0)
216 return true; 222 return true;
217 } 223 }
218 return false; 224 return false;
219 } 225 }
220 226
227 } // namespace
228
229 bool IsMemoryDumpProviderWhitelisted(const char* mdp_name) {
230 return IsMemoryDumpProviderInList(mdp_name, g_dump_provider_whitelist);
231 }
232
233 bool IsMemoryDumpProviderWhitelistedForSummary(const char* mdp_name) {
234 return IsMemoryDumpProviderInList(mdp_name,
235 g_dump_provider_whitelist_for_summary);
236 }
237
221 bool IsMemoryAllocatorDumpNameWhitelisted(const std::string& name) { 238 bool IsMemoryAllocatorDumpNameWhitelisted(const std::string& name) {
222 // Remove special characters, numbers (including hexadecimal which are marked 239 // Remove special characters, numbers (including hexadecimal which are marked
223 // by '0x') from the given string. 240 // by '0x') from the given string.
224 const size_t length = name.size(); 241 const size_t length = name.size();
225 std::string stripped_str; 242 std::string stripped_str;
226 stripped_str.reserve(length); 243 stripped_str.reserve(length);
227 bool parsing_hex = false; 244 bool parsing_hex = false;
228 for (size_t i = 0; i < length; ++i) { 245 for (size_t i = 0; i < length; ++i) {
229 if (parsing_hex && isxdigit(name[i])) 246 if (parsing_hex && isxdigit(name[i]))
230 continue; 247 continue;
(...skipping 12 matching lines...) Expand all
243 return true; 260 return true;
244 } 261 }
245 } 262 }
246 return false; 263 return false;
247 } 264 }
248 265
249 void SetDumpProviderWhitelistForTesting(const char* const* list) { 266 void SetDumpProviderWhitelistForTesting(const char* const* list) {
250 g_dump_provider_whitelist = list; 267 g_dump_provider_whitelist = list;
251 } 268 }
252 269
270 void SetDumpProviderSummaryWhitelistForTesting(const char* const* list) {
271 g_dump_provider_whitelist_for_summary = list;
272 }
273
253 void SetAllocatorDumpNameWhitelistForTesting(const char* const* list) { 274 void SetAllocatorDumpNameWhitelistForTesting(const char* const* list) {
254 g_allocator_dump_name_whitelist = list; 275 g_allocator_dump_name_whitelist = list;
255 } 276 }
256 277
257 } // namespace trace_event 278 } // namespace trace_event
258 } // namespace base 279 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/memory_infra_background_whitelist.h ('k') | base/trace_event/memory_peak_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698