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

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

Issue 1089973002: Clean up and unify IsBoringSwitch(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix compile Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/crash_keys.h" 5 #include "chrome/common/crash_keys.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/common/chrome_switches.h"
15 #include "content/public/common/content_switches.h"
16 #include "ipc/ipc_switches.h"
14 17
15 #if defined(OS_MACOSX) 18 #if defined(OS_MACOSX)
16 #include "breakpad/src/common/simple_string_dictionary.h" 19 #include "breakpad/src/common/simple_string_dictionary.h"
17 #elif defined(OS_WIN) 20 #elif defined(OS_WIN)
18 #include "breakpad/src/client/windows/common/ipc_protocol.h" 21 #include "breakpad/src/client/windows/common/ipc_protocol.h"
19 #elif defined(OS_CHROMEOS) 22 #elif defined(OS_CHROMEOS)
20 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
21 #include "gpu/command_buffer/service/gpu_switches.h" 24 #include "gpu/command_buffer/service/gpu_switches.h"
22 #include "ui/gl/gl_switches.h" 25 #include "ui/gl/gl_switches.h"
23 #endif 26 #endif
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // 277 //
275 // Breakpad cannot be enabled or disabled without an application restart, and 278 // Breakpad cannot be enabled or disabled without an application restart, and
276 // it needs to use the metrics client ID as its stable crash client ID, so 279 // it needs to use the metrics client ID as its stable crash client ID, so
277 // leave its client ID intact even when metrics reporting is disabled while 280 // leave its client ID intact even when metrics reporting is disabled while
278 // the application is running. 281 // the application is running.
279 base::debug::ClearCrashKey(kMetricsClientId); 282 base::debug::ClearCrashKey(kMetricsClientId);
280 #endif 283 #endif
281 } 284 }
282 285
283 static bool IsBoringSwitch(const std::string& flag) { 286 static bool IsBoringSwitch(const std::string& flag) {
287 static const char* const kIgnoreSwitches[] = {
288 switches::kEnableLogging,
289 switches::kFlagSwitchesBegin,
290 switches::kFlagSwitchesEnd,
291 switches::kLoggingLevel,
284 #if defined(OS_WIN) 292 #if defined(OS_WIN)
285 return StartsWithASCII(flag, "--channel=", true) || 293 // This file is linked into both chrome.dll and chrome.exe. However //ipc
286 294 // is only in the .dll, so this needs to be a literal rather than the
287 // No point to including this since we already have a ptype field. 295 // constant.
288 StartsWithASCII(flag, "--type=", true) || 296 "channel",
Lei Zhang 2015/04/16 22:02:30 Can you mention this is suppose to be switches::kP
Robert Sesek 2015/04/17 20:12:55 I thought it was clear from the #if/#else, but don
289 297 #else
290 // Not particularly interesting 298 switches::kProcessChannelID,
291 StartsWithASCII(flag, "--flash-broker=", true) || 299 #endif
292 300 switches::kProcessType,
293 // Just about everything has this, don't bother. 301 switches::kV,
294 StartsWithASCII(flag, "/prefetch:", true) || 302 switches::kVModule,
295 303 #if defined(OS_WIN)
296 // We handle the plugin path separately since it is usually too big 304 switches::kForceFieldTrials,
297 // to fit in the switches (limited to 63 characters). 305 switches::kPluginPath,
298 StartsWithASCII(flag, "--plugin-path=", true) ||
299
300 // This is too big so we end up truncating it anyway.
301 StartsWithASCII(flag, "--force-fieldtrials=", true) ||
302
303 // These surround the flags that were added by about:flags, it lets
304 // you distinguish which flags were added manually via the command
305 // line versus those added through about:flags. For the most part
306 // we don't care how an option was enabled, so we strip these.
307 // (If you need to know can always look at the PEB).
308 flag == "--flag-switches-begin" ||
309 flag == "--flag-switches-end";
310 #elif defined(OS_MACOSX) 306 #elif defined(OS_MACOSX)
311 // These are carried in their own fields. 307 switches::kMetricsClientID,
312 return StartsWithASCII(flag, "--channel=", true) ||
313 StartsWithASCII(flag, "--type=", true) ||
314 StartsWithASCII(flag, "--metrics-client-id=", true);
315 #elif defined(OS_CHROMEOS) 308 #elif defined(OS_CHROMEOS)
316 static const char* const kIgnoreSwitches[] = { 309 switches::kPpapiFlashArgs,
317 ::switches::kEnableLogging, 310 switches::kPpapiFlashPath,
318 ::switches::kFlagSwitchesBegin, 311 switches::kRegisterPepperPlugins,
319 ::switches::kFlagSwitchesEnd, 312 switches::kUIPrioritizeInGpuProcess,
320 ::switches::kLoggingLevel, 313 switches::kUseGL,
321 ::switches::kPpapiFlashArgs, 314 switches::kUserDataDir,
322 ::switches::kPpapiFlashPath,
323 ::switches::kRegisterPepperPlugins,
324 ::switches::kUIPrioritizeInGpuProcess,
325 ::switches::kUseGL,
326 ::switches::kUserDataDir,
327 ::switches::kV,
328 ::switches::kVModule,
329 // Cros/CC flgas are specified as raw strings to avoid dependency. 315 // Cros/CC flgas are specified as raw strings to avoid dependency.
330 "child-wallpaper-large", 316 "child-wallpaper-large",
331 "child-wallpaper-small", 317 "child-wallpaper-small",
332 "default-wallpaper-large", 318 "default-wallpaper-large",
333 "default-wallpaper-small", 319 "default-wallpaper-small",
334 "guest-wallpaper-large", 320 "guest-wallpaper-large",
335 "guest-wallpaper-small", 321 "guest-wallpaper-small",
336 "enterprise-enable-forced-re-enrollment", 322 "enterprise-enable-forced-re-enrollment",
337 "enterprise-enrollment-initial-modulus", 323 "enterprise-enrollment-initial-modulus",
338 "enterprise-enrollment-modulus-limit", 324 "enterprise-enrollment-modulus-limit",
339 "login-profile", 325 "login-profile",
340 "login-user", 326 "login-user",
341 "max-tiles-for-interest-area", 327 "max-tiles-for-interest-area",
342 "max-unused-resource-memory-usage-percentage", 328 "max-unused-resource-memory-usage-percentage",
343 "termination-message-file", 329 "termination-message-file",
344 "use-cras", 330 "use-cras",
331 #endif
345 }; 332 };
333
334 #if defined(OS_WIN)
335 // Just about everything has this, don't bother.
336 if (StartsWithASCII(flag, "/prefetch:", true))
337 return true;
338 #endif
339
346 if (!StartsWithASCII(flag, "--", true)) 340 if (!StartsWithASCII(flag, "--", true))
347 return false; 341 return false;
348 std::size_t end = flag.find("="); 342 size_t end = flag.find("=");
349 int len = (end == std::string::npos) ? flag.length() - 2 : end - 2; 343 size_t len = (end == std::string::npos) ? flag.length() - 2 : end - 2;
350 for (size_t i = 0; i < arraysize(kIgnoreSwitches); ++i) { 344 for (size_t i = 0; i < arraysize(kIgnoreSwitches); ++i) {
351 if (flag.compare(2, len, kIgnoreSwitches[i]) == 0) 345 if (flag.compare(2, len, kIgnoreSwitches[i]) == 0)
352 return true; 346 return true;
353 } 347 }
354 return false; 348 return false;
355 #else
356 return false;
357 #endif
358 } 349 }
359 350
360 void SetSwitchesFromCommandLine(const base::CommandLine* command_line) { 351 void SetSwitchesFromCommandLine(const base::CommandLine* command_line) {
361 DCHECK(command_line); 352 DCHECK(command_line);
362 if (!command_line) 353 if (!command_line)
363 return; 354 return;
364 355
365 const base::CommandLine::StringVector& argv = command_line->argv(); 356 const base::CommandLine::StringVector& argv = command_line->argv();
366 357
367 // Set the number of switches in case size > kNumSwitches. 358 // Set the number of switches in case size > kNumSwitches.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } 435 }
445 436
446 ScopedPrinterInfo::~ScopedPrinterInfo() { 437 ScopedPrinterInfo::~ScopedPrinterInfo() {
447 for (size_t i = 0; i < kPrinterInfoCount; ++i) { 438 for (size_t i = 0; i < kPrinterInfoCount; ++i) {
448 std::string key = base::StringPrintf(kPrinterInfo, i + 1); 439 std::string key = base::StringPrintf(kPrinterInfo, i + 1);
449 base::debug::ClearCrashKey(key); 440 base::debug::ClearCrashKey(key);
450 } 441 }
451 } 442 }
452 443
453 } // namespace crash_keys 444 } // namespace crash_keys
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698