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

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

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

Powered by Google App Engine
This is Rietveld 408576698