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

Side by Side Diff: components/crash/content/browser/crash_micro_dump_manager_android.h

Issue 1525023003: Distinguish in the browser between renderer crashes and kills (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use base::SyncSocket Created 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_MICRO_DUMP_MANAGER_ANDROID_H_
6 #define COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_MICRO_DUMP_MANAGER_ANDROID_H_
7
8 #include <map>
9
10 #include "base/files/scoped_file.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/process/kill.h"
14 #include "base/sync_socket.h"
15 #include "base/synchronization/lock.h"
16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h"
18
19 namespace breakpad {
20
21 // This class manages behavior of the browser on renderer crashes when
22 // microdumps are used for capturing the crash stack. Normally, in this case
23 // the browser doesn't need to do much, because a microdump is written into
24 // Android log by the renderer process itself. However, the browser may need to
25 // crash itself on a renderer crash. Since on Android renderers are not child
26 // processes of the browser, it can't access the exit code. Instead, the browser
27 // uses a dedicated pipe in order to receive the information about the renderer
28 // crash status.
29 class CrashMicroDumpManager : public content::NotificationObserver {
30 public:
31 // The embedder should create a single instance of the CrashMicroDumpManager.
32 static CrashMicroDumpManager* GetInstance();
33
34 // Should be created on the UI thread.
35 CrashMicroDumpManager();
36
37 ~CrashMicroDumpManager() override;
38
39 // Returns a pipe that should be used to transfer termination cause of
40 // |child_process_id|.
41 base::ScopedFD CreateCrashInfoChannel(int child_process_id);
42
43 private:
44 // NotificationObserver implementation:
45 void Observe(int type,
46 const content::NotificationSource& source,
47 const content::NotificationDetails& details) override;
48
49 // Called on child process exit (including crash).
50 void HandleChildTerminationOnFileThread(
51 int child_process_id,
52 base::TerminationStatus termination_status);
53
54 content::NotificationRegistrar notification_registrar_;
55
56 // This map should only be accessed with its lock aquired as it is accessed
57 // from the PROCESS_LAUNCHER and FILE threads.
58 base::Lock child_process_id_to_pipe_lock_;
59 std::map<int, base::SyncSocket*> child_process_id_to_pipe_;
Robert Sesek 2016/01/07 20:02:22 Now that we've got C++11, you can put the scoped_p
mnaganov (inactive) 2016/01/07 21:39:50 Right, thanks! For some reason I was thinking it's
60 base::WeakPtrFactory<CrashMicroDumpManager> weak_factory_;
61
62 static CrashMicroDumpManager* instance_;
63
64 DISALLOW_COPY_AND_ASSIGN(CrashMicroDumpManager);
65 };
66
67 } // namespace breakpad
68
69 #endif // COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_MICRO_DUMP_MANAGER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698