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

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

Issue 1495723004: Minimum implementation of ARC clipboard Bridge (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed tryboy warnings 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
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 interface state changes. 76 // Called whenever the ARC app interface state changes.
77 virtual void OnAppInstanceReady() {} 77 virtual void OnAppInstanceReady() {}
78 virtual void OnAppInstanceClosed() {} 78 virtual void OnAppInstanceClosed() {}
79 79
80 // Called whenever the ARC clipboard interface state changes.
81 virtual void OnClipboardInstanceReady() {}
82 virtual void OnClipboardInstanceClosed() {}
83
80 // Called whenever the ARC input interface state changes. 84 // Called whenever the ARC input interface state changes.
81 virtual void OnInputInstanceReady() {} 85 virtual void OnInputInstanceReady() {}
82 virtual void OnInputInstanceClosed() {} 86 virtual void OnInputInstanceClosed() {}
83 87
84 // Called whenever the ARC notification interface state changes. 88 // Called whenever the ARC notification interface state changes.
85 virtual void OnNotificationsInstanceReady() {} 89 virtual void OnNotificationsInstanceReady() {}
86 virtual void OnNotificationsInstanceClosed() {} 90 virtual void OnNotificationsInstanceClosed() {}
87 91
88 // Called whenever the ARC power interface state changes. 92 // Called whenever the ARC power interface state changes.
89 virtual void OnPowerInstanceReady() {} 93 virtual void OnPowerInstanceReady() {}
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // Adds or removes observers. This can only be called on the thread that this 132 // Adds or removes observers. This can only be called on the thread that this
129 // class was created on. 133 // class was created on.
130 void AddObserver(Observer* observer); 134 void AddObserver(Observer* observer);
131 void RemoveObserver(Observer* observer); 135 void RemoveObserver(Observer* observer);
132 136
133 // Gets the Mojo interface for all the instance services. This will return 137 // Gets the Mojo interface for all the instance services. This will return
134 // nullptr if that particular service is not ready yet. Use an Observer if 138 // nullptr if that particular service is not ready yet. Use an Observer if
135 // you want to be notified when this is ready. This can only be called on the 139 // you want to be notified when this is ready. This can only be called on the
136 // thread that this class was created on. 140 // thread that this class was created on.
137 AppInstance* app_instance() { return app_ptr_.get(); } 141 AppInstance* app_instance() { return app_ptr_.get(); }
142 ClipboardInstance* clipboard_instance() { return clipboard_ptr_.get(); }
138 InputInstance* input_instance() { return input_ptr_.get(); } 143 InputInstance* input_instance() { return input_ptr_.get(); }
139 NotificationsInstance* notifications_instance() { 144 NotificationsInstance* notifications_instance() {
140 return notifications_ptr_.get(); 145 return notifications_ptr_.get();
141 } 146 }
142 PowerInstance* power_instance() { return power_ptr_.get(); } 147 PowerInstance* power_instance() { return power_ptr_.get(); }
143 ProcessInstance* process_instance() { return process_ptr_.get(); } 148 ProcessInstance* process_instance() { return process_ptr_.get(); }
144 SettingsInstance* settings_instance() { return settings_ptr_.get(); } 149 SettingsInstance* settings_instance() { return settings_ptr_.get(); }
145 150
146 int32_t app_version() const { return app_ptr_.version(); } 151 int32_t app_version() const { return app_ptr_.version(); }
152 int32_t clipboard_version() const { return clipboard_ptr_.version(); }
147 int32_t input_version() const { return input_ptr_.version(); } 153 int32_t input_version() const { return input_ptr_.version(); }
148 int32_t notifications_version() const { return notifications_ptr_.version(); } 154 int32_t notifications_version() const { return notifications_ptr_.version(); }
149 int32_t power_version() const { return power_ptr_.version(); } 155 int32_t power_version() const { return power_ptr_.version(); }
150 int32_t process_version() const { return process_ptr_.version(); } 156 int32_t process_version() const { return process_ptr_.version(); }
151 int32_t settings_version() const { return settings_ptr_.version(); } 157 int32_t settings_version() const { return settings_ptr_.version(); }
152 158
153 // ArcHost: 159 // ArcHost:
154 void OnAppInstanceReady(AppInstancePtr app_ptr) override; 160 void OnAppInstanceReady(AppInstancePtr app_ptr) override;
161 void OnClipboardInstanceReady(ClipboardInstancePtr clipboard_ptr) override;
155 void OnInputInstanceReady(InputInstancePtr input_ptr) override; 162 void OnInputInstanceReady(InputInstancePtr input_ptr) override;
156 void OnNotificationsInstanceReady( 163 void OnNotificationsInstanceReady(
157 NotificationsInstancePtr notifications_ptr) override; 164 NotificationsInstancePtr notifications_ptr) override;
158 void OnPowerInstanceReady(PowerInstancePtr power_ptr) override; 165 void OnPowerInstanceReady(PowerInstancePtr power_ptr) override;
159 void OnProcessInstanceReady(ProcessInstancePtr process_ptr) override; 166 void OnProcessInstanceReady(ProcessInstancePtr process_ptr) override;
160 void OnSettingsInstanceReady(SettingsInstancePtr process_ptr) override; 167 void OnSettingsInstanceReady(SettingsInstancePtr process_ptr) override;
161 168
162 // Gets the current state of the bridge service. 169 // Gets the current state of the bridge service.
163 State state() const { return state_; } 170 State state() const { return state_; }
164 171
(...skipping 18 matching lines...) Expand all
183 190
184 private: 191 private:
185 friend class ArcBridgeTest; 192 friend class ArcBridgeTest;
186 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic); 193 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Basic);
187 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites); 194 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Prerequisites);
188 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup); 195 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, ShutdownMidStartup);
189 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart); 196 FRIEND_TEST_ALL_PREFIXES(ArcBridgeTest, Restart);
190 197
191 // Called when one of the individual channels is closed. 198 // Called when one of the individual channels is closed.
192 void CloseAppChannel(); 199 void CloseAppChannel();
200 void CloseClipboardChannel();
193 void CloseInputChannel(); 201 void CloseInputChannel();
194 void CloseNotificationsChannel(); 202 void CloseNotificationsChannel();
195 void ClosePowerChannel(); 203 void ClosePowerChannel();
196 void CloseProcessChannel(); 204 void CloseProcessChannel();
197 void CloseSettingsChannel(); 205 void CloseSettingsChannel();
198 206
199 // Callbacks for QueryVersion. 207 // Callbacks for QueryVersion.
200 void OnAppVersionReady(int32_t version); 208 void OnAppVersionReady(int32_t version);
209 void OnClipboardVersionReady(int32_t version);
201 void OnInputVersionReady(int32_t version); 210 void OnInputVersionReady(int32_t version);
202 void OnNotificationsVersionReady(int32_t version); 211 void OnNotificationsVersionReady(int32_t version);
203 void OnPowerVersionReady(int32_t version); 212 void OnPowerVersionReady(int32_t version);
204 void OnProcessVersionReady(int32_t version); 213 void OnProcessVersionReady(int32_t version);
205 void OnSettingsVersionReady(int32_t version); 214 void OnSettingsVersionReady(int32_t version);
206 215
207 // Mojo interfaces. 216 // Mojo interfaces.
208 AppInstancePtr app_ptr_; 217 AppInstancePtr app_ptr_;
218 ClipboardInstancePtr clipboard_ptr_;
209 InputInstancePtr input_ptr_; 219 InputInstancePtr input_ptr_;
210 NotificationsInstancePtr notifications_ptr_; 220 NotificationsInstancePtr notifications_ptr_;
211 PowerInstancePtr power_ptr_; 221 PowerInstancePtr power_ptr_;
212 ProcessInstancePtr process_ptr_; 222 ProcessInstancePtr process_ptr_;
213 SettingsInstancePtr settings_ptr_; 223 SettingsInstancePtr settings_ptr_;
214 224
215 // Temporary Mojo interfaces. After a Mojo interface pointer has been 225 // Temporary Mojo interfaces. After a Mojo interface pointer has been
216 // received from the other endpoint, we still need to asynchronously query 226 // received from the other endpoint, we still need to asynchronously query
217 // its version. While that is going on, we should still return nullptr on 227 // its version. While that is going on, we should still return nullptr on
218 // the xxx_instance() functions. 228 // the xxx_instance() functions.
219 // To keep the xxx_instance() functions being trivial, store the instance 229 // To keep the xxx_instance() functions being trivial, store the instance
220 // pointer in a temporary variable to avoid losing its reference. 230 // pointer in a temporary variable to avoid losing its reference.
221 AppInstancePtr temporary_app_ptr_; 231 AppInstancePtr temporary_app_ptr_;
232 ClipboardInstancePtr temporary_clipboard_ptr_;
222 InputInstancePtr temporary_input_ptr_; 233 InputInstancePtr temporary_input_ptr_;
223 NotificationsInstancePtr temporary_notifications_ptr_; 234 NotificationsInstancePtr temporary_notifications_ptr_;
224 PowerInstancePtr temporary_power_ptr_; 235 PowerInstancePtr temporary_power_ptr_;
225 ProcessInstancePtr temporary_process_ptr_; 236 ProcessInstancePtr temporary_process_ptr_;
226 SettingsInstancePtr temporary_settings_ptr_; 237 SettingsInstancePtr temporary_settings_ptr_;
227 238
228 base::ObserverList<Observer> observer_list_; 239 base::ObserverList<Observer> observer_list_;
229 240
230 base::ThreadChecker thread_checker_; 241 base::ThreadChecker thread_checker_;
231 242
232 // If the ARC instance service is available. 243 // If the ARC instance service is available.
233 bool available_; 244 bool available_;
234 245
235 // The current state of the bridge. 246 // The current state of the bridge.
236 ArcBridgeService::State state_; 247 ArcBridgeService::State state_;
237 248
238 // WeakPtrFactory to use callbacks. 249 // WeakPtrFactory to use callbacks.
239 base::WeakPtrFactory<ArcBridgeService> weak_factory_; 250 base::WeakPtrFactory<ArcBridgeService> weak_factory_;
240 251
241 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); 252 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService);
242 }; 253 };
243 254
244 } // namespace arc 255 } // namespace arc
245 256
246 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 257 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698