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

Unified 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, 9 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/fake_cryptohome_client.cc
diff --git a/chromeos/dbus/fake_cryptohome_client.cc b/chromeos/dbus/fake_cryptohome_client.cc
index 5954af0593ada4496fe4be01a9044f7bc9ca365b..efc321c4f383123fc728edbe49dc37a4b0a89c3e 100644
--- a/chromeos/dbus/fake_cryptohome_client.cc
+++ b/chromeos/dbus/fake_cryptohome_client.cc
@@ -32,6 +32,10 @@ namespace {
constexpr char kTwentyBytesNonce[] = "+addtwentybytesnonce";
// A symbolic signature.
constexpr char kSignature[] = "signed";
+// Interval to update the progress of MigrateToDircrypto in milliseconds.
+constexpr int kDircryptoMigrationUpdateIntervalMs = 200;
+// The number of updates the MigrateToDircrypto will send before it completes.
+constexpr uint64_t kDircryptoMigrationMaxProgress = 15;
} // namespace
FakeCryptohomeClient::FakeCryptohomeClient()
@@ -66,7 +70,9 @@ void FakeCryptohomeClient::SetLowDiskSpaceHandler(
const LowDiskSpaceHandler& handler) {}
void FakeCryptohomeClient::SetDircryptoMigrationProgressHandler(
- const DircryptoMigrationProgessHandler& handler) {}
+ const DircryptoMigrationProgessHandler& handler) {
+ dircrypto_migration_progress_handler_ = handler;
+}
void FakeCryptohomeClient::WaitForServiceToBeAvailable(
const WaitForServiceToBeAvailableCallback& callback) {
@@ -589,6 +595,11 @@ void FakeCryptohomeClient::MigrateToDircrypto(
const VoidDBusMethodCallback& callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
+ dircrypto_migration_progress_ = 0;
+ dircrypto_migration_progress_timer_.Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(kDircryptoMigrationUpdateIntervalMs),
+ this, &FakeCryptohomeClient::OnDircryptoMigrationProgressUpdated);
}
void FakeCryptohomeClient::SetServiceIsAvailable(bool is_available) {
@@ -655,4 +666,27 @@ void FakeCryptohomeClient::ReturnAsyncMethodDataInternal(
++async_call_id_;
}
+void FakeCryptohomeClient::OnDircryptoMigrationProgressUpdated() {
+ dircrypto_migration_progress_++;
+
+ if (dircrypto_migration_progress_ >= kDircryptoMigrationMaxProgress) {
+ if (!dircrypto_migration_progress_handler_.is_null()) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(dircrypto_migration_progress_handler_,
+ cryptohome::DIRCRYPTO_MIGRATION_SUCCESS,
+ dircrypto_migration_progress_,
+ kDircryptoMigrationMaxProgress));
+ }
+ dircrypto_migration_progress_timer_.Stop();
+ return;
+ }
+ if (!dircrypto_migration_progress_handler_.is_null()) {
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(dircrypto_migration_progress_handler_,
+ cryptohome::DIRCRYPTO_MIGRATION_IN_PROGRESS,
+ dircrypto_migration_progress_,
+ kDircryptoMigrationMaxProgress));
+ }
+}
+
} // namespace chromeos
« 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