| Index: components/crash/content/browser/crash_micro_dump_manager_android.h
|
| diff --git a/components/crash/content/browser/crash_micro_dump_manager_android.h b/components/crash/content/browser/crash_micro_dump_manager_android.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..bdc739bb9a0b35eefaab17424d73496f0ab96cf0
|
| --- /dev/null
|
| +++ b/components/crash/content/browser/crash_micro_dump_manager_android.h
|
| @@ -0,0 +1,77 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_MICRO_DUMP_MANAGER_ANDROID_H_
|
| +#define COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_MICRO_DUMP_MANAGER_ANDROID_H_
|
| +
|
| +#include <map>
|
| +
|
| +#include "base/files/file.h"
|
| +#include "base/process/kill.h"
|
| +#include "base/synchronization/lock.h"
|
| +#include "content/public/browser/browser_child_process_observer.h"
|
| +#include "content/public/browser/notification_observer.h"
|
| +#include "content/public/browser/notification_registrar.h"
|
| +
|
| +namespace breakpad {
|
| +
|
| +// This class manages behavior of the browser on renderer crashes when
|
| +// microdumps are used for capturing the crash stack. Normally, in this case
|
| +// the browser doesn't need to do much, because a microdump is written into
|
| +// Android log by the renderer process itself. However, the browser may need to
|
| +// crash itself on a renderer crash. Since on Android renderers are not child
|
| +// processes of the browser, it can't access the exit code. Instead, the browser
|
| +// uses a dedicated pipe in order to receive the information about the renderer
|
| +// crash status.
|
| +class CrashMicroDumpManager : public content::BrowserChildProcessObserver,
|
| + public content::NotificationObserver {
|
| + public:
|
| + // The embedder should create a single instance of the CrashMicroDumpManager.
|
| + static CrashMicroDumpManager* GetInstance();
|
| +
|
| + // Should be created on the UI thread.
|
| + CrashMicroDumpManager();
|
| +
|
| + ~CrashMicroDumpManager() override;
|
| +
|
| + // Returns a pipe that should be used to transfer termination cause of
|
| + // |child_process_id|.
|
| + base::File CreateCrashInfoChannel(int child_process_id);
|
| +
|
| + private:
|
| + static void HandleChildTermination(
|
| + int pipe_fd,
|
| + base::TerminationStatus termination_status);
|
| +
|
| + // content::BrowserChildProcessObserver implementation:
|
| + void BrowserChildProcessHostDisconnected(
|
| + const content::ChildProcessData& data) override;
|
| + void BrowserChildProcessCrashed(
|
| + const content::ChildProcessData& data,
|
| + int exit_code) override;
|
| +
|
| + // NotificationObserver implementation:
|
| + void Observe(int type,
|
| + const content::NotificationSource& source,
|
| + const content::NotificationDetails& details) override;
|
| +
|
| + // Called on child process exit (including crash).
|
| + void OnChildExit(int child_process_id,
|
| + base::TerminationStatus termination_status);
|
| +
|
| + content::NotificationRegistrar notification_registrar_;
|
| +
|
| + // This map should only be accessed with its lock aquired as it is accessed
|
| + // from the PROCESS_LAUNCHER and UI threads.
|
| + base::Lock child_process_id_to_pipe_fd_lock_;
|
| + std::map<int, int> child_process_id_to_pipe_fd_;
|
| +
|
| + static CrashMicroDumpManager* instance_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CrashMicroDumpManager);
|
| +};
|
| +
|
| +} // namespace breakpad
|
| +
|
| +#endif // COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_MICRO_DUMP_MANAGER_ANDROID_H_
|
|
|