OLD | NEW |
---|---|
(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_DUMP_OBSERVER_ANDROID_H_ | |
6 #define COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_DUMP_OBSERVER_ANDROID_H_ | |
7 | |
8 #include <list> | |
9 #include <memory> | |
10 | |
11 #include "base/android/application_status_listener.h" | |
12 #include "base/memory/singleton.h" | |
13 #include "base/memory/weak_ptr.h" | |
14 #include "base/process/kill.h" | |
15 #include "base/process/process.h" | |
16 #include "content/public/browser/browser_child_process_observer.h" | |
17 #include "content/public/browser/file_descriptor_info.h" | |
18 #include "content/public/browser/notification_observer.h" | |
19 #include "content/public/browser/notification_registrar.h" | |
20 #include "content/public/common/process_type.h" | |
21 | |
22 namespace breakpad { | |
23 | |
24 // This class centralises the observation of child processes for the | |
25 // purpose of reacting to child process crashes. | |
26 class CrashDumpObserver : public content::BrowserChildProcessObserver, | |
27 public content::NotificationObserver { | |
28 public: | |
29 class Client { | |
30 public: | |
31 Client() {} | |
Robert Sesek
2016/08/04 16:59:01
For pure virtual interfaces, you don't need to pro
Tobias Sargeant
2016/08/05 14:59:22
Done.
| |
32 virtual ~Client() {} | |
33 | |
34 virtual void OnChildStart(int child_process_id, | |
35 content::FileDescriptorInfo* mappings) = 0; | |
36 virtual void OnChildExit(int child_process_id, | |
37 base::ProcessHandle pid, | |
38 content::ProcessType process_type, | |
39 base::TerminationStatus termination_status, | |
40 base::android::ApplicationState app_state) = 0; | |
41 | |
42 DISALLOW_COPY_AND_ASSIGN(Client); | |
43 }; | |
44 | |
45 static CrashDumpObserver* GetInstance(); | |
46 | |
47 void RegisterClient(Client* client); | |
48 void UnregisterClient(Client* client); | |
49 | |
50 void BrowserChildProcessStarted(int child_process_id, | |
51 content::FileDescriptorInfo* mappings); | |
52 | |
53 private: | |
54 friend struct base::DefaultSingletonTraits<CrashDumpObserver>; | |
55 | |
56 CrashDumpObserver(); | |
57 ~CrashDumpObserver() override; | |
58 | |
59 // content::BrowserChildProcessObserver implementation: | |
60 void BrowserChildProcessHostDisconnected( | |
61 const content::ChildProcessData& data) override; | |
62 void BrowserChildProcessCrashed(const content::ChildProcessData& data, | |
63 int exit_code) override; | |
64 | |
65 // NotificationObserver implementation: | |
66 void Observe(int type, | |
67 const content::NotificationSource& source, | |
68 const content::NotificationDetails& details) override; | |
69 | |
70 // Called on child process exit (including crash). | |
71 void OnChildExit(int child_process_id, | |
72 base::ProcessHandle pid, | |
73 content::ProcessType process_type, | |
74 base::TerminationStatus termination_status, | |
75 base::android::ApplicationState app_state); | |
76 | |
77 content::NotificationRegistrar notification_registrar_; | |
78 | |
79 base::Lock registered_clients_lock_; | |
80 std::list<Client*> registered_clients_; | |
Robert Sesek
2016/08/04 16:59:01
Could you use base::ObserverListThreadSafe instead
Tobias Sargeant
2016/08/05 14:59:22
I looked at this, and I'm not sure that it's compa
| |
81 | |
82 base::WeakPtrFactory<CrashDumpObserver> weak_factory_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(CrashDumpObserver); | |
85 }; | |
86 | |
87 } // namespace breakpad | |
88 | |
89 #endif // COMPONENTS_CRASH_CONTENT_BROWSER_CRASH_DUMP_OBSERVER_ANDROID_H_ | |
OLD | NEW |