| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/cryptohome/homedir_methods.h" | 5 #include "chromeos/cryptohome/homedir_methods.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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 279 } |
| 280 | 280 |
| 281 void RenameCryptohome(const Identification& id_from, | 281 void RenameCryptohome(const Identification& id_from, |
| 282 const Identification& id_to, | 282 const Identification& id_to, |
| 283 const Callback& callback) override { | 283 const Callback& callback) override { |
| 284 DBusThreadManager::Get()->GetCryptohomeClient()->RenameCryptohome( | 284 DBusThreadManager::Get()->GetCryptohomeClient()->RenameCryptohome( |
| 285 id_from, id_to, base::Bind(&HomedirMethodsImpl::OnBaseReplyCallback, | 285 id_from, id_to, base::Bind(&HomedirMethodsImpl::OnBaseReplyCallback, |
| 286 weak_ptr_factory_.GetWeakPtr(), callback)); | 286 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 287 } | 287 } |
| 288 | 288 |
| 289 void GetAccountDiskUsage( |
| 290 const Identification& id, |
| 291 const GetAccountDiskUsageCallback& callback) override { |
| 292 DBusThreadManager::Get()->GetCryptohomeClient()->GetAccountDiskUsage( |
| 293 id, base::Bind(&HomedirMethodsImpl::OnGetAccountDiskUsageCallback, |
| 294 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 295 } |
| 296 |
| 289 private: | 297 private: |
| 290 void OnGetKeyDataExCallback(const GetKeyDataCallback& callback, | 298 void OnGetKeyDataExCallback(const GetKeyDataCallback& callback, |
| 291 chromeos::DBusMethodCallStatus call_status, | 299 chromeos::DBusMethodCallStatus call_status, |
| 292 bool result, | 300 bool result, |
| 293 const BaseReply& reply) { | 301 const BaseReply& reply) { |
| 294 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS) { | 302 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS) { |
| 295 callback.Run(false, MOUNT_ERROR_FATAL, std::vector<KeyDefinition>()); | 303 callback.Run(false, MOUNT_ERROR_FATAL, std::vector<KeyDefinition>()); |
| 296 return; | 304 return; |
| 297 } | 305 } |
| 298 if (reply.has_error()) { | 306 if (reply.has_error()) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 if (!reply.HasExtension(MountReply::reply)) { | 407 if (!reply.HasExtension(MountReply::reply)) { |
| 400 callback.Run(false, MOUNT_ERROR_FATAL, std::string()); | 408 callback.Run(false, MOUNT_ERROR_FATAL, std::string()); |
| 401 return; | 409 return; |
| 402 } | 410 } |
| 403 | 411 |
| 404 std::string mount_hash; | 412 std::string mount_hash; |
| 405 mount_hash = reply.GetExtension(MountReply::reply).sanitized_username(); | 413 mount_hash = reply.GetExtension(MountReply::reply).sanitized_username(); |
| 406 callback.Run(true, MOUNT_ERROR_NONE, mount_hash); | 414 callback.Run(true, MOUNT_ERROR_NONE, mount_hash); |
| 407 } | 415 } |
| 408 | 416 |
| 417 void OnGetAccountDiskUsageCallback( |
| 418 const GetAccountDiskUsageCallback& callback, |
| 419 chromeos::DBusMethodCallStatus call_status, |
| 420 bool result, |
| 421 const BaseReply& reply) { |
| 422 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS) { |
| 423 callback.Run(false, -1); |
| 424 return; |
| 425 } |
| 426 if (reply.has_error()) { |
| 427 if (reply.error() != CRYPTOHOME_ERROR_NOT_SET) { |
| 428 callback.Run(false, -1); |
| 429 return; |
| 430 } |
| 431 } |
| 432 if (!reply.HasExtension(GetAccountDiskUsageReply::reply)) { |
| 433 callback.Run(false, -1); |
| 434 return; |
| 435 } |
| 436 |
| 437 int64_t size = reply.GetExtension(GetAccountDiskUsageReply::reply).size(); |
| 438 callback.Run(true, size); |
| 439 } |
| 440 |
| 409 void OnBaseReplyCallback(const Callback& callback, | 441 void OnBaseReplyCallback(const Callback& callback, |
| 410 chromeos::DBusMethodCallStatus call_status, | 442 chromeos::DBusMethodCallStatus call_status, |
| 411 bool result, | 443 bool result, |
| 412 const BaseReply& reply) { | 444 const BaseReply& reply) { |
| 413 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS) { | 445 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS) { |
| 414 callback.Run(false, MOUNT_ERROR_FATAL); | 446 callback.Run(false, MOUNT_ERROR_FATAL); |
| 415 return; | 447 return; |
| 416 } | 448 } |
| 417 if (reply.has_error()) { | 449 if (reply.has_error()) { |
| 418 if (reply.error() != CRYPTOHOME_ERROR_NOT_SET) { | 450 if (reply.error() != CRYPTOHOME_ERROR_NOT_SET) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 } | 490 } |
| 459 delete g_homedir_methods; | 491 delete g_homedir_methods; |
| 460 g_homedir_methods = NULL; | 492 g_homedir_methods = NULL; |
| 461 VLOG(1) << "HomedirMethods Shutdown completed"; | 493 VLOG(1) << "HomedirMethods Shutdown completed"; |
| 462 } | 494 } |
| 463 | 495 |
| 464 // static | 496 // static |
| 465 HomedirMethods* HomedirMethods::GetInstance() { return g_homedir_methods; } | 497 HomedirMethods* HomedirMethods::GetInstance() { return g_homedir_methods; } |
| 466 | 498 |
| 467 } // namespace cryptohome | 499 } // namespace cryptohome |
| OLD | NEW |