| OLD | NEW |
| 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 #include "components/arc/arc_bridge_service.h" | 5 #include "components/arc/arc_bridge_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 void ArcBridgeService::CloseSettingsChannel() { | 221 void ArcBridgeService::CloseSettingsChannel() { |
| 222 DCHECK(CalledOnValidThread()); | 222 DCHECK(CalledOnValidThread()); |
| 223 if (!settings_ptr_) | 223 if (!settings_ptr_) |
| 224 return; | 224 return; |
| 225 | 225 |
| 226 settings_ptr_.reset(); | 226 settings_ptr_.reset(); |
| 227 FOR_EACH_OBSERVER(Observer, observer_list(), OnSettingsInstanceClosed()); | 227 FOR_EACH_OBSERVER(Observer, observer_list(), OnSettingsInstanceClosed()); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void ArcBridgeService::OnVideoInstanceReady(VideoInstancePtr video_ptr) { |
| 231 DCHECK(CalledOnValidThread()); |
| 232 temporary_video_ptr_ = std::move(video_ptr); |
| 233 temporary_video_ptr_.QueryVersion(base::Bind( |
| 234 &ArcBridgeService::OnVideoVersionReady, weak_factory_.GetWeakPtr())); |
| 235 } |
| 236 |
| 237 void ArcBridgeService::OnVideoVersionReady(int32_t version) { |
| 238 video_ptr_ = std::move(temporary_video_ptr_); |
| 239 FOR_EACH_OBSERVER(Observer, observer_list(), OnVideoInstanceReady()); |
| 240 video_ptr_.set_connection_error_handler(base::Bind( |
| 241 &ArcBridgeService::CloseVideoChannel, weak_factory_.GetWeakPtr())); |
| 242 } |
| 243 |
| 244 void ArcBridgeService::CloseVideoChannel() { |
| 245 DCHECK(CalledOnValidThread()); |
| 246 if (!video_ptr_) |
| 247 return; |
| 248 |
| 249 video_ptr_.reset(); |
| 250 FOR_EACH_OBSERVER(Observer, observer_list(), OnVideoInstanceClosed()); |
| 251 } |
| 252 |
| 230 void ArcBridgeService::SetState(State state) { | 253 void ArcBridgeService::SetState(State state) { |
| 231 DCHECK(CalledOnValidThread()); | 254 DCHECK(CalledOnValidThread()); |
| 232 // DCHECK on enum classes not supported. | 255 // DCHECK on enum classes not supported. |
| 233 DCHECK(state_ != state); | 256 DCHECK(state_ != state); |
| 234 state_ = state; | 257 state_ = state; |
| 235 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); | 258 FOR_EACH_OBSERVER(Observer, observer_list(), OnStateChanged(state_)); |
| 236 } | 259 } |
| 237 | 260 |
| 238 void ArcBridgeService::SetAvailable(bool available) { | 261 void ArcBridgeService::SetAvailable(bool available) { |
| 239 DCHECK(CalledOnValidThread()); | 262 DCHECK(CalledOnValidThread()); |
| 240 DCHECK(available_ != available); | 263 DCHECK(available_ != available); |
| 241 available_ = available; | 264 available_ = available; |
| 242 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); | 265 FOR_EACH_OBSERVER(Observer, observer_list(), OnAvailableChanged(available_)); |
| 243 } | 266 } |
| 244 | 267 |
| 245 bool ArcBridgeService::CalledOnValidThread() { | 268 bool ArcBridgeService::CalledOnValidThread() { |
| 246 return thread_checker_.CalledOnValidThread(); | 269 return thread_checker_.CalledOnValidThread(); |
| 247 } | 270 } |
| 248 | 271 |
| 249 void ArcBridgeService::CloseAllChannels() { | 272 void ArcBridgeService::CloseAllChannels() { |
| 250 // Call all the error handlers of all the channels to both close the channel | 273 // Call all the error handlers of all the channels to both close the channel |
| 251 // and notify any observers that the channel is closed. | 274 // and notify any observers that the channel is closed. |
| 252 CloseAppChannel(); | 275 CloseAppChannel(); |
| 253 CloseAuthChannel(); | 276 CloseAuthChannel(); |
| 254 CloseInputChannel(); | 277 CloseInputChannel(); |
| 255 CloseNotificationsChannel(); | 278 CloseNotificationsChannel(); |
| 256 ClosePowerChannel(); | 279 ClosePowerChannel(); |
| 257 CloseProcessChannel(); | 280 CloseProcessChannel(); |
| 258 CloseSettingsChannel(); | 281 CloseSettingsChannel(); |
| 282 CloseVideoChannel(); |
| 259 } | 283 } |
| 260 | 284 |
| 261 } // namespace arc | 285 } // namespace arc |
| OLD | NEW |