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

Unified Diff: content/browser/indexed_db/indexed_db_context_impl.cc

Issue 671873004: Migrates legacy packaged app data when it's upgraded to a platform app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses review comments Created 6 years 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
Index: content/browser/indexed_db/indexed_db_context_impl.cc
diff --git a/content/browser/indexed_db/indexed_db_context_impl.cc b/content/browser/indexed_db/indexed_db_context_impl.cc
index 39b3a07a70ab7d8aed3cb69d7dc0ff9fc12de55d..7f84633ae9547fe6cb2ebca5001d05c072ff3419 100644
--- a/content/browser/indexed_db/indexed_db_context_impl.cc
+++ b/content/browser/indexed_db/indexed_db_context_impl.cc
@@ -313,8 +313,7 @@ void IndexedDBContextImpl::DeleteForOrigin(const GURL& origin_url) {
const bool kNonRecursive = false;
base::DeleteFile(idb_directory, kNonRecursive);
}
- base::DeleteFile(GetBlobPath(storage::GetIdentifierFromOrigin(origin_url)),
- true /* recursive */);
+
QueryDiskAndUpdateQuotaUsage(origin_url);
if (s.ok()) {
RemoveFromOriginSet(origin_url);
@@ -323,6 +322,47 @@ void IndexedDBContextImpl::DeleteForOrigin(const GURL& origin_url) {
}
}
+void IndexedDBContextImpl::CopyOriginData(const GURL& origin_url,
+ IndexedDBContext* dest_context) {
+ DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
+
+ if (data_path_.empty() || !IsInOriginSet(origin_url))
+ return;
+
+ IndexedDBContextImpl* dest_context_impl =
+ static_cast<IndexedDBContextImpl*>(dest_context);
+
+ ForceClose(origin_url, FORCE_CLOSE_COPY_ORIGIN);
+ std::string origin_id = storage::GetIdentifierFromOrigin(origin_url);
+
+ // Make sure we're not about to delete our own database.
+ CHECK(dest_context_impl->data_path() != data_path());
cmumford 2015/01/06 15:30:26 CHECK_NE
+
+ // Delete any existing storage paths in the destination context.
+ // A previously failed migration may have left behind partially copied
+ // directories.
+ for (const base::FilePath& dest_path :
+ dest_context_impl->GetStoragePaths(origin_url)) {
+ if (base::PathExists(dest_path)) {
cmumford 2015/01/06 15:30:27 Nit: consider just calling DeleteFile(), and ignor
+ base::DeleteFile(dest_path, true);
+ }
+ }
+
+ // Creates the IndexedDB directory in the destination context if it doesn't
cmumford 2015/01/06 15:30:26 Comment adds no value - code is obvious.
+ // already exist.
+ base::FilePath dest_data_path = dest_context_impl->data_path();
+ if (!base::PathExists(dest_data_path)) {
+ base::CreateDirectory(dest_data_path);
cmumford 2015/01/06 15:30:27 Consider just calling CreateDirectory and ignoring
+ }
+
+ // Copies the storage paths to the destination context.
cmumford 2015/01/06 15:30:27 Nit: consider dropping obvious comment.
+ for (const base::FilePath& src_path : GetStoragePaths(origin_url)) {
+ if (base::PathExists(src_path)) {
+ base::CopyDirectory(src_path, dest_data_path, true);
cmumford 2015/01/06 15:30:27 Nit: Can you make the names congruent? src_data_p
+ }
+ }
+}
+
void IndexedDBContextImpl::ForceClose(const GURL origin_url,
ForceCloseReason reason) {
DCHECK(TaskRunner()->RunsTasksOnCurrentThread());

Powered by Google App Engine
This is Rietveld 408576698