Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |