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

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

Issue 2784273003: Implement a basic UI flow for cryptohome encryption migration. (Closed)
Patch Set: Address review comments. Created 3 years, 8 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
« no previous file with comments | « chromeos/dbus/fake_cryptohome_client.h ('k') | chromeos/login/auth/auth_status_consumer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 14 matching lines...) Expand all
25 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h" 25 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h"
26 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite .h" 26 #include "third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite .h"
27 27
28 namespace chromeos { 28 namespace chromeos {
29 29
30 namespace { 30 namespace {
31 // Signature nonces are twenty bytes. This matches the attestation code. 31 // Signature nonces are twenty bytes. This matches the attestation code.
32 constexpr char kTwentyBytesNonce[] = "+addtwentybytesnonce"; 32 constexpr char kTwentyBytesNonce[] = "+addtwentybytesnonce";
33 // A symbolic signature. 33 // A symbolic signature.
34 constexpr char kSignature[] = "signed"; 34 constexpr char kSignature[] = "signed";
35 // Interval to update the progress of MigrateToDircrypto in milliseconds.
36 constexpr int kDircryptoMigrationUpdateIntervalMs = 200;
37 // The number of updates the MigrateToDircrypto will send before it completes.
38 constexpr uint64_t kDircryptoMigrationMaxProgress = 15;
35 } // namespace 39 } // namespace
36 40
37 FakeCryptohomeClient::FakeCryptohomeClient() 41 FakeCryptohomeClient::FakeCryptohomeClient()
38 : service_is_available_(true), 42 : service_is_available_(true),
39 async_call_id_(1), 43 async_call_id_(1),
40 unmount_result_(true), 44 unmount_result_(true),
41 system_salt_(GetStubSystemSalt()), 45 system_salt_(GetStubSystemSalt()),
42 weak_ptr_factory_(this) { 46 weak_ptr_factory_(this) {
43 base::FilePath cache_path; 47 base::FilePath cache_path;
44 locked_ = PathService::Get(chromeos::FILE_INSTALL_ATTRIBUTES, &cache_path) && 48 locked_ = PathService::Get(chromeos::FILE_INSTALL_ATTRIBUTES, &cache_path) &&
(...skipping 14 matching lines...) Expand all
59 63
60 void FakeCryptohomeClient::ResetAsyncCallStatusHandlers() { 64 void FakeCryptohomeClient::ResetAsyncCallStatusHandlers() {
61 async_call_status_handler_.Reset(); 65 async_call_status_handler_.Reset();
62 async_call_status_data_handler_.Reset(); 66 async_call_status_data_handler_.Reset();
63 } 67 }
64 68
65 void FakeCryptohomeClient::SetLowDiskSpaceHandler( 69 void FakeCryptohomeClient::SetLowDiskSpaceHandler(
66 const LowDiskSpaceHandler& handler) {} 70 const LowDiskSpaceHandler& handler) {}
67 71
68 void FakeCryptohomeClient::SetDircryptoMigrationProgressHandler( 72 void FakeCryptohomeClient::SetDircryptoMigrationProgressHandler(
69 const DircryptoMigrationProgessHandler& handler) {} 73 const DircryptoMigrationProgessHandler& handler) {
74 dircrypto_migration_progress_handler_ = handler;
75 }
70 76
71 void FakeCryptohomeClient::WaitForServiceToBeAvailable( 77 void FakeCryptohomeClient::WaitForServiceToBeAvailable(
72 const WaitForServiceToBeAvailableCallback& callback) { 78 const WaitForServiceToBeAvailableCallback& callback) {
73 if (service_is_available_) { 79 if (service_is_available_) {
74 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 80 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
75 base::Bind(callback, true)); 81 base::Bind(callback, true));
76 } else { 82 } else {
77 pending_wait_for_service_to_be_available_callbacks_.push_back(callback); 83 pending_wait_for_service_to_be_available_callbacks_.push_back(callback);
78 } 84 }
79 } 85 }
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 cryptohome::BaseReply reply; 588 cryptohome::BaseReply reply;
583 ReturnProtobufMethodCallback(reply, callback); 589 ReturnProtobufMethodCallback(reply, callback);
584 } 590 }
585 591
586 void FakeCryptohomeClient::MigrateToDircrypto( 592 void FakeCryptohomeClient::MigrateToDircrypto(
587 const cryptohome::Identification& cryptohome_id, 593 const cryptohome::Identification& cryptohome_id,
588 const cryptohome::AuthorizationRequest& auth, 594 const cryptohome::AuthorizationRequest& auth,
589 const VoidDBusMethodCallback& callback) { 595 const VoidDBusMethodCallback& callback) {
590 base::ThreadTaskRunnerHandle::Get()->PostTask( 596 base::ThreadTaskRunnerHandle::Get()->PostTask(
591 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); 597 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
598 dircrypto_migration_progress_ = 0;
599 dircrypto_migration_progress_timer_.Start(
600 FROM_HERE,
601 base::TimeDelta::FromMilliseconds(kDircryptoMigrationUpdateIntervalMs),
602 this, &FakeCryptohomeClient::OnDircryptoMigrationProgressUpdated);
592 } 603 }
593 604
594 void FakeCryptohomeClient::SetServiceIsAvailable(bool is_available) { 605 void FakeCryptohomeClient::SetServiceIsAvailable(bool is_available) {
595 service_is_available_ = is_available; 606 service_is_available_ = is_available;
596 if (is_available) { 607 if (is_available) {
597 std::vector<WaitForServiceToBeAvailableCallback> callbacks; 608 std::vector<WaitForServiceToBeAvailableCallback> callbacks;
598 callbacks.swap(pending_wait_for_service_to_be_available_callbacks_); 609 callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
599 for (size_t i = 0; i < callbacks.size(); ++i) 610 for (size_t i = 0; i < callbacks.size(); ++i)
600 callbacks[i].Run(is_available); 611 callbacks[i].Run(is_available);
601 } 612 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 const std::string& data) { 659 const std::string& data) {
649 callback.Run(async_call_id_); 660 callback.Run(async_call_id_);
650 if (!async_call_status_data_handler_.is_null()) { 661 if (!async_call_status_data_handler_.is_null()) {
651 base::ThreadTaskRunnerHandle::Get()->PostTask( 662 base::ThreadTaskRunnerHandle::Get()->PostTask(
652 FROM_HERE, base::Bind(async_call_status_data_handler_, async_call_id_, 663 FROM_HERE, base::Bind(async_call_status_data_handler_, async_call_id_,
653 true, data)); 664 true, data));
654 } 665 }
655 ++async_call_id_; 666 ++async_call_id_;
656 } 667 }
657 668
669 void FakeCryptohomeClient::OnDircryptoMigrationProgressUpdated() {
670 dircrypto_migration_progress_++;
671
672 if (dircrypto_migration_progress_ >= kDircryptoMigrationMaxProgress) {
673 if (!dircrypto_migration_progress_handler_.is_null()) {
674 base::ThreadTaskRunnerHandle::Get()->PostTask(
675 FROM_HERE, base::Bind(dircrypto_migration_progress_handler_,
676 cryptohome::DIRCRYPTO_MIGRATION_SUCCESS,
677 dircrypto_migration_progress_,
678 kDircryptoMigrationMaxProgress));
679 }
680 dircrypto_migration_progress_timer_.Stop();
681 return;
682 }
683 if (!dircrypto_migration_progress_handler_.is_null()) {
684 base::ThreadTaskRunnerHandle::Get()->PostTask(
685 FROM_HERE, base::Bind(dircrypto_migration_progress_handler_,
686 cryptohome::DIRCRYPTO_MIGRATION_IN_PROGRESS,
687 dircrypto_migration_progress_,
688 kDircryptoMigrationMaxProgress));
689 }
690 }
691
658 } // namespace chromeos 692 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_cryptohome_client.h ('k') | chromeos/login/auth/auth_status_consumer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698