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

Unified Diff: chrome/common/crash_keys.cc

Issue 1481933002: Move crash keys for command-line switches to components/crash so they can be set (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@installer_crash_keys
Patch Set: typedef -> using, %lu -> PRIuS Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/crash_keys.h ('k') | chrome/common/crash_keys_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/crash_keys.cc
diff --git a/chrome/common/crash_keys.cc b/chrome/common/crash_keys.cc
index ad3fb135c2b3e638405ce84b3700a00878f07904..1270492c123f68b8daa8f114bf3e433e790db5dd 100644
--- a/chrome/common/crash_keys.cc
+++ b/chrome/common/crash_keys.cc
@@ -11,7 +11,6 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
-#include "base/strings/utf_string_conversions.h"
#include "chrome/common/chrome_switches.h"
#include "components/flags_ui/flags_ui_switches.h"
#include "content/public/common/content_switches.h"
@@ -29,9 +28,6 @@ const char kActiveURL[] = "url-chunk";
const char kFontKeyName[] = "font_key_name";
-const char kSwitch[] = "switch-%" PRIuS;
-const char kNumSwitches[] = "num-switches";
-
const char kExtensionID[] = "extension-%" PRIuS;
const char kNumExtensionsCount[] = "num-extensions";
@@ -94,7 +90,6 @@ size_t RegisterChromeCrashKeys() {
#endif
{ kChannel, kSmallSize },
{ kActiveURL, kLargeSize },
- { kNumSwitches, kSmallSize },
{ kNumVariations, kSmallSize },
{ kVariations, kLargeSize },
{ kNumExtensionsCount, kSmallSize },
@@ -154,23 +149,7 @@ size_t RegisterChromeCrashKeys() {
std::vector<base::debug::CrashKey> keys(
fixed_keys, fixed_keys + arraysize(fixed_keys));
- // Register the switches.
- {
- // The fixed_keys names are string constants. Use static storage for
- // formatted key names as well, since they will persist for the duration of
- // the program.
- static char formatted_keys[kSwitchesMaxCount][sizeof(kSwitch) + 1] =
- {{ 0 }};
- const size_t formatted_key_len = sizeof(formatted_keys[0]);
- for (size_t i = 0; i < kSwitchesMaxCount; ++i) {
- // Name the keys using 1-based indexing.
- int n = base::snprintf(
- formatted_keys[i], formatted_key_len, kSwitch, i + 1);
- DCHECK_GT(n, 0);
- base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize };
- keys.push_back(crash_key);
- }
- }
+ crash_keys::GetCrashKeysForCommandLineSwitches(&keys);
// Register the extension IDs.
{
@@ -268,43 +247,8 @@ static bool IsBoringSwitch(const std::string& flag) {
return false;
}
-void SetSwitchesFromCommandLine(const base::CommandLine* command_line) {
- DCHECK(command_line);
- if (!command_line)
- return;
-
- const base::CommandLine::StringVector& argv = command_line->argv();
-
- // Set the number of switches in case size > kNumSwitches.
- base::debug::SetCrashKeyValue(kNumSwitches,
- base::StringPrintf("%" PRIuS, argv.size() - 1));
-
- size_t key_i = 1; // Key names are 1-indexed.
-
- // Go through the argv, skipping the exec path.
- for (size_t i = 1; i < argv.size(); ++i) {
-#if defined(OS_WIN)
- std::string switch_str = base::WideToUTF8(argv[i]);
-#else
- std::string switch_str = argv[i];
-#endif
-
- // Skip uninteresting switches.
- if (IsBoringSwitch(switch_str))
- continue;
-
- // Stop if there are too many switches.
- if (i > crash_keys::kSwitchesMaxCount)
- break;
-
- std::string key = base::StringPrintf(kSwitch, key_i++);
- base::debug::SetCrashKeyValue(key, switch_str);
- }
-
- // Clear any remaining switches.
- for (; key_i <= kSwitchesMaxCount; ++key_i) {
- base::debug::ClearCrashKey(base::StringPrintf(kSwitch, key_i));
- }
+void SetCrashKeysFromCommandLine(const base::CommandLine& command_line) {
+ return SetSwitchesFromCommandLine(command_line, &IsBoringSwitch);
}
void SetActiveExtensions(const std::set<std::string>& extensions) {
« no previous file with comments | « chrome/common/crash_keys.h ('k') | chrome/common/crash_keys_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698