| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 if (clipboard_instance()) | 65 if (clipboard_instance()) |
| 66 observer->OnClipboardInstanceReady(); | 66 observer->OnClipboardInstanceReady(); |
| 67 if (ime_instance()) | 67 if (ime_instance()) |
| 68 observer->OnImeInstanceReady(); | 68 observer->OnImeInstanceReady(); |
| 69 if (input_instance()) | 69 if (input_instance()) |
| 70 observer->OnInputInstanceReady(); | 70 observer->OnInputInstanceReady(); |
| 71 if (net_instance()) | 71 if (net_instance()) |
| 72 observer->OnNetInstanceReady(); | 72 observer->OnNetInstanceReady(); |
| 73 if (notifications_instance()) | 73 if (notifications_instance()) |
| 74 observer->OnNotificationsInstanceReady(); | 74 observer->OnNotificationsInstanceReady(); |
| 75 if (policy_instance()) |
| 76 observer->OnPolicyInstanceReady(); |
| 75 if (power_instance()) | 77 if (power_instance()) |
| 76 observer->OnPowerInstanceReady(); | 78 observer->OnPowerInstanceReady(); |
| 77 if (process_instance()) | 79 if (process_instance()) |
| 78 observer->OnProcessInstanceReady(); | 80 observer->OnProcessInstanceReady(); |
| 79 if (video_instance()) | 81 if (video_instance()) |
| 80 observer->OnVideoInstanceReady(); | 82 observer->OnVideoInstanceReady(); |
| 81 } | 83 } |
| 82 | 84 |
| 83 void ArcBridgeService::RemoveObserver(Observer* observer) { | 85 void ArcBridgeService::RemoveObserver(Observer* observer) { |
| 84 DCHECK(CalledOnValidThread()); | 86 DCHECK(CalledOnValidThread()); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 278 |
| 277 void ArcBridgeService::CloseNotificationsChannel() { | 279 void ArcBridgeService::CloseNotificationsChannel() { |
| 278 DCHECK(CalledOnValidThread()); | 280 DCHECK(CalledOnValidThread()); |
| 279 if (!notifications_ptr_) | 281 if (!notifications_ptr_) |
| 280 return; | 282 return; |
| 281 | 283 |
| 282 notifications_ptr_.reset(); | 284 notifications_ptr_.reset(); |
| 283 FOR_EACH_OBSERVER(Observer, observer_list(), OnNotificationsInstanceClosed()); | 285 FOR_EACH_OBSERVER(Observer, observer_list(), OnNotificationsInstanceClosed()); |
| 284 } | 286 } |
| 285 | 287 |
| 288 void ArcBridgeService::OnPolicyInstanceReady(PolicyInstancePtr policy_ptr) { |
| 289 DCHECK(CalledOnValidThread()); |
| 290 temporary_policy_ptr_ = std::move(policy_ptr); |
| 291 temporary_policy_ptr_.QueryVersion(base::Bind( |
| 292 &ArcBridgeService::OnPolicyVersionReady, weak_factory_.GetWeakPtr())); |
| 293 } |
| 294 |
| 295 void ArcBridgeService::OnPolicyVersionReady(int32_t version) { |
| 296 DCHECK(CalledOnValidThread()); |
| 297 policy_ptr_ = std::move(temporary_policy_ptr_); |
| 298 policy_ptr_.set_connection_error_handler(base::Bind( |
| 299 &ArcBridgeService::ClosePolicyChannel, weak_factory_.GetWeakPtr())); |
| 300 FOR_EACH_OBSERVER(Observer, observer_list(), OnPolicyInstanceReady()); |
| 301 } |
| 302 |
| 303 void ArcBridgeService::ClosePolicyChannel() { |
| 304 DCHECK(CalledOnValidThread()); |
| 305 if (!policy_ptr_) |
| 306 return; |
| 307 |
| 308 policy_ptr_.reset(); |
| 309 FOR_EACH_OBSERVER(Observer, observer_list(), OnPolicyInstanceClosed()); |
| 310 } |
| 311 |
| 286 void ArcBridgeService::OnPowerInstanceReady(PowerInstancePtr power_ptr) { | 312 void ArcBridgeService::OnPowerInstanceReady(PowerInstancePtr power_ptr) { |
| 287 DCHECK(CalledOnValidThread()); | 313 DCHECK(CalledOnValidThread()); |
| 288 temporary_power_ptr_ = std::move(power_ptr); | 314 temporary_power_ptr_ = std::move(power_ptr); |
| 289 temporary_power_ptr_.QueryVersion(base::Bind( | 315 temporary_power_ptr_.QueryVersion(base::Bind( |
| 290 &ArcBridgeService::OnPowerVersionReady, weak_factory_.GetWeakPtr())); | 316 &ArcBridgeService::OnPowerVersionReady, weak_factory_.GetWeakPtr())); |
| 291 } | 317 } |
| 292 | 318 |
| 293 void ArcBridgeService::OnPowerVersionReady(int32_t version) { | 319 void ArcBridgeService::OnPowerVersionReady(int32_t version) { |
| 294 DCHECK(CalledOnValidThread()); | 320 DCHECK(CalledOnValidThread()); |
| 295 power_ptr_ = std::move(temporary_power_ptr_); | 321 power_ptr_ = std::move(temporary_power_ptr_); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 // Call all the error handlers of all the channels to both close the channel | 404 // Call all the error handlers of all the channels to both close the channel |
| 379 // and notify any observers that the channel is closed. | 405 // and notify any observers that the channel is closed. |
| 380 CloseAppChannel(); | 406 CloseAppChannel(); |
| 381 CloseAuthChannel(); | 407 CloseAuthChannel(); |
| 382 CloseClipboardChannel(); | 408 CloseClipboardChannel(); |
| 383 CloseImeChannel(); | 409 CloseImeChannel(); |
| 384 CloseInputChannel(); | 410 CloseInputChannel(); |
| 385 CloseIntentHelperChannel(); | 411 CloseIntentHelperChannel(); |
| 386 CloseNetChannel(); | 412 CloseNetChannel(); |
| 387 CloseNotificationsChannel(); | 413 CloseNotificationsChannel(); |
| 414 ClosePolicyChannel(); |
| 388 ClosePowerChannel(); | 415 ClosePowerChannel(); |
| 389 CloseProcessChannel(); | 416 CloseProcessChannel(); |
| 390 CloseVideoChannel(); | 417 CloseVideoChannel(); |
| 391 } | 418 } |
| 392 | 419 |
| 393 } // namespace arc | 420 } // namespace arc |
| OLD | NEW |