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

Side by Side Diff: chrome/browser/sync_file_system/local/root_delete_helper.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/sync_file_system/local/root_delete_helper.h" 5 #include "chrome/browser/sync_file_system/local/root_delete_helper.h"
6 6
7 #include "base/sequenced_task_runner.h" 7 #include "base/sequenced_task_runner.h"
8 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" 8 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h"
9 #include "chrome/browser/sync_file_system/local/local_file_sync_status.h" 9 #include "chrome/browser/sync_file_system/local/local_file_sync_status.h"
10 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" 10 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h"
11 #include "chrome/browser/sync_file_system/logger.h" 11 #include "chrome/browser/sync_file_system/logger.h"
12 #include "chrome/browser/sync_file_system/sync_callbacks.h" 12 #include "chrome/browser/sync_file_system/sync_callbacks.h"
13 #include "webkit/browser/fileapi/file_system_context.h" 13 #include "storage/browser/fileapi/file_system_context.h"
14 #include "webkit/browser/fileapi/file_system_url.h" 14 #include "storage/browser/fileapi/file_system_url.h"
15 #include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h" 15 #include "storage/browser/fileapi/sandbox_file_system_backend_delegate.h"
16 #include "webkit/common/fileapi/file_system_util.h" 16 #include "storage/common/fileapi/file_system_util.h"
17 17
18 namespace sync_file_system { 18 namespace sync_file_system {
19 19
20 namespace { 20 namespace {
21 21
22 // This runs on FileSystemContext's default_file_task_runner. 22 // This runs on FileSystemContext's default_file_task_runner.
23 void ResetFileChangeTracker( 23 void ResetFileChangeTracker(storage::FileSystemContext* file_system_context,
24 fileapi::FileSystemContext* file_system_context, 24 const storage::FileSystemURL& url) {
25 const fileapi::FileSystemURL& url) {
26 DCHECK(file_system_context->default_file_task_runner()-> 25 DCHECK(file_system_context->default_file_task_runner()->
27 RunsTasksOnCurrentThread()); 26 RunsTasksOnCurrentThread());
28 SyncFileSystemBackend* backend = 27 SyncFileSystemBackend* backend =
29 SyncFileSystemBackend::GetBackend(file_system_context); 28 SyncFileSystemBackend::GetBackend(file_system_context);
30 DCHECK(backend); 29 DCHECK(backend);
31 DCHECK(backend->change_tracker()); 30 DCHECK(backend->change_tracker());
32 backend->change_tracker()->ResetForFileSystem(url.origin(), url.type()); 31 backend->change_tracker()->ResetForFileSystem(url.origin(), url.type());
33 } 32 }
34 33
35 } // namespace 34 } // namespace
36 35
37 RootDeleteHelper::RootDeleteHelper( 36 RootDeleteHelper::RootDeleteHelper(
38 fileapi::FileSystemContext* file_system_context, 37 storage::FileSystemContext* file_system_context,
39 LocalFileSyncStatus* sync_status, 38 LocalFileSyncStatus* sync_status,
40 const fileapi::FileSystemURL& url, 39 const storage::FileSystemURL& url,
41 const FileStatusCallback& callback) 40 const FileStatusCallback& callback)
42 : file_system_context_(file_system_context), 41 : file_system_context_(file_system_context),
43 url_(url), 42 url_(url),
44 callback_(callback), 43 callback_(callback),
45 sync_status_(sync_status), 44 sync_status_(sync_status),
46 weak_factory_(this) { 45 weak_factory_(this) {
47 DCHECK(file_system_context_); 46 DCHECK(file_system_context_);
48 DCHECK(url_.is_valid()); 47 DCHECK(url_.is_valid());
49 DCHECK(!callback_.is_null()); 48 DCHECK(!callback_.is_null());
50 DCHECK(sync_status_); 49 DCHECK(sync_status_);
51 // This is expected to run on the filesystem root. 50 // This is expected to run on the filesystem root.
52 DCHECK(fileapi::VirtualPath::IsRootPath(url.path())); 51 DCHECK(storage::VirtualPath::IsRootPath(url.path()));
53 } 52 }
54 53
55 RootDeleteHelper::~RootDeleteHelper() { 54 RootDeleteHelper::~RootDeleteHelper() {
56 } 55 }
57 56
58 void RootDeleteHelper::Run() { 57 void RootDeleteHelper::Run() {
59 util::Log(logging::LOG_VERBOSE, FROM_HERE, 58 util::Log(logging::LOG_VERBOSE, FROM_HERE,
60 "Deleting the entire local filesystem for remote root deletion: " 59 "Deleting the entire local filesystem for remote root deletion: "
61 "%s", url_.DebugString().c_str()); 60 "%s", url_.DebugString().c_str());
62 61
(...skipping 19 matching lines...) Expand all
82 base::Bind(&RootDeleteHelper::DidResetFileChangeTracker, 81 base::Bind(&RootDeleteHelper::DidResetFileChangeTracker,
83 weak_factory_.GetWeakPtr())); 82 weak_factory_.GetWeakPtr()));
84 } 83 }
85 84
86 void RootDeleteHelper::DidResetFileChangeTracker() { 85 void RootDeleteHelper::DidResetFileChangeTracker() {
87 DCHECK(!sync_status_->IsWritable(url_)); 86 DCHECK(!sync_status_->IsWritable(url_));
88 DCHECK(!sync_status_->IsWriting(url_)); 87 DCHECK(!sync_status_->IsWriting(url_));
89 88
90 // Reopening the filesystem. 89 // Reopening the filesystem.
91 file_system_context_->sandbox_delegate()->OpenFileSystem( 90 file_system_context_->sandbox_delegate()->OpenFileSystem(
92 url_.origin(), url_.type(), 91 url_.origin(),
93 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 92 url_.type(),
93 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
94 base::Bind(&RootDeleteHelper::DidOpenFileSystem, 94 base::Bind(&RootDeleteHelper::DidOpenFileSystem,
95 weak_factory_.GetWeakPtr()), GURL()); 95 weak_factory_.GetWeakPtr()),
96 GURL());
96 } 97 }
97 98
98 void RootDeleteHelper::DidOpenFileSystem(const GURL& /* root */, 99 void RootDeleteHelper::DidOpenFileSystem(const GURL& /* root */,
99 const std::string& /* name */, 100 const std::string& /* name */,
100 base::File::Error error) { 101 base::File::Error error) {
101 FileStatusCallback callback = callback_; 102 FileStatusCallback callback = callback_;
102 callback.Run(error); 103 callback.Run(error);
103 } 104 }
104 105
105 } // namespace sync_file_system 106 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698