Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1404)

Side by Side Diff: chromeos/dbus/fake_cryptohome_client.cc

Issue 2031923003: Remove use of deprecated MessageLoop methods in chromeos. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/fake_cryptohome_client.h" 5 #include "chromeos/dbus/fake_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"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/message_loop/message_loop.h"
14 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/single_thread_task_runner.h"
15 #include "base/threading/thread_restrictions.h" 15 #include "base/threading/thread_restrictions.h"
16 #include "base/threading/thread_task_runner_handle.h"
16 #include "chromeos/chromeos_paths.h" 17 #include "chromeos/chromeos_paths.h"
17 #include "chromeos/dbus/cryptohome/key.pb.h" 18 #include "chromeos/dbus/cryptohome/key.pb.h"
18 #include "chromeos/dbus/cryptohome/rpc.pb.h" 19 #include "chromeos/dbus/cryptohome/rpc.pb.h"
19 #include "third_party/cros_system_api/dbus/service_constants.h" 20 #include "third_party/cros_system_api/dbus/service_constants.h"
20 #include "third_party/protobuf/src/google/protobuf/io/coded_stream.h" 21 #include "third_party/protobuf/src/google/protobuf/io/coded_stream.h"
21 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h" 22 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h"
22 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite .h" 23 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite .h"
23 24
24 namespace chromeos { 25 namespace chromeos {
25 26
(...skipping 21 matching lines...) Expand all
47 } 48 }
48 49
49 void FakeCryptohomeClient::ResetAsyncCallStatusHandlers() { 50 void FakeCryptohomeClient::ResetAsyncCallStatusHandlers() {
50 async_call_status_handler_.Reset(); 51 async_call_status_handler_.Reset();
51 async_call_status_data_handler_.Reset(); 52 async_call_status_data_handler_.Reset();
52 } 53 }
53 54
54 void FakeCryptohomeClient::WaitForServiceToBeAvailable( 55 void FakeCryptohomeClient::WaitForServiceToBeAvailable(
55 const WaitForServiceToBeAvailableCallback& callback) { 56 const WaitForServiceToBeAvailableCallback& callback) {
56 if (service_is_available_) { 57 if (service_is_available_) {
57 base::MessageLoop::current()->PostTask(FROM_HERE, 58 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
58 base::Bind(callback, true)); 59 base::Bind(callback, true));
59 } else { 60 } else {
60 pending_wait_for_service_to_be_available_callbacks_.push_back(callback); 61 pending_wait_for_service_to_be_available_callbacks_.push_back(callback);
61 } 62 }
62 } 63 }
63 64
64 void FakeCryptohomeClient::IsMounted( 65 void FakeCryptohomeClient::IsMounted(
65 const BoolDBusMethodCallback& callback) { 66 const BoolDBusMethodCallback& callback) {
66 base::MessageLoop::current()->PostTask( 67 base::ThreadTaskRunnerHandle::Get()->PostTask(
67 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); 68 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true));
68 } 69 }
69 70
70 bool FakeCryptohomeClient::Unmount(bool* success) { 71 bool FakeCryptohomeClient::Unmount(bool* success) {
71 *success = unmount_result_; 72 *success = unmount_result_;
72 return true; 73 return true;
73 } 74 }
74 75
75 void FakeCryptohomeClient::AsyncCheckKey( 76 void FakeCryptohomeClient::AsyncCheckKey(
76 const cryptohome::Identification& cryptohome_id, 77 const cryptohome::Identification& cryptohome_id,
(...skipping 19 matching lines...) Expand all
96 void FakeCryptohomeClient::RenameCryptohome( 97 void FakeCryptohomeClient::RenameCryptohome(
97 const cryptohome::Identification& cryptohome_id_from, 98 const cryptohome::Identification& cryptohome_id_from,
98 const cryptohome::Identification& cryptohome_id_to, 99 const cryptohome::Identification& cryptohome_id_to,
99 const ProtobufMethodCallback& callback) { 100 const ProtobufMethodCallback& callback) {
100 cryptohome::BaseReply reply; 101 cryptohome::BaseReply reply;
101 ReturnProtobufMethodCallback(reply, callback); 102 ReturnProtobufMethodCallback(reply, callback);
102 } 103 }
103 104
104 void FakeCryptohomeClient::GetSystemSalt( 105 void FakeCryptohomeClient::GetSystemSalt(
105 const GetSystemSaltCallback& callback) { 106 const GetSystemSaltCallback& callback) {
106 base::MessageLoop::current()->PostTask( 107 base::ThreadTaskRunnerHandle::Get()->PostTask(
107 FROM_HERE, 108 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, system_salt_));
108 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, system_salt_));
109 } 109 }
110 110
111 void FakeCryptohomeClient::GetSanitizedUsername( 111 void FakeCryptohomeClient::GetSanitizedUsername(
112 const cryptohome::Identification& cryptohome_id, 112 const cryptohome::Identification& cryptohome_id,
113 const StringDBusMethodCallback& callback) { 113 const StringDBusMethodCallback& callback) {
114 // Even for stub implementation we have to return different values so that 114 // Even for stub implementation we have to return different values so that
115 // multi-profiles would work. 115 // multi-profiles would work.
116 std::string sanitized_username = GetStubSanitizedUsername(cryptohome_id); 116 std::string sanitized_username = GetStubSanitizedUsername(cryptohome_id);
117 base::MessageLoop::current()->PostTask( 117 base::ThreadTaskRunnerHandle::Get()->PostTask(
118 FROM_HERE, 118 FROM_HERE,
119 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, sanitized_username)); 119 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, sanitized_username));
120 } 120 }
121 121
122 std::string FakeCryptohomeClient::BlockingGetSanitizedUsername( 122 std::string FakeCryptohomeClient::BlockingGetSanitizedUsername(
123 const cryptohome::Identification& cryptohome_id) { 123 const cryptohome::Identification& cryptohome_id) {
124 return GetStubSanitizedUsername(cryptohome_id); 124 return GetStubSanitizedUsername(cryptohome_id);
125 } 125 }
126 126
127 void FakeCryptohomeClient::AsyncMount( 127 void FakeCryptohomeClient::AsyncMount(
(...skipping 19 matching lines...) Expand all
147 147
148 void FakeCryptohomeClient::AsyncMountPublic( 148 void FakeCryptohomeClient::AsyncMountPublic(
149 const cryptohome::Identification& public_mount_id, 149 const cryptohome::Identification& public_mount_id,
150 int flags, 150 int flags,
151 const AsyncMethodCallback& callback) { 151 const AsyncMethodCallback& callback) {
152 ReturnAsyncMethodResult(callback, false); 152 ReturnAsyncMethodResult(callback, false);
153 } 153 }
154 154
155 void FakeCryptohomeClient::TpmIsReady( 155 void FakeCryptohomeClient::TpmIsReady(
156 const BoolDBusMethodCallback& callback) { 156 const BoolDBusMethodCallback& callback) {
157 base::MessageLoop::current()->PostTask( 157 base::ThreadTaskRunnerHandle::Get()->PostTask(
158 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); 158 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true));
159 } 159 }
160 160
161 void FakeCryptohomeClient::TpmIsEnabled( 161 void FakeCryptohomeClient::TpmIsEnabled(
162 const BoolDBusMethodCallback& callback) { 162 const BoolDBusMethodCallback& callback) {
163 base::MessageLoop::current()->PostTask( 163 base::ThreadTaskRunnerHandle::Get()->PostTask(
164 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); 164 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true));
165 } 165 }
166 166
167 bool FakeCryptohomeClient::CallTpmIsEnabledAndBlock(bool* enabled) { 167 bool FakeCryptohomeClient::CallTpmIsEnabledAndBlock(bool* enabled) {
168 *enabled = true; 168 *enabled = true;
169 return true; 169 return true;
170 } 170 }
171 171
172 void FakeCryptohomeClient::TpmGetPassword( 172 void FakeCryptohomeClient::TpmGetPassword(
173 const StringDBusMethodCallback& callback) { 173 const StringDBusMethodCallback& callback) {
174 const char kStubTpmPassword[] = "Stub-TPM-password"; 174 const char kStubTpmPassword[] = "Stub-TPM-password";
175 base::MessageLoop::current()->PostTask( 175 base::ThreadTaskRunnerHandle::Get()->PostTask(
176 FROM_HERE, 176 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS,
177 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, 177 std::string(kStubTpmPassword)));
178 std::string(kStubTpmPassword)));
179 } 178 }
180 179
181 void FakeCryptohomeClient::TpmIsOwned( 180 void FakeCryptohomeClient::TpmIsOwned(
182 const BoolDBusMethodCallback& callback) { 181 const BoolDBusMethodCallback& callback) {
183 base::MessageLoop::current()->PostTask( 182 base::ThreadTaskRunnerHandle::Get()->PostTask(
184 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); 183 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true));
185 } 184 }
186 185
187 bool FakeCryptohomeClient::CallTpmIsOwnedAndBlock(bool* owned) { 186 bool FakeCryptohomeClient::CallTpmIsOwnedAndBlock(bool* owned) {
188 *owned = true; 187 *owned = true;
189 return true; 188 return true;
190 } 189 }
191 190
192 void FakeCryptohomeClient::TpmIsBeingOwned( 191 void FakeCryptohomeClient::TpmIsBeingOwned(
193 const BoolDBusMethodCallback& callback) { 192 const BoolDBusMethodCallback& callback) {
194 base::MessageLoop::current()->PostTask( 193 base::ThreadTaskRunnerHandle::Get()->PostTask(
195 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); 194 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true));
196 } 195 }
197 196
198 bool FakeCryptohomeClient::CallTpmIsBeingOwnedAndBlock(bool* owning) { 197 bool FakeCryptohomeClient::CallTpmIsBeingOwnedAndBlock(bool* owning) {
199 *owning = true; 198 *owning = true;
200 return true; 199 return true;
201 } 200 }
202 201
203 void FakeCryptohomeClient::TpmCanAttemptOwnership( 202 void FakeCryptohomeClient::TpmCanAttemptOwnership(
204 const VoidDBusMethodCallback& callback) { 203 const VoidDBusMethodCallback& callback) {
205 base::MessageLoop::current()->PostTask( 204 base::ThreadTaskRunnerHandle::Get()->PostTask(
206 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); 205 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
207 } 206 }
208 207
209 void FakeCryptohomeClient::TpmClearStoredPassword( 208 void FakeCryptohomeClient::TpmClearStoredPassword(
210 const VoidDBusMethodCallback& callback) { 209 const VoidDBusMethodCallback& callback) {
211 base::MessageLoop::current()->PostTask( 210 base::ThreadTaskRunnerHandle::Get()->PostTask(
212 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); 211 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
213 } 212 }
214 213
215 bool FakeCryptohomeClient::CallTpmClearStoredPasswordAndBlock() { 214 bool FakeCryptohomeClient::CallTpmClearStoredPasswordAndBlock() {
216 return true; 215 return true;
217 } 216 }
218 217
219 void FakeCryptohomeClient::Pkcs11IsTpmTokenReady( 218 void FakeCryptohomeClient::Pkcs11IsTpmTokenReady(
220 const BoolDBusMethodCallback& callback) { 219 const BoolDBusMethodCallback& callback) {
221 base::MessageLoop::current()->PostTask( 220 base::ThreadTaskRunnerHandle::Get()->PostTask(
222 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); 221 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true));
223 } 222 }
224 223
225 void FakeCryptohomeClient::Pkcs11GetTpmTokenInfo( 224 void FakeCryptohomeClient::Pkcs11GetTpmTokenInfo(
226 const Pkcs11GetTpmTokenInfoCallback& callback) { 225 const Pkcs11GetTpmTokenInfoCallback& callback) {
227 const char kStubTPMTokenName[] = "StubTPMTokenName"; 226 const char kStubTPMTokenName[] = "StubTPMTokenName";
228 const char kStubUserPin[] = "012345"; 227 const char kStubUserPin[] = "012345";
229 const int kStubSlot = 0; 228 const int kStubSlot = 0;
230 base::MessageLoop::current()->PostTask( 229 base::ThreadTaskRunnerHandle::Get()->PostTask(
231 FROM_HERE, 230 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS,
232 base::Bind(callback, 231 std::string(kStubTPMTokenName),
233 DBUS_METHOD_CALL_SUCCESS, 232 std::string(kStubUserPin), kStubSlot));
234 std::string(kStubTPMTokenName),
235 std::string(kStubUserPin),
236 kStubSlot));
237 } 233 }
238 234
239 void FakeCryptohomeClient::Pkcs11GetTpmTokenInfoForUser( 235 void FakeCryptohomeClient::Pkcs11GetTpmTokenInfoForUser(
240 const cryptohome::Identification& cryptohome_id, 236 const cryptohome::Identification& cryptohome_id,
241 const Pkcs11GetTpmTokenInfoCallback& callback) { 237 const Pkcs11GetTpmTokenInfoCallback& callback) {
242 Pkcs11GetTpmTokenInfo(callback); 238 Pkcs11GetTpmTokenInfo(callback);
243 } 239 }
244 240
245 bool FakeCryptohomeClient::InstallAttributesGet(const std::string& name, 241 bool FakeCryptohomeClient::InstallAttributesGet(const std::string& name,
246 std::vector<uint8_t>* value, 242 std::vector<uint8_t>* value,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 // The real implementation does a blocking wait on the dbus call; the fake 315 // The real implementation does a blocking wait on the dbus call; the fake
320 // implementation must have this file written before returning. 316 // implementation must have this file written before returning.
321 base::ThreadRestrictions::ScopedAllowIO allow_io; 317 base::ThreadRestrictions::ScopedAllowIO allow_io;
322 base::WriteFile(cache_path, result.data(), result.size()); 318 base::WriteFile(cache_path, result.data(), result.size());
323 319
324 return true; 320 return true;
325 } 321 }
326 322
327 void FakeCryptohomeClient::InstallAttributesIsReady( 323 void FakeCryptohomeClient::InstallAttributesIsReady(
328 const BoolDBusMethodCallback& callback) { 324 const BoolDBusMethodCallback& callback) {
329 base::MessageLoop::current()->PostTask( 325 base::ThreadTaskRunnerHandle::Get()->PostTask(
330 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); 326 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true));
331 } 327 }
332 328
333 bool FakeCryptohomeClient::InstallAttributesIsInvalid(bool* is_invalid) { 329 bool FakeCryptohomeClient::InstallAttributesIsInvalid(bool* is_invalid) {
334 *is_invalid = false; 330 *is_invalid = false;
335 return true; 331 return true;
336 } 332 }
337 333
338 bool FakeCryptohomeClient::InstallAttributesIsFirstInstall( 334 bool FakeCryptohomeClient::InstallAttributesIsFirstInstall(
339 bool* is_first_install) { 335 bool* is_first_install) {
340 *is_first_install = !locked_; 336 *is_first_install = !locked_;
341 return true; 337 return true;
342 } 338 }
343 339
344 void FakeCryptohomeClient::TpmAttestationIsPrepared( 340 void FakeCryptohomeClient::TpmAttestationIsPrepared(
345 const BoolDBusMethodCallback& callback) { 341 const BoolDBusMethodCallback& callback) {
346 base::MessageLoop::current()->PostTask( 342 base::ThreadTaskRunnerHandle::Get()->PostTask(
347 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); 343 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true));
348 } 344 }
349 345
350 void FakeCryptohomeClient::TpmAttestationIsEnrolled( 346 void FakeCryptohomeClient::TpmAttestationIsEnrolled(
351 const BoolDBusMethodCallback& callback) { 347 const BoolDBusMethodCallback& callback) {
352 base::MessageLoop::current()->PostTask( 348 base::ThreadTaskRunnerHandle::Get()->PostTask(
353 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true)); 349 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true));
354 } 350 }
355 351
356 void FakeCryptohomeClient::AsyncTpmAttestationCreateEnrollRequest( 352 void FakeCryptohomeClient::AsyncTpmAttestationCreateEnrollRequest(
357 chromeos::attestation::PrivacyCAType pca_type, 353 chromeos::attestation::PrivacyCAType pca_type,
358 const AsyncMethodCallback& callback) { 354 const AsyncMethodCallback& callback) {
359 ReturnAsyncMethodResult(callback, true); 355 ReturnAsyncMethodResult(callback, true);
360 } 356 }
361 357
362 void FakeCryptohomeClient::AsyncTpmAttestationEnroll( 358 void FakeCryptohomeClient::AsyncTpmAttestationEnroll(
(...skipping 19 matching lines...) Expand all
382 const std::string& key_name, 378 const std::string& key_name,
383 const AsyncMethodCallback& callback) { 379 const AsyncMethodCallback& callback) {
384 ReturnAsyncMethodResult(callback, true); 380 ReturnAsyncMethodResult(callback, true);
385 } 381 }
386 382
387 void FakeCryptohomeClient::TpmAttestationDoesKeyExist( 383 void FakeCryptohomeClient::TpmAttestationDoesKeyExist(
388 attestation::AttestationKeyType key_type, 384 attestation::AttestationKeyType key_type,
389 const cryptohome::Identification& cryptohome_id, 385 const cryptohome::Identification& cryptohome_id,
390 const std::string& key_name, 386 const std::string& key_name,
391 const BoolDBusMethodCallback& callback) { 387 const BoolDBusMethodCallback& callback) {
392 base::MessageLoop::current()->PostTask( 388 base::ThreadTaskRunnerHandle::Get()->PostTask(
393 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false)); 389 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false));
394 } 390 }
395 391
396 void FakeCryptohomeClient::TpmAttestationGetCertificate( 392 void FakeCryptohomeClient::TpmAttestationGetCertificate(
397 attestation::AttestationKeyType key_type, 393 attestation::AttestationKeyType key_type,
398 const cryptohome::Identification& cryptohome_id, 394 const cryptohome::Identification& cryptohome_id,
399 const std::string& key_name, 395 const std::string& key_name,
400 const DataMethodCallback& callback) { 396 const DataMethodCallback& callback) {
401 base::MessageLoop::current()->PostTask( 397 base::ThreadTaskRunnerHandle::Get()->PostTask(
402 FROM_HERE, 398 FROM_HERE,
403 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false, std::string())); 399 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false, std::string()));
404 } 400 }
405 401
406 void FakeCryptohomeClient::TpmAttestationGetPublicKey( 402 void FakeCryptohomeClient::TpmAttestationGetPublicKey(
407 attestation::AttestationKeyType key_type, 403 attestation::AttestationKeyType key_type,
408 const cryptohome::Identification& cryptohome_id, 404 const cryptohome::Identification& cryptohome_id,
409 const std::string& key_name, 405 const std::string& key_name,
410 const DataMethodCallback& callback) { 406 const DataMethodCallback& callback) {
411 base::MessageLoop::current()->PostTask( 407 base::ThreadTaskRunnerHandle::Get()->PostTask(
412 FROM_HERE, 408 FROM_HERE,
413 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false, std::string())); 409 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false, std::string()));
414 } 410 }
415 411
416 void FakeCryptohomeClient::TpmAttestationRegisterKey( 412 void FakeCryptohomeClient::TpmAttestationRegisterKey(
417 attestation::AttestationKeyType key_type, 413 attestation::AttestationKeyType key_type,
418 const cryptohome::Identification& cryptohome_id, 414 const cryptohome::Identification& cryptohome_id,
419 const std::string& key_name, 415 const std::string& key_name,
420 const AsyncMethodCallback& callback) { 416 const AsyncMethodCallback& callback) {
421 ReturnAsyncMethodResult(callback, true); 417 ReturnAsyncMethodResult(callback, true);
(...skipping 18 matching lines...) Expand all
440 const std::string& challenge, 436 const std::string& challenge,
441 const AsyncMethodCallback& callback) { 437 const AsyncMethodCallback& callback) {
442 ReturnAsyncMethodResult(callback, true); 438 ReturnAsyncMethodResult(callback, true);
443 } 439 }
444 440
445 void FakeCryptohomeClient::TpmAttestationGetKeyPayload( 441 void FakeCryptohomeClient::TpmAttestationGetKeyPayload(
446 attestation::AttestationKeyType key_type, 442 attestation::AttestationKeyType key_type,
447 const cryptohome::Identification& cryptohome_id, 443 const cryptohome::Identification& cryptohome_id,
448 const std::string& key_name, 444 const std::string& key_name,
449 const DataMethodCallback& callback) { 445 const DataMethodCallback& callback) {
450 base::MessageLoop::current()->PostTask( 446 base::ThreadTaskRunnerHandle::Get()->PostTask(
451 FROM_HERE, 447 FROM_HERE,
452 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false, std::string())); 448 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false, std::string()));
453 } 449 }
454 450
455 void FakeCryptohomeClient::TpmAttestationSetKeyPayload( 451 void FakeCryptohomeClient::TpmAttestationSetKeyPayload(
456 attestation::AttestationKeyType key_type, 452 attestation::AttestationKeyType key_type,
457 const cryptohome::Identification& cryptohome_id, 453 const cryptohome::Identification& cryptohome_id,
458 const std::string& key_name, 454 const std::string& key_name,
459 const std::string& payload, 455 const std::string& payload,
460 const BoolDBusMethodCallback& callback) { 456 const BoolDBusMethodCallback& callback) {
461 base::MessageLoop::current()->PostTask( 457 base::ThreadTaskRunnerHandle::Get()->PostTask(
462 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false)); 458 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false));
463 } 459 }
464 460
465 void FakeCryptohomeClient::TpmAttestationDeleteKeys( 461 void FakeCryptohomeClient::TpmAttestationDeleteKeys(
466 attestation::AttestationKeyType key_type, 462 attestation::AttestationKeyType key_type,
467 const cryptohome::Identification& cryptohome_id, 463 const cryptohome::Identification& cryptohome_id,
468 const std::string& key_prefix, 464 const std::string& key_prefix,
469 const BoolDBusMethodCallback& callback) { 465 const BoolDBusMethodCallback& callback) {
470 base::MessageLoop::current()->PostTask( 466 base::ThreadTaskRunnerHandle::Get()->PostTask(
471 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false)); 467 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, false));
472 } 468 }
473 469
474 void FakeCryptohomeClient::GetKeyDataEx( 470 void FakeCryptohomeClient::GetKeyDataEx(
475 const cryptohome::Identification& cryptohome_id, 471 const cryptohome::Identification& cryptohome_id,
476 const cryptohome::AuthorizationRequest& auth, 472 const cryptohome::AuthorizationRequest& auth,
477 const cryptohome::GetKeyDataRequest& request, 473 const cryptohome::GetKeyDataRequest& request,
478 const ProtobufMethodCallback& callback) { 474 const ProtobufMethodCallback& callback) {
479 cryptohome::BaseReply reply; 475 cryptohome::BaseReply reply;
480 reply.MutableExtension(cryptohome::GetKeyDataReply::reply); 476 reply.MutableExtension(cryptohome::GetKeyDataReply::reply);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 // static 562 // static
567 std::vector<uint8_t> FakeCryptohomeClient::GetStubSystemSalt() { 563 std::vector<uint8_t> FakeCryptohomeClient::GetStubSystemSalt() {
568 const char kStubSystemSalt[] = "stub_system_salt"; 564 const char kStubSystemSalt[] = "stub_system_salt";
569 return std::vector<uint8_t>(kStubSystemSalt, 565 return std::vector<uint8_t>(kStubSystemSalt,
570 kStubSystemSalt + arraysize(kStubSystemSalt) - 1); 566 kStubSystemSalt + arraysize(kStubSystemSalt) - 1);
571 } 567 }
572 568
573 void FakeCryptohomeClient::ReturnProtobufMethodCallback( 569 void FakeCryptohomeClient::ReturnProtobufMethodCallback(
574 const cryptohome::BaseReply& reply, 570 const cryptohome::BaseReply& reply,
575 const ProtobufMethodCallback& callback) { 571 const ProtobufMethodCallback& callback) {
576 base::MessageLoop::current()->PostTask( 572 base::ThreadTaskRunnerHandle::Get()->PostTask(
577 FROM_HERE, 573 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS, true, reply));
578 base::Bind(callback,
579 DBUS_METHOD_CALL_SUCCESS,
580 true,
581 reply));
582 } 574 }
583 575
584 void FakeCryptohomeClient::ReturnAsyncMethodResult( 576 void FakeCryptohomeClient::ReturnAsyncMethodResult(
585 const AsyncMethodCallback& callback, 577 const AsyncMethodCallback& callback,
586 bool returns_data) { 578 bool returns_data) {
587 base::MessageLoop::current()->PostTask( 579 base::ThreadTaskRunnerHandle::Get()->PostTask(
588 FROM_HERE, 580 FROM_HERE,
589 base::Bind(&FakeCryptohomeClient::ReturnAsyncMethodResultInternal, 581 base::Bind(&FakeCryptohomeClient::ReturnAsyncMethodResultInternal,
590 weak_ptr_factory_.GetWeakPtr(), 582 weak_ptr_factory_.GetWeakPtr(), callback, returns_data));
591 callback,
592 returns_data));
593 } 583 }
594 584
595 void FakeCryptohomeClient::ReturnAsyncMethodResultInternal( 585 void FakeCryptohomeClient::ReturnAsyncMethodResultInternal(
596 const AsyncMethodCallback& callback, 586 const AsyncMethodCallback& callback,
597 bool returns_data) { 587 bool returns_data) {
598 callback.Run(async_call_id_); 588 callback.Run(async_call_id_);
599 if (!returns_data && !async_call_status_handler_.is_null()) { 589 if (!returns_data && !async_call_status_handler_.is_null()) {
600 base::MessageLoop::current()->PostTask( 590 base::ThreadTaskRunnerHandle::Get()->PostTask(
601 FROM_HERE, 591 FROM_HERE, base::Bind(async_call_status_handler_, async_call_id_, true,
602 base::Bind(async_call_status_handler_, 592 cryptohome::MOUNT_ERROR_NONE));
603 async_call_id_,
604 true,
605 cryptohome::MOUNT_ERROR_NONE));
606 } else if (returns_data && !async_call_status_data_handler_.is_null()) { 593 } else if (returns_data && !async_call_status_data_handler_.is_null()) {
607 base::MessageLoop::current()->PostTask( 594 base::ThreadTaskRunnerHandle::Get()->PostTask(
608 FROM_HERE, 595 FROM_HERE, base::Bind(async_call_status_data_handler_, async_call_id_,
609 base::Bind(async_call_status_data_handler_, 596 true, std::string()));
610 async_call_id_,
611 true,
612 std::string()));
613 } 597 }
614 ++async_call_id_; 598 ++async_call_id_;
615 } 599 }
616 600
617 } // namespace chromeos 601 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/attestation/attestation_flow_unittest.cc ('k') | chromeos/dbus/mock_cryptohome_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698