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

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

Issue 2136023002: arc: Abort booting ARC if the device is critically low on disk space. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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/cryptohome_client.h" 5 #include "chromeos/dbus/cryptohome_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 FillIdentificationProtobuf(account_id, &id); 161 FillIdentificationProtobuf(account_id, &id);
162 162
163 dbus::MessageWriter writer(&method_call); 163 dbus::MessageWriter writer(&method_call);
164 writer.AppendProtoAsArrayOfBytes(id); 164 writer.AppendProtoAsArrayOfBytes(id);
165 proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs, 165 proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs,
166 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, 166 base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod,
167 weak_ptr_factory_.GetWeakPtr(), callback)); 167 weak_ptr_factory_.GetWeakPtr(), callback));
168 } 168 }
169 169
170 // CryptohomeClient override. 170 // CryptohomeClient override.
171 void GetFreeDiskSpace(const GetFreeDiskSpaceCallback& callback) override {
172 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
173 cryptohome::kCryptohomeGetFreeDiskSpace);
174 proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs,
175 base::Bind(&CryptohomeClientImpl::OnGetFreeDiskSpace,
176 weak_ptr_factory_.GetWeakPtr(), callback));
177 }
178
179 // CryptohomeClient override.
171 void GetSystemSalt(const GetSystemSaltCallback& callback) override { 180 void GetSystemSalt(const GetSystemSaltCallback& callback) override {
172 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, 181 dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
173 cryptohome::kCryptohomeGetSystemSalt); 182 cryptohome::kCryptohomeGetSystemSalt);
174 proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs , 183 proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs ,
175 base::Bind(&CryptohomeClientImpl::OnGetSystemSalt, 184 base::Bind(&CryptohomeClientImpl::OnGetSystemSalt,
176 weak_ptr_factory_.GetWeakPtr(), 185 weak_ptr_factory_.GetWeakPtr(),
177 callback)); 186 callback));
178 } 187 }
179 188
180 // CryptohomeClient override, 189 // CryptohomeClient override,
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 } 975 }
967 dbus::MessageReader reader(response); 976 dbus::MessageReader reader(response);
968 int async_id = 0; 977 int async_id = 0;
969 if (!reader.PopInt32(&async_id)) { 978 if (!reader.PopInt32(&async_id)) {
970 LOG(ERROR) << "Invalid response: " << response->ToString(); 979 LOG(ERROR) << "Invalid response: " << response->ToString();
971 return; 980 return;
972 } 981 }
973 callback.Run(async_id); 982 callback.Run(async_id);
974 } 983 }
975 984
985 // Handles the result of GetFreeDiskSpace().
986 void OnGetFreeDiskSpace(const GetFreeDiskSpaceCallback& callback,
987 dbus::Response* response) {
988 if (!response) {
989 callback.Run(DBUS_METHOD_CALL_FAILURE, 0);
990 return;
991 }
992 dbus::MessageReader reader(response);
993 uint64_t disk_free_bytes = 0;
994 if (!reader.PopUint64(&disk_free_bytes)) {
995 LOG(ERROR) << "Invalid response: " << response->ToString();
996 callback.Run(DBUS_METHOD_CALL_FAILURE, 0);
997 return;
998 }
999 callback.Run(DBUS_METHOD_CALL_SUCCESS, disk_free_bytes);
1000 }
1001
976 // Handles the result of GetSystemSalt(). 1002 // Handles the result of GetSystemSalt().
977 void OnGetSystemSalt(const GetSystemSaltCallback& callback, 1003 void OnGetSystemSalt(const GetSystemSaltCallback& callback,
978 dbus::Response* response) { 1004 dbus::Response* response) {
979 if (!response) { 1005 if (!response) {
980 callback.Run(DBUS_METHOD_CALL_FAILURE, std::vector<uint8_t>()); 1006 callback.Run(DBUS_METHOD_CALL_FAILURE, std::vector<uint8_t>());
981 return; 1007 return;
982 } 1008 }
983 dbus::MessageReader reader(response); 1009 dbus::MessageReader reader(response);
984 const uint8_t* bytes = NULL; 1010 const uint8_t* bytes = NULL;
985 size_t length = 0; 1011 size_t length = 0;
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 return new CryptohomeClientImpl(); 1248 return new CryptohomeClientImpl();
1223 } 1249 }
1224 1250
1225 // static 1251 // static
1226 std::string CryptohomeClient::GetStubSanitizedUsername( 1252 std::string CryptohomeClient::GetStubSanitizedUsername(
1227 const cryptohome::Identification& cryptohome_id) { 1253 const cryptohome::Identification& cryptohome_id) {
1228 return cryptohome_id.id() + kUserIdStubHashSuffix; 1254 return cryptohome_id.id() + kUserIdStubHashSuffix;
1229 } 1255 }
1230 1256
1231 } // namespace chromeos 1257 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698