diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-27 05:11:04 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-27 05:11:04 +0000 |
commit | c4a5d44787011c0e6385d9c7af92b773db79a4f4 (patch) | |
tree | b05b2ab47155a3f2021b03973e82206675e44529 /chromeos/dbus/fake_cryptohome_client.h | |
parent | fbca94baffe12906f4888b9c45b688da133eadae (diff) | |
download | chromium_src-c4a5d44787011c0e6385d9c7af92b773db79a4f4.zip chromium_src-c4a5d44787011c0e6385d9c7af92b773db79a4f4.tar.gz chromium_src-c4a5d44787011c0e6385d9c7af92b773db79a4f4.tar.bz2 |
cryptohome: Merge FakeCryptohomeClient and CryptohomeClinentStubImpl
The new FakeCryptohomeClient is based on CryptohomeClinentStubImpl.
The only addition is set_unmout_result().
BUG=298729
TEST=the existing tests should pass
R=hashimoto@chromium.org, stevenjb@chromium.org
Review URL: https://codereview.chromium.org/24637004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/fake_cryptohome_client.h')
-rw-r--r-- | chromeos/dbus/fake_cryptohome_client.h | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/chromeos/dbus/fake_cryptohome_client.h b/chromeos/dbus/fake_cryptohome_client.h index 74d9e81..26e2cc8 100644 --- a/chromeos/dbus/fake_cryptohome_client.h +++ b/chromeos/dbus/fake_cryptohome_client.h @@ -1,24 +1,23 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. +// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ #define CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ -#include <string> +#include <map> +#include "base/basictypes.h" +#include "base/memory/weak_ptr.h" #include "chromeos/dbus/cryptohome_client.h" namespace chromeos { -// A fake implementation of CryptohomeClient. This only calls callbacks given -// as parameters. -class FakeCryptohomeClient : public CryptohomeClient { +class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient { public: FakeCryptohomeClient(); virtual ~FakeCryptohomeClient(); - // CryptohomeClient overrides virtual void Init(dbus::Bus* bus) OVERRIDE; virtual void SetAsyncCallStatusHandlers( const AsyncCallStatusHandler& handler, @@ -83,9 +82,9 @@ class FakeCryptohomeClient : public CryptohomeClient { virtual bool InstallAttributesIsInvalid(bool* is_invalid) OVERRIDE; virtual bool InstallAttributesIsFirstInstall(bool* is_first_install) OVERRIDE; virtual void TpmAttestationIsPrepared( - const BoolDBusMethodCallback& callback) OVERRIDE; + const BoolDBusMethodCallback& callback) OVERRIDE; virtual void TpmAttestationIsEnrolled( - const BoolDBusMethodCallback& callback) OVERRIDE; + const BoolDBusMethodCallback& callback) OVERRIDE; virtual void AsyncTpmAttestationCreateEnrollRequest( const AsyncMethodCallback& callback) OVERRIDE; virtual void AsyncTpmAttestationEnroll( @@ -140,18 +139,32 @@ class FakeCryptohomeClient : public CryptohomeClient { const std::string& payload, const BoolDBusMethodCallback& callback) OVERRIDE; - // Sets the unmount result of Unmount() call. Unmount() always sets the result - // and pretends that the underlying method call succeeds. + // Sets the unmount result of Unmount() call. void set_unmount_result(bool result) { unmount_result_= result; } private: - AsyncCallStatusHandler handler_; - AsyncCallStatusWithDataHandler data_handler_; + // Posts tasks which return fake results to the UI thread. + void ReturnAsyncMethodResult(const AsyncMethodCallback& callback, + bool returns_data); + // This method is used to implement ReturnAsyncMethodResult. + void ReturnAsyncMethodResultInternal(const AsyncMethodCallback& callback, + bool returns_data); + + int async_call_id_; + AsyncCallStatusHandler async_call_status_handler_; + AsyncCallStatusWithDataHandler async_call_status_data_handler_; + int tpm_is_ready_counter_; bool unmount_result_; + // A stub store for InstallAttributes, mapping an attribute name to the + // associated data blob. Used to implement InstallAttributesSet and -Get. + std::map<std::string, std::vector<uint8> > install_attrs_; + bool locked_; + base::WeakPtrFactory<FakeCryptohomeClient> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(FakeCryptohomeClient); }; |