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

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

Issue 2638433002: Integrate fallback crash handling in chrome (Closed)
Patch Set: Fix signedness comparison goof. Created 3 years, 11 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
11 #include <algorithm> 11 #include <algorithm>
12 #include <string> 12 #include <string>
13 13
14 #include "base/at_exit.h" 14 #include "base/at_exit.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
20 #include "base/strings/string_split.h" 20 #include "base/strings/string_split.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/utf_string_conversions.h"
22 #include "base/time/time.h" 23 #include "base/time/time.h"
23 #include "base/win/registry.h" 24 #include "base/win/registry.h"
24 #include "base/win/windows_version.h" 25 #include "base/win/windows_version.h"
25 #include "chrome/app/main_dll_loader_win.h" 26 #include "chrome/app/main_dll_loader_win.h"
26 #include "chrome/browser/policy/policy_path_parser.h" 27 #include "chrome/browser/policy/policy_path_parser.h"
27 #include "chrome/browser/win/chrome_process_finder.h" 28 #include "chrome/browser/win/chrome_process_finder.h"
28 #include "chrome/common/chrome_constants.h" 29 #include "chrome/common/chrome_constants.h"
29 #include "chrome/common/chrome_paths_internal.h" 30 #include "chrome/common/chrome_paths_internal.h"
30 #include "chrome/common/chrome_switches.h" 31 #include "chrome/common/chrome_switches.h"
31 #include "chrome/install_static/install_details.h" 32 #include "chrome/install_static/install_details.h"
33 #include "chrome/install_static/install_util.h"
32 #include "chrome_elf/chrome_elf_main.h" 34 #include "chrome_elf/chrome_elf_main.h"
33 #include "components/crash/content/app/crash_switches.h" 35 #include "components/crash/content/app/crash_switches.h"
34 #include "components/crash/content/app/crashpad.h" 36 #include "components/crash/content/app/crashpad.h"
37 #include "components/crash/content/app/fallback_crash_handling_win.h"
35 #include "components/crash/content/app/run_as_crashpad_handler_win.h" 38 #include "components/crash/content/app/run_as_crashpad_handler_win.h"
36 #include "content/public/common/content_switches.h" 39 #include "content/public/common/content_switches.h"
37 #include "content/public/common/result_codes.h" 40 #include "content/public/common/result_codes.h"
38 41
39 namespace { 42 namespace {
40 43
41 // List of switches that it's safe to rendezvous early with. Fast start should 44 // List of switches that it's safe to rendezvous early with. Fast start should
42 // not be done if a command line contains a switch not in this set. 45 // not be done if a command line contains a switch not in this set.
43 // Note this is currently stored as a list of two because it's probably faster 46 // Note this is currently stored as a list of two because it's probably faster
44 // to iterate over this small array than building a map for constant time 47 // to iterate over this small array than building a map for constant time
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 without_compat_mode_tokens.c_str()); 192 without_compat_mode_tokens.c_str());
190 } 193 }
191 194
192 // Return if we changed anything so that we can restart. 195 // Return if we changed anything so that we can restart.
193 return tokens.size() != initial_size && result == ERROR_SUCCESS; 196 return tokens.size() != initial_size && result == ERROR_SUCCESS;
194 } 197 }
195 } 198 }
196 return false; 199 return false;
197 } 200 }
198 201
202 int RunFallbackCrashHandler(const base::CommandLine& cmd_line) {
203 // Retrieve the product & version details we need to report the crash
204 // correctly.
205 wchar_t exe_file[MAX_PATH] = {};
206 CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file)));
207
208 base::string16 product_name;
209 base::string16 version;
210 base::string16 channel_name;
211 base::string16 special_build;
212 install_static::GetExecutableVersionDetails(exe_file, &product_name, &version,
213 &special_build, &channel_name);
214
215 return crash_reporter::RunAsFallbackCrashHandler(
216 cmd_line, base::UTF16ToUTF8(product_name), base::UTF16ToUTF8(version),
217 base::UTF16ToUTF8(channel_name));
218 }
219
199 } // namespace 220 } // namespace
200 221
201 #if defined(SYZYASAN) 222 #if defined(SYZYASAN)
202 // This is in chrome_elf. 223 // This is in chrome_elf.
203 extern "C" void BlockUntilHandlerStartedImpl(); 224 extern "C" void BlockUntilHandlerStartedImpl();
204 #endif // SYZYASAN 225 #endif // SYZYASAN
205 226
206 #if !defined(WIN_CONSOLE_APP) 227 #if !defined(WIN_CONSOLE_APP)
207 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) { 228 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) {
208 #else 229 #else
(...skipping 12 matching lines...) Expand all
221 command_line->GetSwitchValueASCII(switches::kProcessType); 242 command_line->GetSwitchValueASCII(switches::kProcessType);
222 243
223 // Confirm that an explicit prefetch profile is used for all process types 244 // Confirm that an explicit prefetch profile is used for all process types
224 // except for the browser process. Any new process type will have to assign 245 // except for the browser process. Any new process type will have to assign
225 // itself a prefetch id. See kPrefetchArgument* constants in 246 // itself a prefetch id. See kPrefetchArgument* constants in
226 // content_switches.cc for details. 247 // content_switches.cc for details.
227 DCHECK(process_type.empty() || 248 DCHECK(process_type.empty() ||
228 HasValidWindowsPrefetchArgument(*command_line)); 249 HasValidWindowsPrefetchArgument(*command_line));
229 250
230 if (process_type == crash_reporter::switches::kCrashpadHandler) { 251 if (process_type == crash_reporter::switches::kCrashpadHandler) {
252 crash_reporter::SetupFallbackCrashHandling(*command_line);
231 return crash_reporter::RunAsCrashpadHandler( 253 return crash_reporter::RunAsCrashpadHandler(
232 *base::CommandLine::ForCurrentProcess()); 254 *base::CommandLine::ForCurrentProcess());
255 } else if (process_type == crash_reporter::switches::kFallbackCrashHandler) {
256 return RunFallbackCrashHandler(*command_line);
233 } 257 }
234 258
235 const base::TimeTicks exe_entry_point_ticks = base::TimeTicks::Now(); 259 const base::TimeTicks exe_entry_point_ticks = base::TimeTicks::Now();
236 260
237 // Signal Chrome Elf that Chrome has begun to start. 261 // Signal Chrome Elf that Chrome has begun to start.
238 SignalChromeElf(); 262 SignalChromeElf();
239 263
240 #if defined(SYZYASAN) 264 #if defined(SYZYASAN)
241 if (process_type.empty()) { 265 if (process_type.empty()) {
242 // This is a temporary workaround for a race during startup with the 266 // This is a temporary workaround for a race during startup with the
(...skipping 13 matching lines...) Expand all
256 RemoveAppCompatFlagsEntry(); 280 RemoveAppCompatFlagsEntry();
257 281
258 // Load and launch the chrome dll. *Everything* happens inside. 282 // Load and launch the chrome dll. *Everything* happens inside.
259 VLOG(1) << "About to load main DLL."; 283 VLOG(1) << "About to load main DLL.";
260 MainDllLoader* loader = MakeMainDllLoader(); 284 MainDllLoader* loader = MakeMainDllLoader();
261 int rc = loader->Launch(instance, exe_entry_point_ticks); 285 int rc = loader->Launch(instance, exe_entry_point_ticks);
262 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded(); 286 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded();
263 delete loader; 287 delete loader;
264 return rc; 288 return rc;
265 } 289 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698