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

Side by Side Diff: webkit/fileapi/file_system_context.cc

Issue 10828043: Wire up the deleteFileSystem operation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adds comment. Created 8 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
« no previous file with comments | « webkit/fileapi/file_system_context.h ('k') | webkit/fileapi/file_system_mount_point_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "webkit/fileapi/file_system_context.h" 5 #include "webkit/fileapi/file_system_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 18 matching lines...) Expand all
29 namespace fileapi { 29 namespace fileapi {
30 30
31 namespace { 31 namespace {
32 32
33 QuotaClient* CreateQuotaClient( 33 QuotaClient* CreateQuotaClient(
34 FileSystemContext* context, 34 FileSystemContext* context,
35 bool is_incognito) { 35 bool is_incognito) {
36 return new FileSystemQuotaClient(context, is_incognito); 36 return new FileSystemQuotaClient(context, is_incognito);
37 } 37 }
38 38
39 void DidOpenFileSystem(FileSystemContext::OpenFileSystemCallback callback, 39 void DidOpenFileSystem(
40 const GURL& filesystem_root, 40 const FileSystemContext::OpenFileSystemCallback& callback,
41 const std::string& filesystem_name, 41 const GURL& filesystem_root,
42 base::PlatformFileError error) { 42 const std::string& filesystem_name,
43 base::PlatformFileError error) {
43 callback.Run(error, filesystem_name, filesystem_root); 44 callback.Run(error, filesystem_name, filesystem_root);
44 } 45 }
45 46
46 } // anonymous namespace 47 } // anonymous namespace
47 48
48 FileSystemContext::FileSystemContext( 49 FileSystemContext::FileSystemContext(
49 base::SequencedTaskRunner* file_task_runner, 50 base::SequencedTaskRunner* file_task_runner,
50 base::SingleThreadTaskRunner* io_task_runner, 51 base::SingleThreadTaskRunner* io_task_runner,
51 quota::SpecialStoragePolicy* special_storage_policy, 52 quota::SpecialStoragePolicy* special_storage_policy,
52 quota::QuotaManagerProxy* quota_manager_proxy, 53 quota::QuotaManagerProxy* quota_manager_proxy,
(...skipping 18 matching lines...) Expand all
71 #endif 72 #endif
72 } 73 }
73 74
74 bool FileSystemContext::DeleteDataForOriginOnFileThread( 75 bool FileSystemContext::DeleteDataForOriginOnFileThread(
75 const GURL& origin_url) { 76 const GURL& origin_url) {
76 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); 77 DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
77 DCHECK(sandbox_provider()); 78 DCHECK(sandbox_provider());
78 79
79 // Delete temporary and persistent data. 80 // Delete temporary and persistent data.
80 return 81 return
81 sandbox_provider()->DeleteOriginDataOnFileThread( 82 (sandbox_provider()->DeleteOriginDataOnFileThread(
82 this, quota_manager_proxy(), origin_url, kFileSystemTypeTemporary) && 83 this, quota_manager_proxy(), origin_url, kFileSystemTypeTemporary) ==
83 sandbox_provider()->DeleteOriginDataOnFileThread( 84 base::PLATFORM_FILE_OK) &&
84 this, quota_manager_proxy(), origin_url, kFileSystemTypePersistent); 85 (sandbox_provider()->DeleteOriginDataOnFileThread(
85 } 86 this, quota_manager_proxy(), origin_url, kFileSystemTypePersistent) ==
86 87 base::PLATFORM_FILE_OK);
87 bool FileSystemContext::DeleteDataForOriginAndTypeOnFileThread(
88 const GURL& origin_url, FileSystemType type) {
89 DCHECK(file_task_runner_->RunsTasksOnCurrentThread());
90 if (type == fileapi::kFileSystemTypeTemporary ||
91 type == fileapi::kFileSystemTypePersistent) {
92 DCHECK(sandbox_provider());
93 return sandbox_provider()->DeleteOriginDataOnFileThread(
94 this, quota_manager_proxy(), origin_url, type);
95 }
96 return false;
97 } 88 }
98 89
99 FileSystemQuotaUtil* 90 FileSystemQuotaUtil*
100 FileSystemContext::GetQuotaUtil(FileSystemType type) const { 91 FileSystemContext::GetQuotaUtil(FileSystemType type) const {
101 FileSystemMountPointProvider* mount_point_provider = 92 FileSystemMountPointProvider* mount_point_provider =
102 GetMountPointProvider(type); 93 GetMountPointProvider(type);
103 if (!mount_point_provider) 94 if (!mount_point_provider)
104 return NULL; 95 return NULL;
105 return mount_point_provider->GetQuotaUtil(); 96 return mount_point_provider->GetQuotaUtil();
106 } 97 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 133
143 ExternalFileSystemMountPointProvider* 134 ExternalFileSystemMountPointProvider*
144 FileSystemContext::external_provider() const { 135 FileSystemContext::external_provider() const {
145 return external_provider_.get(); 136 return external_provider_.get();
146 } 137 }
147 138
148 void FileSystemContext::OpenFileSystem( 139 void FileSystemContext::OpenFileSystem(
149 const GURL& origin_url, 140 const GURL& origin_url,
150 FileSystemType type, 141 FileSystemType type,
151 bool create, 142 bool create,
152 OpenFileSystemCallback callback) { 143 const OpenFileSystemCallback& callback) {
153 DCHECK(!callback.is_null()); 144 DCHECK(!callback.is_null());
154 145
155 FileSystemMountPointProvider* mount_point_provider = 146 FileSystemMountPointProvider* mount_point_provider =
156 GetMountPointProvider(type); 147 GetMountPointProvider(type);
157 if (!mount_point_provider) { 148 if (!mount_point_provider) {
158 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, std::string(), GURL()); 149 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, std::string(), GURL());
159 return; 150 return;
160 } 151 }
161 152
162 GURL root_url = GetFileSystemRootURI(origin_url, type); 153 GURL root_url = GetFileSystemRootURI(origin_url, type);
163 std::string name = GetFileSystemName(origin_url, type); 154 std::string name = GetFileSystemName(origin_url, type);
164 155
165 mount_point_provider->ValidateFileSystemRoot( 156 mount_point_provider->ValidateFileSystemRoot(
166 origin_url, type, create, 157 origin_url, type, create,
167 base::Bind(&DidOpenFileSystem, callback, root_url, name)); 158 base::Bind(&DidOpenFileSystem, callback, root_url, name));
168 } 159 }
169 160
161 void FileSystemContext::DeleteFileSystem(
162 const GURL& origin_url,
163 FileSystemType type,
164 const DeleteFileSystemCallback& callback) {
165 FileSystemMountPointProvider* mount_point_provider =
166 GetMountPointProvider(type);
167 if (!mount_point_provider) {
168 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
169 return;
170 }
171
172 mount_point_provider->DeleteFileSystem(origin_url, type, this, callback);
173 }
174
170 FileSystemOperationInterface* FileSystemContext::CreateFileSystemOperation( 175 FileSystemOperationInterface* FileSystemContext::CreateFileSystemOperation(
171 const FileSystemURL& url) { 176 const FileSystemURL& url) {
172 if (!url.is_valid()) 177 if (!url.is_valid())
173 return NULL; 178 return NULL;
174 FileSystemMountPointProvider* mount_point_provider = 179 FileSystemMountPointProvider* mount_point_provider =
175 GetMountPointProvider(url.type()); 180 GetMountPointProvider(url.type());
176 if (!mount_point_provider) 181 if (!mount_point_provider)
177 return NULL; 182 return NULL;
178 return mount_point_provider->CreateFileSystemOperation(url, this); 183 return mount_point_provider->CreateFileSystemOperation(url, this);
179 } 184 }
(...skipping 24 matching lines...) Expand all
204 if (!io_task_runner_->RunsTasksOnCurrentThread() && 209 if (!io_task_runner_->RunsTasksOnCurrentThread() &&
205 io_task_runner_->DeleteSoon(FROM_HERE, this)) { 210 io_task_runner_->DeleteSoon(FROM_HERE, this)) {
206 return; 211 return;
207 } 212 }
208 STLDeleteContainerPairSecondPointers(provider_map_.begin(), 213 STLDeleteContainerPairSecondPointers(provider_map_.begin(),
209 provider_map_.end()); 214 provider_map_.end());
210 delete this; 215 delete this;
211 } 216 }
212 217
213 } // namespace fileapi 218 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_context.h ('k') | webkit/fileapi/file_system_mount_point_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698