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

Side by Side Diff: chromeos/dbus/session_manager_client.cc

Issue 2887363003: Read container_instance_id. (Closed)
Patch Set: Address comments. Created 3 years, 7 months 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
OLDNEW
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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 730
731 void ScreenIsUnlockedReceived(dbus::Signal* signal) { 731 void ScreenIsUnlockedReceived(dbus::Signal* signal) {
732 screen_is_locked_ = false; 732 screen_is_locked_ = false;
733 for (auto& observer : observers_) 733 for (auto& observer : observers_)
734 observer.ScreenIsUnlocked(); 734 observer.ScreenIsUnlocked();
735 } 735 }
736 736
737 void ArcInstanceStoppedReceived(dbus::Signal* signal) { 737 void ArcInstanceStoppedReceived(dbus::Signal* signal) {
738 dbus::MessageReader reader(signal); 738 dbus::MessageReader reader(signal);
739 bool clean = false; 739 bool clean = false;
740 if (!reader.PopBool(&clean)) { 740 std::string container_instance_id;
741 if (!reader.PopBool(&clean) || !reader.PopString(&container_instance_id)) {
741 LOG(ERROR) << "Invalid signal: " << signal->ToString(); 742 LOG(ERROR) << "Invalid signal: " << signal->ToString();
742 return; 743 return;
743 } 744 }
744 for (auto& observer : observers_) 745 for (auto& observer : observers_)
745 observer.ArcInstanceStopped(clean); 746 observer.ArcInstanceStopped(clean, container_instance_id);
746 } 747 }
747 748
748 // Called when the object is connected to the signal. 749 // Called when the object is connected to the signal.
749 void SignalConnected(const std::string& interface_name, 750 void SignalConnected(const std::string& interface_name,
750 const std::string& signal_name, 751 const std::string& signal_name,
751 bool success) { 752 bool success) {
752 LOG_IF(ERROR, !success) << "Failed to connect to " << signal_name; 753 LOG_IF(ERROR, !success) << "Failed to connect to " << signal_name;
753 } 754 }
754 755
755 // Called when kSessionManagerGetServerBackedStateKeys method is complete. 756 // Called when kSessionManagerGetServerBackedStateKeys method is complete.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 arc_start_time = base::TimeTicks::FromInternalValue(ticks); 806 arc_start_time = base::TimeTicks::FromInternalValue(ticks);
806 } else { 807 } else {
807 LOG(ERROR) << "Invalid response: " << response->ToString(); 808 LOG(ERROR) << "Invalid response: " << response->ToString();
808 } 809 }
809 } 810 }
810 callback.Run(success, arc_start_time); 811 callback.Run(success, arc_start_time);
811 } 812 }
812 813
813 void OnStartArcInstanceSucceeded(const StartArcInstanceCallback& callback, 814 void OnStartArcInstanceSucceeded(const StartArcInstanceCallback& callback,
814 dbus::Response* response) { 815 dbus::Response* response) {
816 DCHECK(response);
817 dbus::MessageReader reader(response);
818 std::string container_instance_id;
819 if (!reader.PopString(&container_instance_id)) {
820 LOG(ERROR) << "Invalid response: " << response->ToString();
821 if (!callback.is_null())
822 callback.Run(StartArcInstanceResult::UNKNOWN_ERROR, std::string());
823 return;
824 }
825
815 if (!callback.is_null()) 826 if (!callback.is_null())
816 callback.Run(StartArcInstanceResult::SUCCESS); 827 callback.Run(StartArcInstanceResult::SUCCESS, container_instance_id);
817 } 828 }
818 829
819 void OnStartArcInstanceFailed(const StartArcInstanceCallback& callback, 830 void OnStartArcInstanceFailed(const StartArcInstanceCallback& callback,
820 dbus::ErrorResponse* response) { 831 dbus::ErrorResponse* response) {
821 LOG(ERROR) << "Failed to call StartArcInstance: " 832 LOG(ERROR) << "Failed to call StartArcInstance: "
822 << (response ? response->ToString() : "(null)"); 833 << (response ? response->ToString() : "(null)");
823 if (!callback.is_null()) { 834 if (!callback.is_null()) {
824 callback.Run(response && response->GetErrorName() == 835 callback.Run(response && response->GetErrorName() ==
825 login_manager::dbus_error::kLowFreeDisk 836 login_manager::dbus_error::kLowFreeDisk
826 ? StartArcInstanceResult::LOW_FREE_DISK_SPACE 837 ? StartArcInstanceResult::LOW_FREE_DISK_SPACE
827 : StartArcInstanceResult::UNKNOWN_ERROR); 838 : StartArcInstanceResult::UNKNOWN_ERROR,
839 std::string());
828 } 840 }
829 } 841 }
830 842
831 dbus::ObjectProxy* session_manager_proxy_ = nullptr; 843 dbus::ObjectProxy* session_manager_proxy_ = nullptr;
832 std::unique_ptr<BlockingMethodCaller> blocking_method_caller_; 844 std::unique_ptr<BlockingMethodCaller> blocking_method_caller_;
833 base::ObserverList<Observer> observers_; 845 base::ObserverList<Observer> observers_;
834 846
835 // Most recent screen-lock state received from session_manager. 847 // Most recent screen-lock state received from session_manager.
836 bool screen_is_locked_ = false; 848 bool screen_is_locked_ = false;
837 849
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 } 1041 }
1030 1042
1031 void CheckArcAvailability(const ArcCallback& callback) override { 1043 void CheckArcAvailability(const ArcCallback& callback) override {
1032 callback.Run(false); 1044 callback.Run(false);
1033 } 1045 }
1034 1046
1035 void StartArcInstance(const cryptohome::Identification& cryptohome_id, 1047 void StartArcInstance(const cryptohome::Identification& cryptohome_id,
1036 bool disable_boot_completed_broadcast, 1048 bool disable_boot_completed_broadcast,
1037 bool enable_vendor_privileged, 1049 bool enable_vendor_privileged,
1038 const StartArcInstanceCallback& callback) override { 1050 const StartArcInstanceCallback& callback) override {
1039 callback.Run(StartArcInstanceResult::UNKNOWN_ERROR); 1051 callback.Run(StartArcInstanceResult::UNKNOWN_ERROR, std::string());
1040 } 1052 }
1041 1053
1042 void SetArcCpuRestriction( 1054 void SetArcCpuRestriction(
1043 login_manager::ContainerCpuRestrictionState restriction_state, 1055 login_manager::ContainerCpuRestrictionState restriction_state,
1044 const ArcCallback& callback) override { 1056 const ArcCallback& callback) override {
1045 callback.Run(false); 1057 callback.Run(false);
1046 } 1058 }
1047 1059
1048 void EmitArcBooted(const cryptohome::Identification& cryptohome_id, 1060 void EmitArcBooted(const cryptohome::Identification& cryptohome_id,
1049 const ArcCallback& callback) override { 1061 const ArcCallback& callback) override {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 1095
1084 SessionManagerClient* SessionManagerClient::Create( 1096 SessionManagerClient* SessionManagerClient::Create(
1085 DBusClientImplementationType type) { 1097 DBusClientImplementationType type) {
1086 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) 1098 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION)
1087 return new SessionManagerClientImpl(); 1099 return new SessionManagerClientImpl();
1088 DCHECK_EQ(FAKE_DBUS_CLIENT_IMPLEMENTATION, type); 1100 DCHECK_EQ(FAKE_DBUS_CLIENT_IMPLEMENTATION, type);
1089 return new SessionManagerClientStubImpl(); 1101 return new SessionManagerClientStubImpl();
1090 } 1102 }
1091 1103
1092 } // namespace chromeos 1104 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698