Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/dbus/session_manager_client.h" | 5 #include "chromeos/dbus/session_manager_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 login_manager::kSessionManagerCheckArcAvailability); | 303 login_manager::kSessionManagerCheckArcAvailability); |
| 304 | 304 |
| 305 session_manager_proxy_->CallMethod( | 305 session_manager_proxy_->CallMethod( |
| 306 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 306 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 307 base::Bind(&SessionManagerClientImpl::OnCheckArcAvailability, | 307 base::Bind(&SessionManagerClientImpl::OnCheckArcAvailability, |
| 308 weak_ptr_factory_.GetWeakPtr(), callback)); | 308 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 309 } | 309 } |
| 310 | 310 |
| 311 void StartArcInstance(const cryptohome::Identification& cryptohome_id, | 311 void StartArcInstance(const cryptohome::Identification& cryptohome_id, |
| 312 bool disable_boot_completed_broadcast, | 312 bool disable_boot_completed_broadcast, |
| 313 const ArcCallback& callback) override { | 313 const StartArcInstanceCallback& callback) override { |
| 314 dbus::MethodCall method_call( | 314 dbus::MethodCall method_call( |
| 315 login_manager::kSessionManagerInterface, | 315 login_manager::kSessionManagerInterface, |
| 316 login_manager::kSessionManagerStartArcInstance); | 316 login_manager::kSessionManagerStartArcInstance); |
| 317 dbus::MessageWriter writer(&method_call); | 317 dbus::MessageWriter writer(&method_call); |
| 318 writer.AppendString(cryptohome_id.id()); | 318 writer.AppendString(cryptohome_id.id()); |
| 319 writer.AppendBool(disable_boot_completed_broadcast); | 319 writer.AppendBool(disable_boot_completed_broadcast); |
| 320 session_manager_proxy_->CallMethod( | 320 session_manager_proxy_->CallMethodWithErrorCallback( |
| 321 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 321 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 322 base::Bind(&SessionManagerClientImpl::OnArcMethod, | 322 base::Bind(&SessionManagerClientImpl::OnStartArcInstanceSucceeded, |
| 323 weak_ptr_factory_.GetWeakPtr(), | 323 weak_ptr_factory_.GetWeakPtr(), callback), |
| 324 login_manager::kSessionManagerStartArcInstance, callback)); | 324 base::Bind(&SessionManagerClientImpl::OnStartArcInstanceFailed, |
| 325 weak_ptr_factory_.GetWeakPtr(), callback)); | |
| 325 } | 326 } |
| 326 | 327 |
| 327 void StopArcInstance(const ArcCallback& callback) override { | 328 void StopArcInstance(const ArcCallback& callback) override { |
| 328 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, | 329 dbus::MethodCall method_call(login_manager::kSessionManagerInterface, |
| 329 login_manager::kSessionManagerStopArcInstance); | 330 login_manager::kSessionManagerStopArcInstance); |
| 330 session_manager_proxy_->CallMethod( | 331 session_manager_proxy_->CallMethod( |
| 331 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 332 &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 332 base::Bind(&SessionManagerClientImpl::OnArcMethod, | 333 base::Bind(&SessionManagerClientImpl::OnArcMethod, |
| 333 weak_ptr_factory_.GetWeakPtr(), | 334 weak_ptr_factory_.GetWeakPtr(), |
| 334 login_manager::kSessionManagerStopArcInstance, callback)); | 335 login_manager::kSessionManagerStopArcInstance, callback)); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 if (!response) { | 716 if (!response) { |
| 716 LOG(ERROR) << "Failed to call " << method_name; | 717 LOG(ERROR) << "Failed to call " << method_name; |
| 717 } else { | 718 } else { |
| 718 success = true; | 719 success = true; |
| 719 } | 720 } |
| 720 | 721 |
| 721 if (!callback.is_null()) | 722 if (!callback.is_null()) |
| 722 callback.Run(success); | 723 callback.Run(success); |
| 723 } | 724 } |
| 724 | 725 |
| 726 void OnStartArcInstanceSucceeded(const StartArcInstanceCallback& callback, | |
| 727 dbus::Response* response) { | |
| 728 if (!callback.is_null()) | |
| 729 callback.Run(true, "" /* no error */); | |
| 730 } | |
| 731 | |
| 732 void OnStartArcInstanceFailed(const StartArcInstanceCallback& callback, | |
| 733 dbus::ErrorResponse* response) { | |
| 734 LOG(ERROR) << "Failed to call StartArcInstance: " | |
| 735 << (response ? response->ToString() : "(null)"); | |
| 736 if (!callback.is_null()) | |
| 737 callback.Run(false, | |
| 738 response ? response->GetErrorName() : base::EmptyString()); | |
|
hashimoto
2016/10/06 08:12:20
Please be consistent by sticking to one of "" or b
hidehiko
2016/10/06 08:33:21
Done.
| |
| 739 } | |
| 740 | |
| 725 dbus::ObjectProxy* session_manager_proxy_; | 741 dbus::ObjectProxy* session_manager_proxy_; |
| 726 std::unique_ptr<BlockingMethodCaller> blocking_method_caller_; | 742 std::unique_ptr<BlockingMethodCaller> blocking_method_caller_; |
| 727 base::ObserverList<Observer> observers_; | 743 base::ObserverList<Observer> observers_; |
| 728 | 744 |
| 729 // Most recent screen-lock state received from session_manager. | 745 // Most recent screen-lock state received from session_manager. |
| 730 bool screen_is_locked_; | 746 bool screen_is_locked_; |
| 731 | 747 |
| 732 // Note: This should remain the last member so it'll be destroyed and | 748 // Note: This should remain the last member so it'll be destroyed and |
| 733 // invalidate its weak pointers before any other members are destroyed. | 749 // invalidate its weak pointers before any other members are destroyed. |
| 734 base::WeakPtrFactory<SessionManagerClientImpl> weak_ptr_factory_; | 750 base::WeakPtrFactory<SessionManagerClientImpl> weak_ptr_factory_; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 891 if (!callback.is_null()) | 907 if (!callback.is_null()) |
| 892 callback.Run(state_keys); | 908 callback.Run(state_keys); |
| 893 } | 909 } |
| 894 | 910 |
| 895 void CheckArcAvailability(const ArcCallback& callback) override { | 911 void CheckArcAvailability(const ArcCallback& callback) override { |
| 896 callback.Run(false); | 912 callback.Run(false); |
| 897 } | 913 } |
| 898 | 914 |
| 899 void StartArcInstance(const cryptohome::Identification& cryptohome_id, | 915 void StartArcInstance(const cryptohome::Identification& cryptohome_id, |
| 900 bool disable_boot_completed_broadcast, | 916 bool disable_boot_completed_broadcast, |
| 901 const ArcCallback& callback) override { | 917 const StartArcInstanceCallback& callback) override { |
| 902 callback.Run(false); | 918 callback.Run(false, ""); |
| 903 } | 919 } |
| 904 | 920 |
| 905 void PrioritizeArcInstance(const ArcCallback& callback) override { | 921 void PrioritizeArcInstance(const ArcCallback& callback) override { |
| 906 callback.Run(false); | 922 callback.Run(false); |
| 907 } | 923 } |
| 908 | 924 |
| 909 void EmitArcBooted() override {} | 925 void EmitArcBooted() override {} |
| 910 | 926 |
| 911 void StopArcInstance(const ArcCallback& callback) override { | 927 void StopArcInstance(const ArcCallback& callback) override { |
| 912 callback.Run(false); | 928 callback.Run(false); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 939 | 955 |
| 940 SessionManagerClient* SessionManagerClient::Create( | 956 SessionManagerClient* SessionManagerClient::Create( |
| 941 DBusClientImplementationType type) { | 957 DBusClientImplementationType type) { |
| 942 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 958 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 943 return new SessionManagerClientImpl(); | 959 return new SessionManagerClientImpl(); |
| 944 DCHECK_EQ(FAKE_DBUS_CLIENT_IMPLEMENTATION, type); | 960 DCHECK_EQ(FAKE_DBUS_CLIENT_IMPLEMENTATION, type); |
| 945 return new SessionManagerClientStubImpl(); | 961 return new SessionManagerClientStubImpl(); |
| 946 } | 962 } |
| 947 | 963 |
| 948 } // namespace chromeos | 964 } // namespace chromeos |
| OLD | NEW |