Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / chromeos / dbus / fake_cryptohome_client.cc
blobf019de0b72d7ab2bf278745c4d15678cae3e2b3c
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chromeos/dbus/fake_cryptohome_client.h"
7 #include "base/bind.h"
8 #include "base/message_loop.h"
9 #include "third_party/cros_system_api/dbus/service_constants.h"
11 namespace chromeos {
13 namespace {
15 // A fake system salt. GetSystemSalt copies it to the given buffer.
16 const char kStubSystemSalt[] = "stub_system_salt";
18 } // namespace
20 FakeCryptohomeClient::FakeCryptohomeClient() : unmount_result_(false) {
23 FakeCryptohomeClient::~FakeCryptohomeClient() {
26 void FakeCryptohomeClient::TpmIsBeingOwned(
27 const BoolDBusMethodCallback& callback) {
30 bool FakeCryptohomeClient::Unmount(bool* success) {
31 *success = unmount_result_;
32 return true;
35 void FakeCryptohomeClient::AsyncCheckKey(const std::string& username,
36 const std::string& key,
37 const AsyncMethodCallback& callback) {
40 bool FakeCryptohomeClient::InstallAttributesIsInvalid(bool* is_invalid) {
41 return false;
44 void FakeCryptohomeClient::TpmAttestationGetKeyPayload(
45 attestation::AttestationKeyType key_type,
46 const std::string& key_name,
47 const DataMethodCallback& callback) {
50 void FakeCryptohomeClient::AsyncTpmAttestationFinishCertRequest(
51 const std::string& pca_response,
52 attestation::AttestationKeyType key_type,
53 const std::string& key_name,
54 const AsyncMethodCallback& callback) {
57 void FakeCryptohomeClient::TpmIsEnabled(
58 const BoolDBusMethodCallback& callback) {
61 void FakeCryptohomeClient::AsyncTpmAttestationEnroll(
62 const std::string& pca_response,
63 const AsyncMethodCallback& callback) {
66 void FakeCryptohomeClient::AsyncMigrateKey(
67 const std::string& username,
68 const std::string& from_key,
69 const std::string& to_key,
70 const AsyncMethodCallback& callback) {
73 void FakeCryptohomeClient::IsMounted(const BoolDBusMethodCallback& callback) {
74 base::MessageLoop::current()->PostTask(FROM_HERE,
75 base::Bind(callback,
76 DBUS_METHOD_CALL_SUCCESS, true));
79 bool FakeCryptohomeClient::InstallAttributesGet(const std::string& name,
80 std::vector<uint8>* value,
81 bool* successful) {
82 return false;
85 void FakeCryptohomeClient::AsyncMount(const std::string& username,
86 const std::string& key, int flags,
87 const AsyncMethodCallback& callback) {
88 DCHECK(!callback.is_null());
90 base::MessageLoop::current()->PostTask(FROM_HERE,
91 base::Bind(callback, 1 /* async_id */));
92 if (!handler_.is_null())
93 base::MessageLoop::current()->PostTask(FROM_HERE,
94 base::Bind(handler_,
95 1, // async_id
96 true, // return_status
97 cryptohome::MOUNT_ERROR_NONE));
100 void FakeCryptohomeClient::AsyncMountGuest(
101 const AsyncMethodCallback& callback) {
104 bool FakeCryptohomeClient::CallTpmIsBeingOwnedAndBlock(bool* owning) {
105 return false;
108 void FakeCryptohomeClient::Pkcs11IsTpmTokenReady(
109 const BoolDBusMethodCallback& callback) {
112 void FakeCryptohomeClient::TpmClearStoredPassword(
113 const VoidDBusMethodCallback& callback) {
116 void FakeCryptohomeClient::TpmCanAttemptOwnership(
117 const VoidDBusMethodCallback& callback) {
120 bool FakeCryptohomeClient::GetSystemSalt(std::vector<uint8>* salt) {
121 salt->assign(kStubSystemSalt,
122 kStubSystemSalt + arraysize(kStubSystemSalt) - 1);
123 return true;
126 void FakeCryptohomeClient::TpmGetPassword(
127 const StringDBusMethodCallback& callback) {
130 bool FakeCryptohomeClient::InstallAttributesFinalize(bool* successful) {
131 return false;
134 void FakeCryptohomeClient::SetAsyncCallStatusHandlers(
135 const AsyncCallStatusHandler& handler,
136 const AsyncCallStatusWithDataHandler& data_handler) {
137 handler_ = handler;
138 data_handler_ = data_handler;
141 bool FakeCryptohomeClient::CallTpmIsEnabledAndBlock(bool* enabled) {
142 return false;
145 bool FakeCryptohomeClient::InstallAttributesSet(
146 const std::string& name,
147 const std::vector<uint8>& value,
148 bool* successful) {
149 return false;
152 bool FakeCryptohomeClient::InstallAttributesIsFirstInstall(
153 bool* is_first_install) {
154 return false;
157 void FakeCryptohomeClient::TpmAttestationGetCertificate(
158 attestation::AttestationKeyType key_type,
159 const std::string& key_name,
160 const DataMethodCallback& callback) {
163 void FakeCryptohomeClient::InstallAttributesIsReady(
164 const BoolDBusMethodCallback& callback) {
165 base::MessageLoop::current()->PostTask(FROM_HERE,
166 base::Bind(callback,
167 DBUS_METHOD_CALL_SUCCESS, true));
170 void FakeCryptohomeClient::TpmAttestationGetPublicKey(
171 attestation::AttestationKeyType key_type,
172 const std::string& key_name,
173 const DataMethodCallback& callback) {
176 void FakeCryptohomeClient::TpmAttestationSignSimpleChallenge(
177 attestation::AttestationKeyType key_type,
178 const std::string& key_name,
179 const std::string& challenge,
180 const AsyncMethodCallback& callback) {
183 void FakeCryptohomeClient::Pkcs11GetTpmTokenInfo(
184 const Pkcs11GetTpmTokenInfoCallback& callback) {
187 void FakeCryptohomeClient::TpmIsOwned(const BoolDBusMethodCallback& callback) {
190 void FakeCryptohomeClient::TpmAttestationIsPrepared(
191 const BoolDBusMethodCallback& callback) {
194 void FakeCryptohomeClient::TpmIsReady(const BoolDBusMethodCallback& callback) {
197 void FakeCryptohomeClient::AsyncTpmAttestationCreateEnrollRequest(
198 const AsyncMethodCallback& callback) {
201 void FakeCryptohomeClient::ResetAsyncCallStatusHandlers() {
202 handler_.Reset();
203 data_handler_.Reset();
206 void FakeCryptohomeClient::TpmAttestationDoesKeyExist(
207 attestation::AttestationKeyType key_type,
208 const std::string& key_name,
209 const BoolDBusMethodCallback& callback) {
212 bool FakeCryptohomeClient::CallTpmIsOwnedAndBlock(bool* owned) {
213 return false;
216 void FakeCryptohomeClient::AsyncRemove(const std::string& username,
217 const AsyncMethodCallback& callback) {
220 void FakeCryptohomeClient::TpmAttestationSetKeyPayload(
221 attestation::AttestationKeyType key_type,
222 const std::string& key_name,
223 const std::string& payload,
224 const BoolDBusMethodCallback& callback) {
227 void FakeCryptohomeClient::GetSanitizedUsername(
228 const std::string& username,
229 const StringDBusMethodCallback& callback) {
230 DCHECK(!callback.is_null());
232 base::MessageLoop::current()->PostTask(
233 FROM_HERE,
234 base::Bind(callback,
235 chromeos::DBUS_METHOD_CALL_SUCCESS,
236 username));
237 if (!data_handler_.is_null())
238 base::MessageLoop::current()->PostTask(
239 FROM_HERE,
240 base::Bind(data_handler_,
241 1, // async_id
242 true, // return_status
243 username));
246 void FakeCryptohomeClient::TpmAttestationSignEnterpriseChallenge(
247 attestation::AttestationKeyType key_type,
248 const std::string& key_name,
249 const std::string& domain,
250 const std::string& device_id,
251 attestation::AttestationChallengeOptions options,
252 const std::string& challenge,
253 const AsyncMethodCallback& callback) {
256 void FakeCryptohomeClient::TpmAttestationIsEnrolled(
257 const BoolDBusMethodCallback& callback) {
260 void FakeCryptohomeClient::TpmAttestationRegisterKey(
261 attestation::AttestationKeyType key_type,
262 const std::string& key_name,
263 const AsyncMethodCallback& callback) {
266 bool FakeCryptohomeClient::CallTpmClearStoredPasswordAndBlock() {
267 return false;
270 void FakeCryptohomeClient::AsyncTpmAttestationCreateCertRequest(
271 int options,
272 const AsyncMethodCallback& callback) {
275 } // namespace chromeos