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

Side by Side 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: trybot complaints Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/indexed_db/indexed_db_context_impl.h" 5 #include "content/browser/indexed_db/indexed_db_context_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 base::DeleteFile(GetBlobPath(storage::GetIdentifierFromOrigin(origin_url)), 314 base::DeleteFile(GetBlobPath(storage::GetIdentifierFromOrigin(origin_url)),
315 true /* recursive */); 315 true /* recursive */);
316 QueryDiskAndUpdateQuotaUsage(origin_url); 316 QueryDiskAndUpdateQuotaUsage(origin_url);
317 if (s.ok()) { 317 if (s.ok()) {
318 RemoveFromOriginSet(origin_url); 318 RemoveFromOriginSet(origin_url);
319 origin_size_map_.erase(origin_url); 319 origin_size_map_.erase(origin_url);
320 space_available_map_.erase(origin_url); 320 space_available_map_.erase(origin_url);
321 } 321 }
322 } 322 }
323 323
324 void IndexedDBContextImpl::CopyOriginData(const GURL& origin_url,
325 IndexedDBContext* dest_context) {
326 DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
327
328 if (data_path_.empty() || !IsInOriginSet(origin_url))
329 return;
330
331 IndexedDBContextImpl* dest_context_impl =
332 static_cast<IndexedDBContextImpl*>(dest_context);
333
334 ForceClose(origin_url, FORCE_CLOSE_COPY_ORIGIN);
335 std::string origin_id = storage::GetIdentifierFromOrigin(origin_url);
336
337 // Make sure we're not about to delete our own database.
338 CHECK_NE(dest_context_impl->data_path().value(), data_path().value());
339
340 // Delete any existing storage paths in the destination context.
341 // A previously failed migration may have left behind partially copied
342 // directories.
343 for (const base::FilePath& dest_path :
344 dest_context_impl->GetStoragePaths(origin_url))
345 base::DeleteFile(dest_path, true);
346
347 base::FilePath dest_data_path = dest_context_impl->data_path();
348 base::CreateDirectory(dest_data_path);
349
350 for (const base::FilePath& src_data_path : GetStoragePaths(origin_url)) {
351 if (base::PathExists(src_data_path)) {
352 base::CopyDirectory(src_data_path, dest_data_path, true);
353 }
354 }
355 }
356
324 void IndexedDBContextImpl::ForceClose(const GURL origin_url, 357 void IndexedDBContextImpl::ForceClose(const GURL origin_url,
325 ForceCloseReason reason) { 358 ForceCloseReason reason) {
326 DCHECK(TaskRunner()->RunsTasksOnCurrentThread()); 359 DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
327 UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.Context.ForceCloseReason", 360 UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.Context.ForceCloseReason",
328 reason, 361 reason,
329 FORCE_CLOSE_REASON_MAX); 362 FORCE_CLOSE_REASON_MAX);
330 363
331 if (data_path_.empty() || !IsInOriginSet(origin_url)) 364 if (data_path_.empty() || !IsInOriginSet(origin_url))
332 return; 365 return;
333 366
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 origin_set_.reset(); 603 origin_set_.reset();
571 origin_size_map_.clear(); 604 origin_size_map_.clear();
572 space_available_map_.clear(); 605 space_available_map_.clear();
573 } 606 }
574 607
575 base::SequencedTaskRunner* IndexedDBContextImpl::TaskRunner() const { 608 base::SequencedTaskRunner* IndexedDBContextImpl::TaskRunner() const {
576 return task_runner_.get(); 609 return task_runner_.get();
577 } 610 }
578 611
579 } // namespace content 612 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_context_impl.h ('k') | content/public/browser/indexed_db_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698