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

Side by Side Diff: components/arc/arc_bridge_service.h

Issue 1548833002: arc-bridge: Restart ARC instance on crash (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Created 5 years 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 2015 The Chromium Authors. All rights reserved. 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 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 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 5 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 // Notifies life cycle events of ArcBridgeService. 67 // Notifies life cycle events of ArcBridgeService.
68 class Observer { 68 class Observer {
69 public: 69 public:
70 // Called whenever the state of the bridge has changed. 70 // Called whenever the state of the bridge has changed.
71 virtual void OnStateChanged(State state) {} 71 virtual void OnStateChanged(State state) {}
72 72
73 // Called whenever ARC's availability has changed for this system. 73 // Called whenever ARC's availability has changed for this system.
74 virtual void OnAvailableChanged(bool available) {} 74 virtual void OnAvailableChanged(bool available) {}
75 75
76 // Called whenever the ARC app list is ready. 76 // Called whenever the ARC app interface state changes.
77 virtual void OnAppInstanceReady() {} 77 virtual void OnAppInstanceReady() {}
78 virtual void OnAppInstanceClosed() {}
78 79
79 // Called whenever the ARC input is ready. 80 // Called whenever the ARC input interface state changes.
80 virtual void OnInputInstanceReady() {} 81 virtual void OnInputInstanceReady() {}
82 virtual void OnInputInstanceClosed() {}
81 83
82 // Called whenever the ARC notification is ready. 84 // Called whenever the ARC notification interface state changes.
83 virtual void OnNotificationsInstanceReady() {} 85 virtual void OnNotificationsInstanceReady() {}
86 virtual void OnNotificationsInstanceClosed() {}
84 87
85 // Called whenever the ARC power is ready. 88 // Called whenever the ARC power interface state changes.
86 virtual void OnPowerInstanceReady() {} 89 virtual void OnPowerInstanceReady() {}
90 virtual void OnPowerInstanceClosed() {}
87 91
88 // Called whenever the ARC process is ready. 92 // Called whenever the ARC process interface state changes.
89 virtual void OnProcessInstanceReady() {} 93 virtual void OnProcessInstanceReady() {}
94 virtual void OnProcessInstanceClosed() {}
90 95
91 // Called whenever the ARC settings is ready. 96 // Called whenever the ARC settings interface state changes.
92 virtual void OnSettingsInstanceReady() {} 97 virtual void OnSettingsInstanceReady() {}
98 virtual void OnSettingsInstanceClosed() {}
93 99
94 protected: 100 protected:
95 virtual ~Observer() {} 101 virtual ~Observer() {}
96 }; 102 };
97 103
98 ~ArcBridgeService() override; 104 ~ArcBridgeService() override;
99 105
100 // Gets the global instance of the ARC Bridge Service. This can only be 106 // Gets the global instance of the ARC Bridge Service. This can only be
101 // called on the thread that this class was created on. 107 // called on the thread that this class was created on.
102 static ArcBridgeService* Get(); 108 static ArcBridgeService* Get();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // Changes the current state and notifies all observers. 164 // Changes the current state and notifies all observers.
159 void SetState(State state); 165 void SetState(State state);
160 166
161 // Changes the current availability and notifies all observers. 167 // Changes the current availability and notifies all observers.
162 void SetAvailable(bool availability); 168 void SetAvailable(bool availability);
163 169
164 base::ObserverList<Observer>& observer_list() { return observer_list_; } 170 base::ObserverList<Observer>& observer_list() { return observer_list_; }
165 171
166 bool CalledOnValidThread(); 172 bool CalledOnValidThread();
167 173
174 // Closes all Mojo channels.
175 void CloseAllChannels();
176
168 private: 177 private:
169 friend class ArcBridgeTest; 178 friend class ArcBridgeTest;
170 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); 179 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic);
171 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); 180 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites);
172 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); 181 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup);
182 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart);
183
184 // Called when one of the individual channels is closed.
185 void OnAppChannelClosed();
186 void OnInputChannelClosed();
187 void OnNotificationsChannelClosed();
188 void OnPowerChannelClosed();
189 void OnProcessChannelClosed();
190 void OnSettingsChannelClosed();
173 191
174 // Mojo interfaces. 192 // Mojo interfaces.
175 AppInstancePtr app_ptr_; 193 AppInstancePtr app_ptr_;
176 InputInstancePtr input_ptr_; 194 InputInstancePtr input_ptr_;
177 NotificationsInstancePtr notifications_ptr_; 195 NotificationsInstancePtr notifications_ptr_;
178 PowerInstancePtr power_ptr_; 196 PowerInstancePtr power_ptr_;
179 ProcessInstancePtr process_ptr_; 197 ProcessInstancePtr process_ptr_;
180 SettingsInstancePtr settings_ptr_; 198 SettingsInstancePtr settings_ptr_;
181 199
182 base::ObserverList<Observer> observer_list_; 200 base::ObserverList<Observer> observer_list_;
183 201
184 base::ThreadChecker thread_checker_; 202 base::ThreadChecker thread_checker_;
185 203
186 // If the ARC instance service is available. 204 // If the ARC instance service is available.
187 bool available_; 205 bool available_;
188 206
189 // The current state of the bridge. 207 // The current state of the bridge.
190 ArcBridgeService::State state_; 208 ArcBridgeService::State state_;
191 209
210 // WeakPtrFactory to use callbacks.
211 base::WeakPtrFactory<ArcBridgeService> weak_factory_;
212
192 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); 213 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService);
193 }; 214 };
194 215
195 } // namespace arc 216 } // namespace arc
196 217
197 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 218 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698