Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/crash/content/app/crashpad.h" | 5 #include "components/crash/content/app/crashpad.h" |
| 6 | 6 |
| 7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/lazy_instance.h" | |
| 16 #include "base/logging.h" | 17 #include "base/logging.h" |
| 17 #include "base/mac/bundle_locations.h" | 18 #include "base/mac/bundle_locations.h" |
| 18 #include "base/mac/foundation_util.h" | 19 #include "base/mac/foundation_util.h" |
| 19 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_piece.h" | 21 #include "base/strings/string_piece.h" |
| 21 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 22 #include "base/strings/sys_string_conversions.h" | 23 #include "base/strings/sys_string_conversions.h" |
| 23 #include "components/crash/content/app/crash_reporter_client.h" | 24 #include "components/crash/content/app/crash_reporter_client.h" |
| 24 #include "third_party/crashpad/crashpad/client/crash_report_database.h" | 25 #include "third_party/crashpad/crashpad/client/crash_report_database.h" |
| 25 #include "third_party/crashpad/crashpad/client/crashpad_client.h" | 26 #include "third_party/crashpad/crashpad/client/crashpad_client.h" |
| 26 #include "third_party/crashpad/crashpad/client/crashpad_info.h" | 27 #include "third_party/crashpad/crashpad/client/crashpad_info.h" |
| 27 #include "third_party/crashpad/crashpad/client/settings.h" | 28 #include "third_party/crashpad/crashpad/client/settings.h" |
| 28 #include "third_party/crashpad/crashpad/client/simple_string_dictionary.h" | 29 #include "third_party/crashpad/crashpad/client/simple_string_dictionary.h" |
| 29 #include "third_party/crashpad/crashpad/client/simulate_crash.h" | 30 #include "third_party/crashpad/crashpad/client/simulate_crash.h" |
| 30 | 31 |
| 31 namespace crash_reporter { | 32 namespace crash_reporter { |
| 33 | |
| 34 namespace { | |
| 35 | |
| 36 base::LazyInstance<crashpad::CrashpadClient>::Leaky g_crashpad_client = | |
| 37 LAZY_INSTANCE_INITIALIZER; | |
|
Robert Sesek
2017/03/14 22:14:54
Also worth noting that this is how crashpad_win.cc
Mark Mentovai
2017/03/14 23:24:52
Robert Sesek wrote:
Robert Sesek
2017/03/15 19:22:10
Done. (Assuming you really did want a non-const-re
| |
| 38 | |
| 39 } // namespace | |
| 40 | |
| 41 base::mac::ScopedMachSendRight GetHandlerMachPort() { | |
| 42 return g_crashpad_client.Get().GetHandlerMachPort(); | |
| 43 } | |
| 44 | |
| 32 namespace internal { | 45 namespace internal { |
| 33 | 46 |
| 34 base::FilePath PlatformCrashpadInitialization(bool initial_client, | 47 base::FilePath PlatformCrashpadInitialization(bool initial_client, |
| 35 bool browser_process, | 48 bool browser_process, |
| 36 bool embedded_handler) { | 49 bool embedded_handler) { |
| 37 base::FilePath database_path; // Only valid in the browser process. | 50 base::FilePath database_path; // Only valid in the browser process. |
| 38 base::FilePath metrics_path; // Only valid in the browser process. | 51 base::FilePath metrics_path; // Only valid in the browser process. |
| 39 DCHECK(!embedded_handler); // This is not used on Mac. | 52 DCHECK(!embedded_handler); // This is not used on Mac. |
| 40 | 53 |
| 41 if (initial_client) { | 54 if (initial_client) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 std::vector<std::string> arguments; | 96 std::vector<std::string> arguments; |
| 84 if (!browser_process) { | 97 if (!browser_process) { |
| 85 // If this is an initial client that's not the browser process, it's | 98 // If this is an initial client that's not the browser process, it's |
| 86 // important that the new Crashpad handler also not be connected to any | 99 // important that the new Crashpad handler also not be connected to any |
| 87 // existing handler. This argument tells the new Crashpad handler to | 100 // existing handler. This argument tells the new Crashpad handler to |
| 88 // sever this connection. | 101 // sever this connection. |
| 89 arguments.push_back( | 102 arguments.push_back( |
| 90 "--reset-own-crash-exception-port-to-system-default"); | 103 "--reset-own-crash-exception-port-to-system-default"); |
| 91 } | 104 } |
| 92 | 105 |
| 93 crashpad::CrashpadClient crashpad_client; | 106 bool result = g_crashpad_client.Get().StartHandler( |
|
Mark Mentovai
2017/03/14 23:24:52
clang-format’s worse, and I guess I’m not supposed
Robert Sesek
2017/03/15 19:22:10
https://bugs.chromium.org/p/chromium/issues/detail
| |
| 94 bool result = crashpad_client.StartHandler(handler_path, | 107 handler_path, database_path, metrics_path, url, process_annotations, |
| 95 database_path, | 108 arguments, true, false); |
| 96 metrics_path, | |
| 97 url, | |
| 98 process_annotations, | |
| 99 arguments, | |
| 100 true, | |
| 101 false); | |
| 102 | 109 |
| 103 // If this is an initial client that's not the browser process, it's | 110 // If this is an initial client that's not the browser process, it's |
| 104 // important to sever the connection to any existing handler. If | 111 // important to sever the connection to any existing handler. If |
| 105 // StartHandler() failed, call UseSystemDefaultHandler() to drop the link | 112 // StartHandler() failed, call UseSystemDefaultHandler() to drop the link |
| 106 // to the existing handler. | 113 // to the existing handler. |
| 107 if (!result && !browser_process) { | 114 if (!result && !browser_process) { |
| 108 crashpad::CrashpadClient::UseSystemDefaultHandler(); | 115 crashpad::CrashpadClient::UseSystemDefaultHandler(); |
| 109 } | 116 } |
| 110 } // @autoreleasepool | 117 } // @autoreleasepool |
| 111 } | 118 } |
| 112 | 119 |
| 113 return database_path; | 120 return database_path; |
| 114 } | 121 } |
| 115 | 122 |
| 116 } // namespace internal | 123 } // namespace internal |
| 117 } // namespace crash_reporter | 124 } // namespace crash_reporter |
| OLD | NEW |