Skip to content
Permalink
Browse files

webview: migrate missed profile data.

We missed migrating various data stores in the initial profile directory
migration, because many of them are not created until used. Run the
migration again and move all the missed files as well.

If any new data has been written to the new location already, we rename
it as a backup and then replace it with the old data, as we can't really
merge the data; it's more likely that the old state is useful as the
partial migration only just happened in the M79 rollout for most users.

(cherry picked from commit e614745)

Bug: 1033655
Change-Id: Ib2b7267454f1d9ae896f13a45e01683871c0b764
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1966383
Reviewed-by: Victor Costan <pwnall@chromium.org>
Commit-Queue: Richard Coles <torne@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#725282}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1970630
Reviewed-by: Ben Mason <benmason@chromium.org>
Cr-Commit-Position: refs/branch-heads/3945@{#965}
Cr-Branched-From: e4635ff-refs/heads/master@{#706915}
  • Loading branch information
tornewuff authored and Ben Mason committed Dec 16, 2019
1 parent 07097a3 commit 6080c2bad8b06b80c4040ff5261062217815e4a3
Showing with 39 additions and 11 deletions.
  1. +30 −11 android_webview/browser/aw_browser_context.cc
  2. +9 −0 android_webview/browser/cookie_manager.cc
@@ -84,13 +84,12 @@ void MigrateProfileData(base::FilePath cache_path,
old_cache_path = old_cache_path.DirName().Append(
FILE_PATH_LITERAL("org.chromium.android_webview"));

if (!base::PathExists(old_cache_path))
return;

bool success = base::CreateDirectory(cache_path);
if (success)
success &= base::Move(old_cache_path, cache_path);
DCHECK(success);
if (base::PathExists(old_cache_path)) {
bool success = base::CreateDirectory(cache_path);
if (success)
success &= base::Move(old_cache_path, cache_path);
DCHECK(success);
}

base::FilePath old_context_storage_path;
base::PathService::Get(base::DIR_ANDROID_APP_DATA, &old_context_storage_path);
@@ -101,19 +100,39 @@ void MigrateProfileData(base::FilePath cache_path,

auto migrate_context_storage_data = [&old_context_storage_path,
&context_storage_path](auto& suffix) {
if (base::PathExists(old_context_storage_path.Append(suffix))) {
bool success = base::Move(old_context_storage_path.Append(suffix),
context_storage_path.Append(suffix));

FilePath old_file = old_context_storage_path.Append(suffix);
if (base::PathExists(old_file)) {
FilePath new_file = context_storage_path.Append(suffix);

if (base::PathExists(new_file)) {
bool success =
base::Move(new_file, new_file.AddExtension(".partial-migration"));
DCHECK(success);
}
bool success = base::Move(old_file, new_file);
DCHECK(success);
}
};

// These were handled in the initial migration
migrate_context_storage_data("Web Data");
migrate_context_storage_data("Web Data-journal");
migrate_context_storage_data("GPUCache");
migrate_context_storage_data("blob_storage");
migrate_context_storage_data("Session Storage");

// These were missed in the initial migration
migrate_context_storage_data("Application Cache");
migrate_context_storage_data("File System");
migrate_context_storage_data("IndexedDB");
migrate_context_storage_data("Local Storage");
migrate_context_storage_data("QuotaManager");
migrate_context_storage_data("QuotaManager-journal");
migrate_context_storage_data("Service Worker");
migrate_context_storage_data("VideoDecodeStats");
migrate_context_storage_data("databases");
migrate_context_storage_data("shared_proto_db");
migrate_context_storage_data("webrtc_event_logs");
}

} // namespace
@@ -204,9 +204,18 @@ CookieManager::~CookieManager() {}

void CookieManager::MigrateCookieStorePath() {
base::FilePath old_cookie_store_path = GetPathInAppDirectory("Cookies");
base::FilePath old_cookie_journal_path =
GetPathInAppDirectory("Cookies-journal");

if (base::PathExists(old_cookie_store_path)) {
base::Move(old_cookie_store_path, cookie_store_path_);
base::Move(old_cookie_journal_path, cookie_store_path_);
} else {
// Some users got an incomplete version of this migration where the journal
// was not moved. Delete the old journal if it exists, as we can't merge
// them.
// TODO(torne): remove this in a future release (M81?)
base::DeleteFile(old_cookie_journal_path, false);
}
}

0 comments on commit 6080c2b

Please sign in to comment.
You can’t perform that action at this time.