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/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 Loading... | |
| 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 Loading... | |
| 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 return; | |
|
hidehiko
2016/07/14 07:39:40
isn't it necessary to invoke callback.Run(FAILURE,
Shuhei Takahashi
2016/07/14 08:44:27
Yup, I think that's good to call failure callback.
| |
| 997 } | |
| 998 callback.Run(DBUS_METHOD_CALL_SUCCESS, disk_free_bytes); | |
| 999 } | |
| 1000 | |
| 976 // Handles the result of GetSystemSalt(). | 1001 // Handles the result of GetSystemSalt(). |
| 977 void OnGetSystemSalt(const GetSystemSaltCallback& callback, | 1002 void OnGetSystemSalt(const GetSystemSaltCallback& callback, |
| 978 dbus::Response* response) { | 1003 dbus::Response* response) { |
| 979 if (!response) { | 1004 if (!response) { |
| 980 callback.Run(DBUS_METHOD_CALL_FAILURE, std::vector<uint8_t>()); | 1005 callback.Run(DBUS_METHOD_CALL_FAILURE, std::vector<uint8_t>()); |
| 981 return; | 1006 return; |
| 982 } | 1007 } |
| 983 dbus::MessageReader reader(response); | 1008 dbus::MessageReader reader(response); |
| 984 const uint8_t* bytes = NULL; | 1009 const uint8_t* bytes = NULL; |
| 985 size_t length = 0; | 1010 size_t length = 0; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1222 return new CryptohomeClientImpl(); | 1247 return new CryptohomeClientImpl(); |
| 1223 } | 1248 } |
| 1224 | 1249 |
| 1225 // static | 1250 // static |
| 1226 std::string CryptohomeClient::GetStubSanitizedUsername( | 1251 std::string CryptohomeClient::GetStubSanitizedUsername( |
| 1227 const cryptohome::Identification& cryptohome_id) { | 1252 const cryptohome::Identification& cryptohome_id) { |
| 1228 return cryptohome_id.id() + kUserIdStubHashSuffix; | 1253 return cryptohome_id.id() + kUserIdStubHashSuffix; |
| 1229 } | 1254 } |
| 1230 | 1255 |
| 1231 } // namespace chromeos | 1256 } // namespace chromeos |
| OLD | NEW |