Chromium Code Reviews| Index: components/crash/content/app/fallback_crash_handler_launcher_win.h |
| diff --git a/components/crash/content/app/fallback_crash_handler_launcher_win.h b/components/crash/content/app/fallback_crash_handler_launcher_win.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cb63351109398095a87616598d1b0c3b51539452 |
| --- /dev/null |
| +++ b/components/crash/content/app/fallback_crash_handler_launcher_win.h |
| @@ -0,0 +1,68 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
|
scottmg
2017/01/06 18:29:04
2017 :)
Sigurður Ásgeirsson
2017/01/06 20:59:10
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_CRASH_CONTENT_APP_FALLBACK_CRASH_HANDLER_LAUNCHER_WIN_H_ |
| +#define COMPONENTS_CRASH_CONTENT_APP_FALLBACK_CRASH_HANDLER_LAUNCHER_WIN_H_ |
| + |
| +#include "base/command_line.h" |
| +#include "base/files/file_path.h" |
| +#include "base/macros.h" |
| +#include "base/win/scoped_handle.h" |
| +#include "base/win/startup_information.h" |
| + |
| +#include <windows.h> |
|
scottmg
2017/01/06 18:29:04
This goes before " includes.
Sigurður Ásgeirsson
2017/01/06 20:59:10
Done.
|
| + |
| +namespace crash_reporter { |
| + |
| +// This class is a last-ditch crash handler for the Crashpad handler process. |
| +// It prepares and stores a command line, ready for dispatching when |
| +// an exception occurs. Everything needed to call CreateProcess is pre-allocated |
| +// to minimize the odds of re-faulting due to e.g. tripping over the same issue |
| +// that caused the initial crash. |
| +// This is still very much best-effort, as doing anything at all inside a |
| +// process that's crashed is always going to be iffy^2. |
| +// Only one instance of this class can exist at a time. |
|
scottmg
2017/01/06 18:29:04
"Only one instance" should be confirmed somewhere
Sigurður Ásgeirsson
2017/01/06 20:59:10
Ah, that's redundant. Initially I had wanted to ma
|
| +class FallbackCrashHandlerLauncher { |
| + public: |
| + FallbackCrashHandlerLauncher(); |
| + ~FallbackCrashHandlerLauncher(); |
| + |
| + // Initialize |
| + bool Initialize(const base::CommandLine& program, |
| + const base::FilePath& crashpad_database); |
| + |
| + // Launch the pre-computed command line for the fallback error handler. |
| + // The expectation is that this function will never return, as the fallback |
| + // error handler should terminate it with the exception code as the process |
| + // exit code. The return value from this function is therefore academic in |
| + // the normal case. |
| + // However, for completeness, this function returns one of: |
| + // - The error from CreateProcess if it fails to launch the fallback handler. |
| + // - The error from waiting on the fallback crash handler process if it |
| + // fails to wait for that process to exit. |
| + // - The exit code from the fallback crash handler process. |
| + // - The error encountered in retrieving the crash handler process' exit code. |
| + DWORD LaunchAndWaitForHandler(EXCEPTION_POINTERS* pointers); |
| + |
| + private: |
| + // A copy of the actual exception pointers made at time of exception. |
| + EXCEPTION_POINTERS exception_pointers_; |
| + |
| + // The precomputed startup info and command line for launching the fallback |
| + // handler. |
| + base::win::StartupInformation startup_info_; |
| + // Stores the pre-cooked command line, with an allottment of zeros at the back |
|
scottmg
2017/01/06 18:29:04
allotment
Sigurður Ásgeirsson
2017/01/06 20:59:10
Done.
|
| + // sufficient for writing in the thread id, just before launch. |
| + std::vector<wchar_t> cmd_line_; |
| + |
| + // An inheritable handle to our own process, the raw handle is necessary |
| + // for pre-computing the startup info. |
| + base::win::ScopedHandle self_process_handle_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FallbackCrashHandlerLauncher); |
| +}; |
| + |
| +} // namespace crash_reporter |
| + |
| +#endif // COMPONENTS_CRASH_CONTENT_APP_FALLBACK_CRASH_HANDLER_LAUNCHER_WIN_H_ |