| 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 225260f69254e90da4596c6df31a07319fecdddd..f1357fdef50fa256bc87bd1e149d950dd437d290 100644
|
| --- a/content/browser/indexed_db/indexed_db_context_impl.cc
|
| +++ b/content/browser/indexed_db/indexed_db_context_impl.cc
|
| @@ -321,6 +321,39 @@ 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_NE(dest_context_impl->data_path().value(), data_path().value());
|
| +
|
| + // 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))
|
| + base::DeleteFile(dest_path, true);
|
| +
|
| + base::FilePath dest_data_path = dest_context_impl->data_path();
|
| + base::CreateDirectory(dest_data_path);
|
| +
|
| + for (const base::FilePath& src_data_path : GetStoragePaths(origin_url)) {
|
| + if (base::PathExists(src_data_path)) {
|
| + base::CopyDirectory(src_data_path, dest_data_path, true);
|
| + }
|
| + }
|
| +}
|
| +
|
| void IndexedDBContextImpl::ForceClose(const GURL origin_url,
|
| ForceCloseReason reason) {
|
| DCHECK(TaskRunner()->RunsTasksOnCurrentThread());
|
|
|