| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 if (app_instance()) | 56 if (app_instance()) |
| 57 observer->OnAppInstanceReady(); | 57 observer->OnAppInstanceReady(); |
| 58 if (auth_instance()) | 58 if (auth_instance()) |
| 59 observer->OnAuthInstanceReady(); | 59 observer->OnAuthInstanceReady(); |
| 60 if (clipboard_instance()) | 60 if (clipboard_instance()) |
| 61 observer->OnClipboardInstanceReady(); | 61 observer->OnClipboardInstanceReady(); |
| 62 if (ime_instance()) | 62 if (ime_instance()) |
| 63 observer->OnImeInstanceReady(); | 63 observer->OnImeInstanceReady(); |
| 64 if (input_instance()) | 64 if (input_instance()) |
| 65 observer->OnInputInstanceReady(); | 65 observer->OnInputInstanceReady(); |
| 66 if (net_instance()) |
| 67 observer->OnNetInstanceReady(); |
| 66 if (notifications_instance()) | 68 if (notifications_instance()) |
| 67 observer->OnNotificationsInstanceReady(); | 69 observer->OnNotificationsInstanceReady(); |
| 68 if (power_instance()) | 70 if (power_instance()) |
| 69 observer->OnPowerInstanceReady(); | 71 observer->OnPowerInstanceReady(); |
| 70 if (process_instance()) | 72 if (process_instance()) |
| 71 observer->OnProcessInstanceReady(); | 73 observer->OnProcessInstanceReady(); |
| 72 if (video_instance()) | 74 if (video_instance()) |
| 73 observer->OnVideoInstanceReady(); | 75 observer->OnVideoInstanceReady(); |
| 74 } | 76 } |
| 75 | 77 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 220 |
| 219 void ArcBridgeService::CloseIntentHelperChannel() { | 221 void ArcBridgeService::CloseIntentHelperChannel() { |
| 220 DCHECK(CalledOnValidThread()); | 222 DCHECK(CalledOnValidThread()); |
| 221 if (!intent_helper_ptr_) | 223 if (!intent_helper_ptr_) |
| 222 return; | 224 return; |
| 223 | 225 |
| 224 intent_helper_ptr_.reset(); | 226 intent_helper_ptr_.reset(); |
| 225 FOR_EACH_OBSERVER(Observer, observer_list(), OnIntentHelperInstanceClosed()); | 227 FOR_EACH_OBSERVER(Observer, observer_list(), OnIntentHelperInstanceClosed()); |
| 226 } | 228 } |
| 227 | 229 |
| 230 void ArcBridgeService::OnNetInstanceReady(NetInstancePtr net_ptr) { |
| 231 DCHECK(CalledOnValidThread()); |
| 232 temporary_net_ptr_ = std::move(net_ptr); |
| 233 temporary_net_ptr_.QueryVersion(base::Bind( |
| 234 &ArcBridgeService::OnNetVersionReady, weak_factory_.GetWeakPtr())); |
| 235 } |
| 236 |
| 237 void ArcBridgeService::OnNetVersionReady(int32_t version) { |
| 238 DCHECK(CalledOnValidThread()); |
| 239 net_ptr_ = std::move(temporary_net_ptr_); |
| 240 net_ptr_.set_connection_error_handler(base::Bind( |
| 241 &ArcBridgeService::CloseNetChannel, weak_factory_.GetWeakPtr())); |
| 242 FOR_EACH_OBSERVER(Observer, observer_list(), OnNetInstanceReady()); |
| 243 } |
| 244 |
| 245 void ArcBridgeService::CloseNetChannel() { |
| 246 DCHECK(CalledOnValidThread()); |
| 247 if (!net_ptr_) |
| 248 return; |
| 249 |
| 250 net_ptr_.reset(); |
| 251 FOR_EACH_OBSERVER(Observer, observer_list(), OnNetInstanceClosed()); |
| 252 } |
| 253 |
| 228 void ArcBridgeService::OnNotificationsInstanceReady( | 254 void ArcBridgeService::OnNotificationsInstanceReady( |
| 229 NotificationsInstancePtr notifications_ptr) { | 255 NotificationsInstancePtr notifications_ptr) { |
| 230 DCHECK(CalledOnValidThread()); | 256 DCHECK(CalledOnValidThread()); |
| 231 temporary_notifications_ptr_ = std::move(notifications_ptr); | 257 temporary_notifications_ptr_ = std::move(notifications_ptr); |
| 232 temporary_notifications_ptr_.QueryVersion( | 258 temporary_notifications_ptr_.QueryVersion( |
| 233 base::Bind(&ArcBridgeService::OnNotificationsVersionReady, | 259 base::Bind(&ArcBridgeService::OnNotificationsVersionReady, |
| 234 weak_factory_.GetWeakPtr())); | 260 weak_factory_.GetWeakPtr())); |
| 235 } | 261 } |
| 236 | 262 |
| 237 void ArcBridgeService::OnNotificationsVersionReady(int32_t version) { | 263 void ArcBridgeService::OnNotificationsVersionReady(int32_t version) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 376 |
| 351 void ArcBridgeService::CloseAllChannels() { | 377 void ArcBridgeService::CloseAllChannels() { |
| 352 // Call all the error handlers of all the channels to both close the channel | 378 // Call all the error handlers of all the channels to both close the channel |
| 353 // and notify any observers that the channel is closed. | 379 // and notify any observers that the channel is closed. |
| 354 CloseAppChannel(); | 380 CloseAppChannel(); |
| 355 CloseAuthChannel(); | 381 CloseAuthChannel(); |
| 356 CloseClipboardChannel(); | 382 CloseClipboardChannel(); |
| 357 CloseImeChannel(); | 383 CloseImeChannel(); |
| 358 CloseInputChannel(); | 384 CloseInputChannel(); |
| 359 CloseIntentHelperChannel(); | 385 CloseIntentHelperChannel(); |
| 386 CloseNetChannel(); |
| 360 CloseNotificationsChannel(); | 387 CloseNotificationsChannel(); |
| 361 ClosePowerChannel(); | 388 ClosePowerChannel(); |
| 362 CloseProcessChannel(); | 389 CloseProcessChannel(); |
| 363 CloseVideoChannel(); | 390 CloseVideoChannel(); |
| 364 } | 391 } |
| 365 | 392 |
| 366 } // namespace arc | 393 } // namespace arc |
| OLD | NEW |