| 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 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "third_party/crashpad/crashpad/client/simple_string_dictionary.h" | 28 #include "third_party/crashpad/crashpad/client/simple_string_dictionary.h" |
| 29 #include "third_party/crashpad/crashpad/client/simulate_crash.h" | 29 #include "third_party/crashpad/crashpad/client/simulate_crash.h" |
| 30 | 30 |
| 31 namespace crash_reporter { | 31 namespace crash_reporter { |
| 32 namespace internal { | 32 namespace internal { |
| 33 | 33 |
| 34 base::FilePath PlatformCrashpadInitialization(bool initial_client, | 34 base::FilePath PlatformCrashpadInitialization(bool initial_client, |
| 35 bool browser_process, | 35 bool browser_process, |
| 36 bool embedded_handler) { | 36 bool embedded_handler) { |
| 37 base::FilePath database_path; // Only valid in the browser process. | 37 base::FilePath database_path; // Only valid in the browser process. |
| 38 base::FilePath metrics_path; // Only valid in the browser process. |
| 38 DCHECK(!embedded_handler); // This is not used on Mac. | 39 DCHECK(!embedded_handler); // This is not used on Mac. |
| 39 | 40 |
| 40 if (initial_client) { | 41 if (initial_client) { |
| 41 @autoreleasepool { | 42 @autoreleasepool { |
| 42 base::FilePath framework_bundle_path = base::mac::FrameworkBundlePath(); | 43 base::FilePath framework_bundle_path = base::mac::FrameworkBundlePath(); |
| 43 base::FilePath handler_path = | 44 base::FilePath handler_path = |
| 44 framework_bundle_path.Append("Helpers").Append("crashpad_handler"); | 45 framework_bundle_path.Append("Helpers").Append("crashpad_handler"); |
| 45 | 46 |
| 46 // Is there a way to recover if this fails? | 47 // Is there a way to recover if this fails? |
| 47 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); | 48 CrashReporterClient* crash_reporter_client = GetCrashReporterClient(); |
| 48 crash_reporter_client->GetCrashDumpLocation(&database_path); | 49 crash_reporter_client->GetCrashDumpLocation(&database_path); |
| 50 crash_reporter_client->GetCrashMetricsLocation(&metrics_path); |
| 49 | 51 |
| 50 #if defined(GOOGLE_CHROME_BUILD) && defined(OFFICIAL_BUILD) | 52 #if defined(GOOGLE_CHROME_BUILD) && defined(OFFICIAL_BUILD) |
| 51 // Only allow the possibility of report upload in official builds. This | 53 // Only allow the possibility of report upload in official builds. This |
| 52 // crash server won't have symbols for any other build types. | 54 // crash server won't have symbols for any other build types. |
| 53 std::string url = "https://clients2.google.com/cr/report"; | 55 std::string url = "https://clients2.google.com/cr/report"; |
| 54 #else | 56 #else |
| 55 std::string url; | 57 std::string url; |
| 56 #endif | 58 #endif |
| 57 | 59 |
| 58 std::map<std::string, std::string> process_annotations; | 60 std::map<std::string, std::string> process_annotations; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 84 // important that the new Crashpad handler also not be connected to any | 86 // important that the new Crashpad handler also not be connected to any |
| 85 // existing handler. This argument tells the new Crashpad handler to | 87 // existing handler. This argument tells the new Crashpad handler to |
| 86 // sever this connection. | 88 // sever this connection. |
| 87 arguments.push_back( | 89 arguments.push_back( |
| 88 "--reset-own-crash-exception-port-to-system-default"); | 90 "--reset-own-crash-exception-port-to-system-default"); |
| 89 } | 91 } |
| 90 | 92 |
| 91 crashpad::CrashpadClient crashpad_client; | 93 crashpad::CrashpadClient crashpad_client; |
| 92 bool result = crashpad_client.StartHandler(handler_path, | 94 bool result = crashpad_client.StartHandler(handler_path, |
| 93 database_path, | 95 database_path, |
| 96 metrics_path, |
| 94 url, | 97 url, |
| 95 process_annotations, | 98 process_annotations, |
| 96 arguments, | 99 arguments, |
| 97 true); | 100 true); |
| 98 if (result) { | 101 if (result) { |
| 99 result = crashpad_client.UseHandler(); | 102 result = crashpad_client.UseHandler(); |
| 100 } | 103 } |
| 101 | 104 |
| 102 // If this is an initial client that's not the browser process, it's | 105 // If this is an initial client that's not the browser process, it's |
| 103 // important to sever the connection to any existing handler. If | 106 // important to sever the connection to any existing handler. If |
| 104 // StartHandler() or UseHandler() failed, call UseSystemDefaultHandler() | 107 // StartHandler() or UseHandler() failed, call UseSystemDefaultHandler() |
| 105 // in that case to drop the link to the existing handler. | 108 // in that case to drop the link to the existing handler. |
| 106 if (!result && !browser_process) { | 109 if (!result && !browser_process) { |
| 107 crashpad::CrashpadClient::UseSystemDefaultHandler(); | 110 crashpad::CrashpadClient::UseSystemDefaultHandler(); |
| 108 } | 111 } |
| 109 } // @autoreleasepool | 112 } // @autoreleasepool |
| 110 } | 113 } |
| 111 | 114 |
| 112 return database_path; | 115 return database_path; |
| 113 } | 116 } |
| 114 | 117 |
| 115 } // namespace internal | 118 } // namespace internal |
| 116 } // namespace crash_reporter | 119 } // namespace crash_reporter |
| OLD | NEW |