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

Unified Diff: components/crash/content/app/crashpad.cc

Issue 1479283002: Reland: Crashpad Windows: Use the Crashpad client instead of Breakpad on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: with crashpad 1f3ced1846f3956e678c562c90e0d6c970543617 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 | « components/crash/content/app/crashpad.h ('k') | components/crash/content/app/crashpad_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/crash/content/app/crashpad.cc
diff --git a/components/crash/content/app/crashpad_mac.mm b/components/crash/content/app/crashpad.cc
similarity index 68%
copy from components/crash/content/app/crashpad_mac.mm
copy to components/crash/content/app/crashpad.cc
index f87fc96ee46b38368faef8c69ce21cf6ac2752a8..e3b4124affd8182b1d160d42f109363bab717612 100644
--- a/components/crash/content/app/crashpad_mac.mm
+++ b/components/crash/content/app/crashpad.cc
@@ -2,26 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/crash/content/app/crashpad_mac.h"
+#include "components/crash/content/app/crashpad.h"
#include <string.h>
-#include <unistd.h>
#include <algorithm>
#include <map>
#include <vector>
#include "base/auto_reset.h"
+#include "base/command_line.h"
#include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h"
-#include "base/files/file_path.h"
#include "base/logging.h"
-#include "base/mac/bundle_locations.h"
-#include "base/mac/foundation_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
+#include "build/build_config.h"
#include "components/crash/content/app/crash_reporter_client.h"
#include "third_party/crashpad/crashpad/client/crash_report_database.h"
#include "third_party/crashpad/crashpad/client/crashpad_client.h"
@@ -30,6 +28,10 @@
#include "third_party/crashpad/crashpad/client/simple_string_dictionary.h"
#include "third_party/crashpad/crashpad/client/simulate_crash.h"
+#if defined(OS_POSIX)
+#include <unistd.h>
+#endif // OS_POSIX
+
namespace crash_reporter {
namespace {
@@ -74,6 +76,7 @@ bool LogMessageHandler(int severity,
}
}
+ CHECK_LE(message_start, string.size());
std::string message = base::StringPrintf("%s:%d: %s", file, line,
string.c_str() + message_start);
SetCrashKeyValue("LOG_FATAL", message);
@@ -98,79 +101,26 @@ void InitializeCrashpad(bool initial_client, const std::string& process_type) {
CrashReporterClient* crash_reporter_client = GetCrashReporterClient();
if (initial_client) {
+#if defined(OS_MACOSX)
// "relauncher" is hard-coded because it's a Chrome --type, but this
// component can't see Chrome's switches. This is only used for argument
// sanitization.
DCHECK(browser_process || process_type == "relauncher");
+#else
+ DCHECK(browser_process);
+#endif // OS_MACOSX
} else {
DCHECK(!browser_process);
}
- base::FilePath database_path; // Only valid in the browser process.
-
- if (initial_client) {
- @autoreleasepool {
- base::FilePath framework_bundle_path = base::mac::FrameworkBundlePath();
- base::FilePath handler_path =
- framework_bundle_path.Append("Helpers").Append("crashpad_handler");
-
- // Is there a way to recover if this fails?
- crash_reporter_client->GetCrashDumpLocation(&database_path);
-
- // TODO(mark): Reading the Breakpad keys is temporary and transitional. At
- // the very least, they should be renamed to Crashpad. For the time being,
- // this isn't the worst thing: Crashpad is still uploading to a
- // Breakpad-type server, after all.
- NSBundle* framework_bundle = base::mac::FrameworkBundle();
- NSString* product = base::mac::ObjCCast<NSString>(
- [framework_bundle objectForInfoDictionaryKey:@"BreakpadProduct"]);
- NSString* version = base::mac::ObjCCast<NSString>(
- [framework_bundle objectForInfoDictionaryKey:@"BreakpadVersion"]);
- NSString* url_ns = base::mac::ObjCCast<NSString>(
- [framework_bundle objectForInfoDictionaryKey:@"BreakpadURL"]);
-
- std::string url = base::SysNSStringToUTF8(url_ns);
-
- std::map<std::string, std::string> process_annotations;
- process_annotations["prod"] = base::SysNSStringToUTF8(product);
- process_annotations["ver"] = base::SysNSStringToUTF8(version);
- process_annotations["plat"] = std::string("OS X");
-
- crashpad::CrashpadClient crashpad_client;
-
- std::vector<std::string> arguments;
- if (!browser_process) {
- // If this is an initial client that's not the browser process, it's
- // important that the new Crashpad handler also not be connected to any
- // existing handler. This argument tells the new Crashpad handler to
- // sever this connection.
- arguments.push_back(
- "--reset-own-crash-exception-port-to-system-default");
- }
-
- bool result = crashpad_client.StartHandler(handler_path,
- database_path,
- url,
- process_annotations,
- arguments,
- true);
- if (result) {
- result = crashpad_client.UseHandler();
- }
-
- // If this is an initial client that's not the browser process, it's
- // important to sever the connection to any existing handler. If
- // StartHandler() or UseHandler() failed, call UseSystemDefaultHandler()
- // in that case to drop the link to the existing handler.
- if (!result && !browser_process) {
- crashpad::CrashpadClient::UseSystemDefaultHandler();
- }
- } // @autoreleasepool
- }
+ // database_path is only valid in the browser process.
+ base::FilePath database_path =
+ internal::PlatformCrashpadInitialization(initial_client, browser_process);
crashpad::CrashpadInfo* crashpad_info =
crashpad::CrashpadInfo::GetCrashpadInfo();
+#if defined(OS_MACOSX)
#if defined(NDEBUG)
const bool is_debug_build = false;
#else
@@ -188,6 +138,7 @@ void InitializeCrashpad(bool initial_client, const std::string& process_type) {
crashpad_info->set_system_crash_reporter_forwarding(
crashpad::TriState::kDisabled);
}
+#endif // OS_MACOSX
g_simple_string_dictionary = new crashpad::SimpleStringDictionary();
crashpad_info->set_simple_annotations(g_simple_string_dictionary);
@@ -197,7 +148,11 @@ void InitializeCrashpad(bool initial_client, const std::string& process_type) {
SetCrashKeyValue("ptype", browser_process ? base::StringPiece("browser")
: base::StringPiece(process_type));
+#if defined(OS_POSIX)
SetCrashKeyValue("pid", base::IntToString(getpid()));
+#elif defined(OS_WIN)
+ SetCrashKeyValue("pid", base::IntToString(::GetCurrentProcessId()));
+#endif
logging::SetLogMessageHandler(LogMessageHandler);
@@ -272,12 +227,10 @@ void GetUploadedReports(std::vector<UploadedReport>* uploaded_reports) {
}
}
- struct {
- bool operator()(const UploadedReport& a, const UploadedReport& b) {
- return a.creation_time >= b.creation_time;
- }
- } sort_by_time;
- std::sort(uploaded_reports->begin(), uploaded_reports->end(), sort_by_time);
+ std::sort(uploaded_reports->begin(), uploaded_reports->end(),
+ [](const UploadedReport& a, const UploadedReport& b) {
+ return a.creation_time >= b.creation_time;
+ });
}
} // namespace crash_reporter
« no previous file with comments | « components/crash/content/app/crashpad.h ('k') | components/crash/content/app/crashpad_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698