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

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: More changes for review Created 6 years, 1 month 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 308 }
309 309
310 QueryDiskAndUpdateQuotaUsage(origin_url); 310 QueryDiskAndUpdateQuotaUsage(origin_url);
311 if (s.ok()) { 311 if (s.ok()) {
312 RemoveFromOriginSet(origin_url); 312 RemoveFromOriginSet(origin_url);
313 origin_size_map_.erase(origin_url); 313 origin_size_map_.erase(origin_url);
314 space_available_map_.erase(origin_url); 314 space_available_map_.erase(origin_url);
315 } 315 }
316 } 316 }
317 317
318 void IndexedDBContextImpl::CopyOriginData(const GURL& origin_url,
319 IndexedDBContext* dest_context) {
320 DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
321 ForceClose(origin_url, FORCE_CLOSE_COPY_ORIGIN);
322 if (data_path_.empty() || !IsInOriginSet(origin_url))
323 return;
324
325 base::FilePath idb_directory = GetFilePath(origin_url);
326 base::FilePath dest_directory = dest_context->GetFilePath(origin_url);
327
328 if (base::PathExists(dest_directory)) {
329 return;
330 }
331
332 if (!base::PathExists(dest_directory.DirName())) {
333 base::CreateDirectory(dest_directory.DirName());
334 }
335
336 base::CopyDirectory(idb_directory, dest_directory.DirName(), true);
337 }
338
318 void IndexedDBContextImpl::ForceClose(const GURL origin_url, 339 void IndexedDBContextImpl::ForceClose(const GURL origin_url,
319 ForceCloseReason reason) { 340 ForceCloseReason reason) {
320 DCHECK(TaskRunner()->RunsTasksOnCurrentThread()); 341 DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
321 UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.Context.ForceCloseReason", 342 UMA_HISTOGRAM_ENUMERATION("WebCore.IndexedDB.Context.ForceCloseReason",
322 reason, 343 reason,
323 FORCE_CLOSE_REASON_MAX); 344 FORCE_CLOSE_REASON_MAX);
324 345
325 if (data_path_.empty() || !IsInOriginSet(origin_url)) 346 if (data_path_.empty() || !IsInOriginSet(origin_url))
326 return; 347 return;
327 348
(...skipping 11 matching lines...) Expand all
339 return 0; 360 return 0;
340 361
341 return factory_->GetConnectionCount(origin_url); 362 return factory_->GetConnectionCount(origin_url);
342 } 363 }
343 364
344 base::FilePath IndexedDBContextImpl::GetFilePath(const GURL& origin_url) const { 365 base::FilePath IndexedDBContextImpl::GetFilePath(const GURL& origin_url) const {
345 std::string origin_id = storage::GetIdentifierFromOrigin(origin_url); 366 std::string origin_id = storage::GetIdentifierFromOrigin(origin_url);
346 return GetIndexedDBFilePath(origin_id); 367 return GetIndexedDBFilePath(origin_id);
347 } 368 }
348 369
349 base::FilePath IndexedDBContextImpl::GetFilePathForTesting(
350 const std::string& origin_id) const {
351 return GetIndexedDBFilePath(origin_id);
352 }
353
354 void IndexedDBContextImpl::SetTaskRunnerForTesting( 370 void IndexedDBContextImpl::SetTaskRunnerForTesting(
355 base::SequencedTaskRunner* task_runner) { 371 base::SequencedTaskRunner* task_runner) {
356 DCHECK(!task_runner_.get()); 372 DCHECK(!task_runner_.get());
357 task_runner_ = task_runner; 373 task_runner_ = task_runner;
358 } 374 }
359 375
360 void IndexedDBContextImpl::ConnectionOpened(const GURL& origin_url, 376 void IndexedDBContextImpl::ConnectionOpened(const GURL& origin_url,
361 IndexedDBConnection* connection) { 377 IndexedDBConnection* connection) {
362 DCHECK(TaskRunner()->RunsTasksOnCurrentThread()); 378 DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
363 if (quota_manager_proxy()) { 379 if (quota_manager_proxy()) {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 origin_set_.reset(); 561 origin_set_.reset();
546 origin_size_map_.clear(); 562 origin_size_map_.clear();
547 space_available_map_.clear(); 563 space_available_map_.clear();
548 } 564 }
549 565
550 base::SequencedTaskRunner* IndexedDBContextImpl::TaskRunner() const { 566 base::SequencedTaskRunner* IndexedDBContextImpl::TaskRunner() const {
551 return task_runner_.get(); 567 return task_runner_.get();
552 } 568 }
553 569
554 } // namespace content 570 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698