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

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: Rebase 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 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 315 }
316 316
317 QueryDiskAndUpdateQuotaUsage(origin_url); 317 QueryDiskAndUpdateQuotaUsage(origin_url);
318 if (s.ok()) { 318 if (s.ok()) {
319 RemoveFromOriginSet(origin_url); 319 RemoveFromOriginSet(origin_url);
320 origin_size_map_.erase(origin_url); 320 origin_size_map_.erase(origin_url);
321 space_available_map_.erase(origin_url); 321 space_available_map_.erase(origin_url);
322 } 322 }
323 } 323 }
324 324
325 void IndexedDBContextImpl::CopyOriginData(const GURL& origin_url,
326 IndexedDBContext* dest_context) {
327 DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
328 ForceClose(origin_url, FORCE_CLOSE_COPY_ORIGIN);
329 if (data_path_.empty() || !IsInOriginSet(origin_url))
330 return;
331
332 base::FilePath idb_directory =
333 GetFilePathForTesting(origin_url.possibly_invalid_spec());
jsbell 2014/12/12 17:46:09 The "ForTesting" methods should only be called fro
334 base::FilePath dest_directory =
jsbell 2014/12/12 17:46:09 This is basically just computing <context>/Indexed
ryanackley 2014/12/12 19:03:04 Should I expose the methods I need on IndexedDBCon
335 dest_context->GetFilePathForTesting(origin_url.possibly_invalid_spec());
336
337 if (base::PathExists(dest_directory)) {
338 return;
339 }
340
341 if (!base::PathExists(dest_directory.DirName())) {
342 base::CreateDirectory(dest_directory.DirName());
343 }
344
345 base::CopyDirectory(idb_directory, dest_directory.DirName(), true);
346 }
347
325 void IndexedDBContextImpl::ForceClose(const GURL origin_url, 348 void IndexedDBContextImpl::ForceClose(const GURL origin_url,
326 ForceCloseReason reason) { 349 ForceCloseReason reason) {
327 DCHECK(TaskRunner()->RunsTasksOnCurrentThread()); 350 DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
328 UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.Context.ForceCloseReason", 351 UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.Context.ForceCloseReason",
329 reason, 352 reason,
330 FORCE_CLOSE_REASON_MAX); 353 FORCE_CLOSE_REASON_MAX);
331 354
332 if (data_path_.empty() || !IsInOriginSet(origin_url)) 355 if (data_path_.empty() || !IsInOriginSet(origin_url))
333 return; 356 return;
334 357
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 origin_set_.reset(); 594 origin_set_.reset();
572 origin_size_map_.clear(); 595 origin_size_map_.clear();
573 space_available_map_.clear(); 596 space_available_map_.clear();
574 } 597 }
575 598
576 base::SequencedTaskRunner* IndexedDBContextImpl::TaskRunner() const { 599 base::SequencedTaskRunner* IndexedDBContextImpl::TaskRunner() const {
577 return task_runner_.get(); 600 return task_runner_.get();
578 } 601 }
579 602
580 } // namespace content 603 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698