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

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

Issue 2577373002: Refactor ArcBridgeServiceImpl part 2. (Closed)
Patch Set: Rebase Created 4 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
« no previous file with comments | « no previous file | components/arc/arc_bridge_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <iosfwd> 8 #include <iosfwd>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/files/scoped_file.h"
13 #include "base/macros.h" 12 #include "base/macros.h"
14 #include "base/observer_list.h" 13 #include "base/observer_list.h"
15 #include "base/values.h"
16 #include "components/arc/arc_session_observer.h" 14 #include "components/arc/arc_session_observer.h"
17 #include "components/arc/instance_holder.h" 15 #include "components/arc/instance_holder.h"
18 16
19 namespace base { 17 namespace base {
20 class CommandLine; 18 class CommandLine;
21 } // namespace base 19 } // namespace base
22 20
23 namespace arc { 21 namespace arc {
24 namespace mojom { 22 namespace mojom {
25 23
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 InstanceHolder<mojom::PrintInstance>* print() { return &print_; } 122 InstanceHolder<mojom::PrintInstance>* print() { return &print_; }
125 InstanceHolder<mojom::ProcessInstance>* process() { return &process_; } 123 InstanceHolder<mojom::ProcessInstance>* process() { return &process_; }
126 InstanceHolder<mojom::StorageManagerInstance>* storage_manager() { 124 InstanceHolder<mojom::StorageManagerInstance>* storage_manager() {
127 return &storage_manager_; 125 return &storage_manager_;
128 } 126 }
129 InstanceHolder<mojom::TtsInstance>* tts() { return &tts_; } 127 InstanceHolder<mojom::TtsInstance>* tts() { return &tts_; }
130 InstanceHolder<mojom::VideoInstance>* video() { return &video_; } 128 InstanceHolder<mojom::VideoInstance>* video() { return &video_; }
131 InstanceHolder<mojom::WallpaperInstance>* wallpaper() { return &wallpaper_; } 129 InstanceHolder<mojom::WallpaperInstance>* wallpaper() { return &wallpaper_; }
132 130
133 // Gets if ARC is currently running. 131 // Gets if ARC is currently running.
134 bool ready() const { return state() == State::READY; } 132 bool ready() const { return state() == State::RUNNING; }
135 133
136 // Gets if ARC is currently stopped. This is not exactly !ready() since there 134 // Gets if ARC is currently stopped. This is not exactly !ready() since there
137 // are transient states between ready() and stopped(). 135 // are transient states between ready() and stopped().
138 bool stopped() const { return state() == State::STOPPED; } 136 bool stopped() const { return state() == State::STOPPED; }
139 137
140 protected: 138 protected:
141 // The possible states of the bridge. In the normal flow, the state changes 139 // The possible states of the bridge. In the normal flow, the state changes
142 // in the following sequence: 140 // in the following sequence:
143 // 141 //
144 // STOPPED 142 // STOPPED
145 // PrerequisitesChanged() -> 143 // RequestStart() ->
146 // CONNECTING 144 // STARTING
147 // OnConnectionEstablished() -> 145 // OnSessionReady() ->
148 // READY 146 // READY
149 // 147 //
150 // The ArcSession state machine can be thought of being substates of 148 // The ArcSession state machine can be thought of being substates of
151 // ArcBridgeService's CONNECTING state. 149 // ArcBridgeService's STARTING state.
150 // ArcBridgeService's state machine can be stopped at any phase.
152 // 151 //
153 // * 152 // *
154 // StopInstance() -> 153 // RequestStop() ->
155 // STOPPING 154 // STOPPING
156 // OnStopped() -> 155 // OnSessionStopped() ->
157 // STOPPED 156 // STOPPED
158 enum class State { 157 enum class State {
159 // ARC is not currently running. 158 // ARC instance is not currently running.
160 STOPPED, 159 STOPPED,
161 160
162 // The request to connect has been sent. 161 // Request to start ARC instance is received. Starting an ARC instance.
163 CONNECTING, 162 STARTING,
164 163
165 // The instance has started, and the bridge is fully established. 164 // ARC instance has finished initializing, and is now ready for interaction
166 CONNECTED, 165 // with other services.
166 RUNNING,
167 167
168 // The ARC instance has finished initializing and is now ready for user 168 // Request to stop ARC instance is recieved. Stopping the ARC instance.
169 // interaction.
170 READY,
171
172 // The ARC instance has started shutting down.
173 STOPPING, 169 STOPPING,
174 }; 170 };
175 171
176 // Instance holders. 172 // Instance holders.
177 InstanceHolder<mojom::AppInstance> app_; 173 InstanceHolder<mojom::AppInstance> app_;
178 InstanceHolder<mojom::AudioInstance> audio_; 174 InstanceHolder<mojom::AudioInstance> audio_;
179 InstanceHolder<mojom::AuthInstance> auth_; 175 InstanceHolder<mojom::AuthInstance> auth_;
180 InstanceHolder<mojom::BluetoothInstance> bluetooth_; 176 InstanceHolder<mojom::BluetoothInstance> bluetooth_;
181 InstanceHolder<mojom::BootPhaseMonitorInstance> boot_phase_monitor_; 177 InstanceHolder<mojom::BootPhaseMonitorInstance> boot_phase_monitor_;
182 InstanceHolder<mojom::ClipboardInstance> clipboard_; 178 InstanceHolder<mojom::ClipboardInstance> clipboard_;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 225
230 // WeakPtrFactory to use callbacks. 226 // WeakPtrFactory to use callbacks.
231 base::WeakPtrFactory<ArcBridgeService> weak_factory_; 227 base::WeakPtrFactory<ArcBridgeService> weak_factory_;
232 228
233 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); 229 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService);
234 }; 230 };
235 231
236 } // namespace arc 232 } // namespace arc
237 233
238 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 234 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | components/arc/arc_bridge_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698