| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "chromeos/dbus/blocking_method_caller.h" | 9 #include "chromeos/dbus/blocking_method_caller.h" |
| 10 #include "dbus/bus.h" | 10 #include "dbus/bus.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 async_call_status_handler_.Reset(); | 52 async_call_status_handler_.Reset(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // CryptohomeClient override. | 55 // CryptohomeClient override. |
| 56 virtual bool IsMounted(bool* is_mounted) OVERRIDE { | 56 virtual bool IsMounted(bool* is_mounted) OVERRIDE { |
| 57 INITIALIZE_METHOD_CALL(method_call, cryptohome::kCryptohomeIsMounted); | 57 INITIALIZE_METHOD_CALL(method_call, cryptohome::kCryptohomeIsMounted); |
| 58 return CallBoolMethodAndBlock(&method_call, is_mounted); | 58 return CallBoolMethodAndBlock(&method_call, is_mounted); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // CryptohomeClient override. | 61 // CryptohomeClient override. |
| 62 virtual bool IsMountedForUser(const std::string& username, |
| 63 bool* is_mounted, |
| 64 bool* is_ephemeral_mount) OVERRIDE { |
| 65 INITIALIZE_METHOD_CALL(method_call, |
| 66 cryptohome::kCryptohomeIsMountedForUser); |
| 67 dbus::MessageWriter writer(&method_call); |
| 68 writer.AppendString(username); |
| 69 scoped_ptr<dbus::Response> response( |
| 70 blocking_method_caller_.CallMethodAndBlock(&method_call)); |
| 71 if (!response.get()) |
| 72 return false; |
| 73 dbus::MessageReader reader(response.get()); |
| 74 if (!reader.PopBool(is_mounted) || |
| 75 !reader.PopBool(is_ephemeral_mount)) |
| 76 return false; |
| 77 return true; |
| 78 } |
| 79 |
| 80 // CryptohomeClient override. |
| 62 virtual bool Unmount(bool *success) OVERRIDE { | 81 virtual bool Unmount(bool *success) OVERRIDE { |
| 63 INITIALIZE_METHOD_CALL(method_call, cryptohome::kCryptohomeUnmount); | 82 INITIALIZE_METHOD_CALL(method_call, cryptohome::kCryptohomeUnmount); |
| 64 return CallBoolMethodAndBlock(&method_call, success); | 83 return CallBoolMethodAndBlock(&method_call, success); |
| 65 } | 84 } |
| 66 | 85 |
| 67 // CryptohomeClient override. | 86 // CryptohomeClient override. |
| 68 virtual void AsyncCheckKey(const std::string& username, | 87 virtual void AsyncCheckKey(const std::string& username, |
| 69 const std::string& key, | 88 const std::string& key, |
| 70 const AsyncMethodCallback& callback) OVERRIDE { | 89 const AsyncMethodCallback& callback) OVERRIDE { |
| 71 INITIALIZE_METHOD_CALL(method_call, cryptohome::kCryptohomeAsyncCheckKey); | 90 INITIALIZE_METHOD_CALL(method_call, cryptohome::kCryptohomeAsyncCheckKey); |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 async_call_status_handler_.Reset(); | 440 async_call_status_handler_.Reset(); |
| 422 } | 441 } |
| 423 | 442 |
| 424 // CryptohomeClient override. | 443 // CryptohomeClient override. |
| 425 virtual bool IsMounted(bool* is_mounted) OVERRIDE { | 444 virtual bool IsMounted(bool* is_mounted) OVERRIDE { |
| 426 *is_mounted = true; | 445 *is_mounted = true; |
| 427 return true; | 446 return true; |
| 428 } | 447 } |
| 429 | 448 |
| 430 // CryptohomeClient override. | 449 // CryptohomeClient override. |
| 450 virtual bool IsMountedForUser(const std::string& username, |
| 451 bool* is_mounted, |
| 452 bool* is_ephemeral_mount) OVERRIDE { |
| 453 *is_mounted = true; |
| 454 *is_ephemeral_mount = false; |
| 455 return true; |
| 456 } |
| 457 |
| 458 // CryptohomeClient override. |
| 431 virtual bool Unmount(bool* success) OVERRIDE { | 459 virtual bool Unmount(bool* success) OVERRIDE { |
| 432 *success = true; | 460 *success = true; |
| 433 return true; | 461 return true; |
| 434 } | 462 } |
| 435 | 463 |
| 436 // CryptohomeClient override. | 464 // CryptohomeClient override. |
| 437 virtual void AsyncCheckKey(const std::string& username, | 465 virtual void AsyncCheckKey(const std::string& username, |
| 438 const std::string& key, | 466 const std::string& key, |
| 439 const AsyncMethodCallback& callback) OVERRIDE { | 467 const AsyncMethodCallback& callback) OVERRIDE { |
| 440 ReturnAsyncMethodResult(callback); | 468 ReturnAsyncMethodResult(callback); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 // static | 658 // static |
| 631 CryptohomeClient* CryptohomeClient::Create(DBusClientImplementationType type, | 659 CryptohomeClient* CryptohomeClient::Create(DBusClientImplementationType type, |
| 632 dbus::Bus* bus) { | 660 dbus::Bus* bus) { |
| 633 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 661 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 634 return new CryptohomeClientImpl(bus); | 662 return new CryptohomeClientImpl(bus); |
| 635 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 663 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 636 return new CryptohomeClientStubImpl(); | 664 return new CryptohomeClientStubImpl(); |
| 637 } | 665 } |
| 638 | 666 |
| 639 } // namespace chromeos | 667 } // namespace chromeos |
| OLD | NEW |