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

Side by Side Diff: chrome/app/chrome_exe_main_win.cc

Issue 2088133002: Switch chrome_elf exception handling from breakpad to crashpad. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove include 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <windows.h> 5 #include <windows.h>
6 #include <malloc.h> 6 #include <malloc.h>
7 #include <shellscalingapi.h> 7 #include <shellscalingapi.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <tchar.h> 9 #include <tchar.h>
10 10
(...skipping 24 matching lines...) Expand all
35 #include "components/crash/content/app/crash_switches.h" 35 #include "components/crash/content/app/crash_switches.h"
36 #include "components/crash/content/app/crashpad.h" 36 #include "components/crash/content/app/crashpad.h"
37 #include "components/crash/content/app/run_as_crashpad_handler_win.h" 37 #include "components/crash/content/app/run_as_crashpad_handler_win.h"
38 #include "components/startup_metric_utils/browser/startup_metric_utils.h" 38 #include "components/startup_metric_utils/browser/startup_metric_utils.h"
39 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win. h" 39 #include "components/startup_metric_utils/common/pre_read_field_trial_utils_win. h"
40 #include "content/public/common/content_switches.h" 40 #include "content/public/common/content_switches.h"
41 #include "content/public/common/result_codes.h" 41 #include "content/public/common/result_codes.h"
42 42
43 namespace { 43 namespace {
44 44
45 base::LazyInstance<ChromeCrashReporterClient>::Leaky g_chrome_crash_client =
46 LAZY_INSTANCE_INITIALIZER;
47
48 base::LazyInstance<std::vector<crash_reporter::Report>>::Leaky g_crash_reports =
49 LAZY_INSTANCE_INITIALIZER;
50
51 // List of switches that it's safe to rendezvous early with. Fast start should 45 // List of switches that it's safe to rendezvous early with. Fast start should
52 // not be done if a command line contains a switch not in this set. 46 // not be done if a command line contains a switch not in this set.
53 // Note this is currently stored as a list of two because it's probably faster 47 // Note this is currently stored as a list of two because it's probably faster
54 // to iterate over this small array than building a map for constant time 48 // to iterate over this small array than building a map for constant time
55 // lookups. 49 // lookups.
56 const char* const kFastStartSwitches[] = { 50 const char* const kFastStartSwitches[] = {
57 switches::kProfileDirectory, 51 switches::kProfileDirectory,
58 switches::kShowAppList, 52 switches::kShowAppList,
59 }; 53 };
60 54
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 183
190 // Return if we changed anything so that we can restart. 184 // Return if we changed anything so that we can restart.
191 return tokens.size() != initial_size && result == ERROR_SUCCESS; 185 return tokens.size() != initial_size && result == ERROR_SUCCESS;
192 } 186 }
193 } 187 }
194 return false; 188 return false;
195 } 189 }
196 190
197 } // namespace 191 } // namespace
198 192
199 // This helper is looked up in the browser to retrieve the crash reports. See
200 // CrashUploadListCrashpad. Note that we do not pass an std::vector here,
201 // because we do not want to allocate/free in different modules. The returned
202 // pointer is read-only.
203 extern "C" __declspec(dllexport) void GetCrashReportsImpl(
204 const crash_reporter::Report** reports,
205 size_t* report_count) {
206 crash_reporter::GetReports(g_crash_reports.Pointer());
207 *reports = g_crash_reports.Pointer()->data();
208 *report_count = g_crash_reports.Pointer()->size();
209 }
210
211 #if !defined(WIN_CONSOLE_APP) 193 #if !defined(WIN_CONSOLE_APP)
212 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) { 194 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) {
213 #else 195 #else
214 int main() { 196 int main() {
215 HINSTANCE instance = GetModuleHandle(nullptr); 197 HINSTANCE instance = GetModuleHandle(nullptr);
216 #endif 198 #endif
217 // Initialize the CommandLine singleton from the environment. 199 // Initialize the CommandLine singleton from the environment.
218 base::CommandLine::Init(0, nullptr); 200 base::CommandLine::Init(0, nullptr);
219 const base::CommandLine* command_line = 201 const base::CommandLine* command_line =
220 base::CommandLine::ForCurrentProcess(); 202 base::CommandLine::ForCurrentProcess();
221 203
222 const std::string process_type = 204 const std::string process_type =
223 command_line->GetSwitchValueASCII(switches::kProcessType); 205 command_line->GetSwitchValueASCII(switches::kProcessType);
224 206
225 startup_metric_utils::InitializePreReadOptions( 207 startup_metric_utils::InitializePreReadOptions(
226 BrowserDistribution::GetDistribution()->GetRegistryPath()); 208 BrowserDistribution::GetDistribution()->GetRegistryPath());
227 209
228 // Confirm that an explicit prefetch profile is used for all process types 210 // Confirm that an explicit prefetch profile is used for all process types
229 // except for the browser process. Any new process type will have to assign 211 // except for the browser process. Any new process type will have to assign
230 // itself a prefetch id. See kPrefetchArgument* constants in 212 // itself a prefetch id. See kPrefetchArgument* constants in
231 // content_switches.cc for details. 213 // content_switches.cc for details.
232 DCHECK(process_type.empty() || 214 DCHECK(process_type.empty() ||
233 HasValidWindowsPrefetchArgument(*command_line)); 215 HasValidWindowsPrefetchArgument(*command_line));
234 216
235 if (process_type == crash_reporter::switches::kCrashpadHandler) { 217 if (process_type == crash_reporter::switches::kCrashpadHandler) {
236 return crash_reporter::RunAsCrashpadHandler( 218 return crash_reporter::RunAsCrashpadHandler(
237 *base::CommandLine::ForCurrentProcess()); 219 *base::CommandLine::ForCurrentProcess());
238 } 220 }
239 221
240 crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer());
241 crash_reporter::InitializeCrashpadWithEmbeddedHandler(process_type.empty(),
242 process_type);
243
244 startup_metric_utils::RecordExeMainEntryPointTime(base::Time::Now()); 222 startup_metric_utils::RecordExeMainEntryPointTime(base::Time::Now());
245 223
246 // Signal Chrome Elf that Chrome has begun to start. 224 // Signal Chrome Elf that Chrome has begun to start.
247 SignalChromeElf(); 225 SignalChromeElf();
248 226
249 // The exit manager is in charge of calling the dtors of singletons. 227 // The exit manager is in charge of calling the dtors of singletons.
250 base::AtExitManager exit_manager; 228 base::AtExitManager exit_manager;
251 229
252 EnableHighDPISupport(); 230 EnableHighDPISupport();
253 231
254 if (AttemptFastNotify(*command_line)) 232 if (AttemptFastNotify(*command_line))
255 return 0; 233 return 0;
256 234
257 RemoveAppCompatFlagsEntry(); 235 RemoveAppCompatFlagsEntry();
258 236
259 // Load and launch the chrome dll. *Everything* happens inside. 237 // Load and launch the chrome dll. *Everything* happens inside.
260 VLOG(1) << "About to load main DLL."; 238 VLOG(1) << "About to load main DLL.";
261 MainDllLoader* loader = MakeMainDllLoader(); 239 MainDllLoader* loader = MakeMainDllLoader();
262 int rc = loader->Launch(instance); 240 int rc = loader->Launch(instance);
263 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded(); 241 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded();
264 delete loader; 242 delete loader;
265 return rc; 243 return rc;
266 } 244 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698