Commit f56fc9fc authored by Adrienne Walker's avatar Adrienne Walker Committed by Commit Bot

Convert AppDataMigrator to use OnceClosure

This is just in preparation for future changes to how this class uses
IndexedDB.

Change-Id: Ic10969e970f90a62db064c2fa53a388ff63658e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2020564
Auto-Submit: enne <enne@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Commit-Queue: enne <enne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735134}
parent 3e8889d3
...@@ -82,7 +82,7 @@ void MigrateFileSystem(WeakPtr<extensions::AppDataMigrator> migrator, ...@@ -82,7 +82,7 @@ void MigrateFileSystem(WeakPtr<extensions::AppDataMigrator> migrator,
StoragePartition* old_partition, StoragePartition* old_partition,
StoragePartition* current_partition, StoragePartition* current_partition,
const extensions::Extension* extension, const extensions::Extension* extension,
const base::Closure& reply) { base::OnceClosure reply) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Since this method is static and it's being run as a closure task, check to // Since this method is static and it's being run as a closure task, check to
...@@ -103,14 +103,14 @@ void MigrateFileSystem(WeakPtr<extensions::AppDataMigrator> migrator, ...@@ -103,14 +103,14 @@ void MigrateFileSystem(WeakPtr<extensions::AppDataMigrator> migrator,
base::BindOnce( base::BindOnce(
&MigrateOnFileSystemThread, base::RetainedRef(old_fs_context), &MigrateOnFileSystemThread, base::RetainedRef(old_fs_context),
base::RetainedRef(fs_context), base::RetainedRef(extension)), base::RetainedRef(fs_context), base::RetainedRef(extension)),
reply); std::move(reply));
} }
void MigrateLegacyPartition(WeakPtr<extensions::AppDataMigrator> migrator, void MigrateLegacyPartition(WeakPtr<extensions::AppDataMigrator> migrator,
StoragePartition* old_partition, StoragePartition* old_partition,
StoragePartition* current_partition, StoragePartition* current_partition,
const extensions::Extension* extension, const extensions::Extension* extension,
const base::Closure& reply) { base::OnceClosure reply) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
IndexedDBContext* indexed_db_context = IndexedDBContext* indexed_db_context =
...@@ -120,9 +120,9 @@ void MigrateLegacyPartition(WeakPtr<extensions::AppDataMigrator> migrator, ...@@ -120,9 +120,9 @@ void MigrateLegacyPartition(WeakPtr<extensions::AppDataMigrator> migrator,
// Create a closure for the file system migration. This is the next step in // Create a closure for the file system migration. This is the next step in
// the migration flow after the IndexedDB migration. // the migration flow after the IndexedDB migration.
base::Closure migrate_fs = base::OnceClosure migrate_fs = base::BindOnce(
base::Bind(&MigrateFileSystem, migrator, old_partition, current_partition, &MigrateFileSystem, migrator, old_partition, current_partition,
base::RetainedRef(extension), reply); base::RetainedRef(extension), std::move(reply));
// Perform the IndexedDB migration on the old context's sequenced task // Perform the IndexedDB migration on the old context's sequenced task
// runner. After completion, it should call MigrateFileSystem. // runner. After completion, it should call MigrateFileSystem.
...@@ -131,7 +131,7 @@ void MigrateLegacyPartition(WeakPtr<extensions::AppDataMigrator> migrator, ...@@ -131,7 +131,7 @@ void MigrateLegacyPartition(WeakPtr<extensions::AppDataMigrator> migrator,
base::BindOnce( base::BindOnce(
&MigrateOnIndexedDBThread, base::RetainedRef(old_indexed_db_context), &MigrateOnIndexedDBThread, base::RetainedRef(old_indexed_db_context),
base::RetainedRef(indexed_db_context), base::RetainedRef(extension)), base::RetainedRef(indexed_db_context), base::RetainedRef(extension)),
migrate_fs); std::move(migrate_fs));
} }
} // namespace } // namespace
...@@ -151,7 +151,7 @@ bool AppDataMigrator::NeedsMigration(const Extension* old, ...@@ -151,7 +151,7 @@ bool AppDataMigrator::NeedsMigration(const Extension* old,
void AppDataMigrator::DoMigrationAndReply(const Extension* old, void AppDataMigrator::DoMigrationAndReply(const Extension* old,
const Extension* extension, const Extension* extension,
const base::Closure& reply) { base::OnceClosure reply) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(NeedsMigration(old, extension)); DCHECK(NeedsMigration(old, extension));
...@@ -174,7 +174,7 @@ void AppDataMigrator::DoMigrationAndReply(const Extension* old, ...@@ -174,7 +174,7 @@ void AppDataMigrator::DoMigrationAndReply(const Extension* old,
registry_->AddEnabled(old); registry_->AddEnabled(old);
MigrateLegacyPartition(weak_factory_.GetWeakPtr(), old_partition, MigrateLegacyPartition(weak_factory_.GetWeakPtr(), old_partition,
new_partition, extension, reply); new_partition, extension, std::move(reply));
} }
} // namespace extensions } // namespace extensions
...@@ -27,7 +27,7 @@ class AppDataMigrator { ...@@ -27,7 +27,7 @@ class AppDataMigrator {
void DoMigrationAndReply(const Extension* old, void DoMigrationAndReply(const Extension* old,
const Extension* extension, const Extension* extension,
const base::Closure& reply); base::OnceClosure reply);
private: private:
Profile* profile_; Profile* profile_;
......
...@@ -115,9 +115,6 @@ scoped_refptr<const Extension> GetTestExtension(bool platform_app) { ...@@ -115,9 +115,6 @@ scoped_refptr<const Extension> GetTestExtension(bool platform_app) {
return app; return app;
} }
void MigrationCallback() {
}
void DidWrite(base::File::Error status, int64_t bytes, bool complete) { void DidWrite(base::File::Error status, int64_t bytes, bool complete) {
base::RunLoop::QuitCurrentWhenIdleDeprecated(); base::RunLoop::QuitCurrentWhenIdleDeprecated();
} }
...@@ -252,7 +249,7 @@ TEST_F(AppDataMigratorTest, NoOpMigration) { ...@@ -252,7 +249,7 @@ TEST_F(AppDataMigratorTest, NoOpMigration) {
// Nothing to migrate. Basically this should just not cause an error // Nothing to migrate. Basically this should just not cause an error
migrator_->DoMigrationAndReply(old_ext.get(), new_ext.get(), migrator_->DoMigrationAndReply(old_ext.get(), new_ext.get(),
base::Bind(&MigrationCallback)); base::DoNothing());
} }
// crbug.com/747589 // crbug.com/747589
...@@ -264,7 +261,7 @@ TEST_F(AppDataMigratorTest, DISABLED_FileSystemMigration) { ...@@ -264,7 +261,7 @@ TEST_F(AppDataMigratorTest, DISABLED_FileSystemMigration) {
default_fs_context_, profile_.get()); default_fs_context_, profile_.get());
migrator_->DoMigrationAndReply(old_ext.get(), new_ext.get(), migrator_->DoMigrationAndReply(old_ext.get(), new_ext.get(),
base::Bind(&MigrationCallback)); base::DoNothing());
content::RunAllTasksUntilIdle(); content::RunAllTasksUntilIdle();
......
...@@ -1600,8 +1600,9 @@ void ExtensionService::AddNewOrUpdatedExtension( ...@@ -1600,8 +1600,9 @@ void ExtensionService::AddNewOrUpdatedExtension(
const Extension* old = registry_->GetInstalledExtension(extension->id()); const Extension* old = registry_->GetInstalledExtension(extension->id());
if (AppDataMigrator::NeedsMigration(old, extension)) { if (AppDataMigrator::NeedsMigration(old, extension)) {
app_data_migrator_->DoMigrationAndReply( app_data_migrator_->DoMigrationAndReply(
old, extension, base::Bind(&ExtensionService::FinishInstallation, old, extension,
AsWeakPtr(), base::RetainedRef(extension))); base::BindOnce(&ExtensionService::FinishInstallation, AsWeakPtr(),
base::RetainedRef(extension)));
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment