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

Unified Diff: chrome/app/chrome_crash_reporter_client_win.cc

Issue 2053953002: Add chrome_crash_reporter_client_win.cc to the source file list for chrome_elf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/app/chrome_crash_reporter_client_win.h ('k') | chrome/install_static/install_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/chrome_crash_reporter_client_win.cc
diff --git a/chrome/app/chrome_crash_reporter_client_win.cc b/chrome/app/chrome_crash_reporter_client_win.cc
index 6cd77d62cb9bd13497d0ffc52ee761cc416d05ce..42e2093efa73d2506a45a87d0b89b2b4cc974dc0 100644
--- a/chrome/app/chrome_crash_reporter_client_win.cc
+++ b/chrome/app/chrome_crash_reporter_client_win.cc
@@ -8,19 +8,199 @@
#include <assert.h>
#include <windows.h>
-
+#include <shellapi.h>
#include <memory>
#include <string>
-#include "build/build_config.h"
+#include "base/command_line.h"
+#include "base/debug/crash_logging.h"
+#include "base/debug/leak_annotations.h"
+#include "base/format_macros.h"
#include "chrome/common/chrome_result_codes.h"
-#include "chrome/common/crash_keys.h"
#include "chrome/install_static/install_util.h"
+#include "components/crash/content/app/crashpad.h"
+#include "components/crash/core/common/crash_keys.h"
+
+namespace {
+
+// TODO(ananta)
+// When the new crash key map implementation lands, we should remove the
+// constants defined below, the RegisterCrashKeysHelper function, the
+// RegisterCrashKeys function in the crash_keys::CrashReporterClient interface
+// and the snprintf function defined here.
+constexpr char kActiveURL[] = "url-chunk";
+constexpr char kFontKeyName[] = "font_key_name";
+
+// Installed extensions. |kExtensionID| should be formatted with an integer,
+// in the range [0, kExtensionIDMaxCount).
+constexpr char kNumExtensionsCount[] = "num-extensions";
+constexpr size_t kExtensionIDMaxCount = 10;
+constexpr char kExtensionID[] = "extension-%" PRIuS;
+
+constexpr char kShutdownType[] = "shutdown-type";
+
+constexpr char kGPUVendorID[] = "gpu-venid";
+constexpr char kGPUDeviceID[] = "gpu-devid";
+constexpr char kGPUDriverVersion[] = "gpu-driver";
+constexpr char kGPUPixelShaderVersion[] = "gpu-psver";
+constexpr char kGPUVertexShaderVersion[] = "gpu-vsver";
+
+constexpr char kHungAudioThreadDetails[] = "hung-audio-thread-details";
+
+constexpr char kViewCount[] = "view-count";
+constexpr char kZeroEncodeDetails[] = "zero-encode-details";
+
+// The user's printers, up to kPrinterInfoCount. Should be set with
+// ScopedPrinterInfo.
+constexpr size_t kPrinterInfoCount = 4;
+constexpr char kPrinterInfo[] = "prn-info-%" PRIuS;
+
+using namespace crash_keys;
+
+int snprintf(char* buffer,
+ size_t size,
+ _Printf_format_string_ const char* format,
+ ...) {
+ va_list arguments;
+ va_start(arguments, format);
+ int result = vsnprintf(buffer, size, format, arguments);
+ va_end(arguments);
+ return result;
+}
+
+size_t RegisterCrashKeysHelper() {
+ // The following keys may be chunked by the underlying crash logging system,
+ // but ultimately constitute a single key-value pair.
+ //
+ // If you're adding keys here, please also add them to the list in
+ // //blimp/engine/app/blimp_engine_crash_keys.cc
+ constexpr base::debug::CrashKey fixed_keys[] = {
+ {kMetricsClientId, kSmallSize},
+ {kChannel, kSmallSize},
+ {kActiveURL, kLargeSize},
+ {kNumVariations, kSmallSize},
+ {kVariations, kLargeSize},
+ {kNumExtensionsCount, kSmallSize},
+ {kShutdownType, kSmallSize},
+ {kGPUVendorID, kSmallSize},
+ {kGPUDeviceID, kSmallSize},
+ {kGPUDriverVersion, kSmallSize},
+ {kGPUPixelShaderVersion, kSmallSize},
+ {kGPUVertexShaderVersion, kSmallSize},
+
+ // content/:
+ {"discardable-memory-allocated", kSmallSize},
+ {"discardable-memory-free", kSmallSize},
+ {kFontKeyName, kSmallSize},
+ {"ppapi_path", kMediumSize},
+ {"subresource_url", kLargeSize},
+ {"total-discardable-memory-allocated", kSmallSize},
+ {kBug464926CrashKey, kSmallSize},
+ {kViewCount, kSmallSize},
+
+ // media/:
+ {kHungAudioThreadDetails, kSmallSize},
+ {kZeroEncodeDetails, kSmallSize},
+
+ // Temporary for http://crbug.com/575245.
+ {"swapout_frame_id", kSmallSize},
+ {"swapout_proxy_id", kSmallSize},
+ {"swapout_view_id", kSmallSize},
+ {"commit_frame_id", kSmallSize},
+ {"commit_proxy_id", kSmallSize},
+ {"commit_view_id", kSmallSize},
+ {"commit_main_render_frame_id", kSmallSize},
+ {"newproxy_proxy_id", kSmallSize},
+ {"newproxy_view_id", kSmallSize},
+ {"newproxy_opener_id", kSmallSize},
+ {"newproxy_parent_id", kSmallSize},
+ {"rvinit_view_id", kSmallSize},
+ {"rvinit_proxy_id", kSmallSize},
+ {"rvinit_main_frame_id", kSmallSize},
+ {"initrf_frame_id", kSmallSize},
+ {"initrf_proxy_id", kSmallSize},
+ {"initrf_view_id", kSmallSize},
+ {"initrf_main_frame_id", kSmallSize},
+ {"initrf_view_is_live", kSmallSize},
+
+ // Temporary for https://crbug.com/591478.
+ {"initrf_parent_proxy_exists", kSmallSize},
+ {"initrf_render_view_is_live", kSmallSize},
+ {"initrf_parent_is_in_same_site_instance", kSmallSize},
+ {"initrf_parent_process_is_live", kSmallSize},
+ {"initrf_root_is_in_same_site_instance", kSmallSize},
+ {"initrf_root_is_in_same_site_instance_as_parent", kSmallSize},
+ {"initrf_root_process_is_live", kSmallSize},
+ {"initrf_root_proxy_is_live", kSmallSize},
+
+ // Temporary for https://crbug.com/612711.
+ {"aci_wrong_sp_extension_id", kSmallSize},
+
+ // Temporary for https://crbug.com/616149.
+ {"existing_extension_pref_value_type", crash_keys::kSmallSize},
+ };
+
+ // This dynamic set of keys is used for sets of key value pairs when gathering
+ // a collection of data, like command line switches or extension IDs.
+ std::vector<base::debug::CrashKey> keys(fixed_keys,
+ fixed_keys + arraysize(fixed_keys));
+
+ crash_keys::GetCrashKeysForCommandLineSwitches(&keys);
+
+ // Register the extension IDs.
+ {
+ static char formatted_keys[kExtensionIDMaxCount]
+ [sizeof(kExtensionID) + 1] = {{0}};
+ const size_t formatted_key_len = sizeof(formatted_keys[0]);
+ for (size_t i = 0; i < kExtensionIDMaxCount; ++i) {
+ snprintf(formatted_keys[i], formatted_key_len, kExtensionID, i + 1);
+ base::debug::CrashKey crash_key = {formatted_keys[i], kSmallSize};
+ keys.push_back(crash_key);
+ }
+ }
+
+ // Register the printer info.
+ {
+ static char formatted_keys[kPrinterInfoCount]
+ [sizeof(kPrinterInfo) + 1] = {{0}};
+ const size_t formatted_key_len = sizeof(formatted_keys[0]);
+ for (size_t i = 0; i < kPrinterInfoCount; ++i) {
+ // Key names are 1-indexed.
+ snprintf(formatted_keys[i], formatted_key_len, kPrinterInfo, i + 1);
+ base::debug::CrashKey crash_key = {formatted_keys[i], kSmallSize};
+ keys.push_back(crash_key);
+ }
+ }
+
+ return base::debug::InitCrashKeys(&keys[0], keys.size(), kChunkMaxLength);
+}
+
+} // namespace
ChromeCrashReporterClient::ChromeCrashReporterClient() {}
ChromeCrashReporterClient::~ChromeCrashReporterClient() {}
+#if !defined(NACL_WIN64)
+// static
+void ChromeCrashReporterClient::InitializeCrashReportingForProcess() {
+ static ChromeCrashReporterClient* instance = nullptr;
+ if (instance)
+ return;
+
+ instance = new ChromeCrashReporterClient();
+ ANNOTATE_LEAKING_OBJECT_PTR(instance);
+
+ std::string process_type = install_static::GetSwitchValueFromCommandLine(
+ ::GetCommandLineA(), install_static::kProcessType);
+ if (process_type != install_static::kCrashpadHandler) {
+ crash_reporter::SetCrashReporterClient(instance);
+ crash_reporter::InitializeCrashpadWithEmbeddedHandler(process_type.empty(),
+ process_type);
+ }
+}
+#endif // NACL_WIN64
+
bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation(
base::string16* crash_dir) {
// By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate
@@ -137,8 +317,11 @@ bool ChromeCrashReporterClient::GetCrashDumpLocation(
return install_static::GetDefaultCrashDumpLocation(crash_dir);
}
+// TODO(ananta)
+// This function should be removed when the new crash key map implementation
+// lands.
size_t ChromeCrashReporterClient::RegisterCrashKeys() {
- return crash_keys::RegisterChromeCrashKeys();
+ return RegisterCrashKeysHelper();
}
bool ChromeCrashReporterClient::IsRunningUnattended() {
« no previous file with comments | « chrome/app/chrome_crash_reporter_client_win.h ('k') | chrome/install_static/install_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698