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 "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 Loading... | |
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 24 matching lines...) Expand all Loading... | |
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 sandbox_provider()->DeleteOriginDataOnFileThread( |
84 this, quota_manager_proxy(), origin_url, kFileSystemTypePersistent); | 85 this, quota_manager_proxy(), origin_url, kFileSystemTypePersistent); |
85 } | 86 } |
86 | 87 |
87 bool FileSystemContext::DeleteDataForOriginAndTypeOnFileThread( | 88 base::PlatformFileError |
89 FileSystemContext::DeleteDataForOriginAndTypeOnFileThread( | |
kinuko
2012/07/31 20:10:30
Since you changed the return code here I think you
nhiroki (google)
2012/08/01 00:15:48
Done.
| |
88 const GURL& origin_url, FileSystemType type) { | 90 const GURL& origin_url, FileSystemType type) { |
89 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); | 91 DCHECK(file_task_runner_->RunsTasksOnCurrentThread()); |
90 if (type == fileapi::kFileSystemTypeTemporary || | 92 if (type == fileapi::kFileSystemTypeTemporary || |
91 type == fileapi::kFileSystemTypePersistent) { | 93 type == fileapi::kFileSystemTypePersistent) { |
92 DCHECK(sandbox_provider()); | 94 DCHECK(sandbox_provider()); |
93 return sandbox_provider()->DeleteOriginDataOnFileThread( | 95 if (sandbox_provider()->DeleteOriginDataOnFileThread( |
94 this, quota_manager_proxy(), origin_url, type); | 96 this, quota_manager_proxy(), origin_url, type)) |
97 return base::PLATFORM_FILE_OK; | |
95 } | 98 } |
96 return false; | 99 return base::PLATFORM_FILE_ERROR_FAILED; |
97 } | 100 } |
98 | 101 |
99 FileSystemQuotaUtil* | 102 FileSystemQuotaUtil* |
100 FileSystemContext::GetQuotaUtil(FileSystemType type) const { | 103 FileSystemContext::GetQuotaUtil(FileSystemType type) const { |
101 FileSystemMountPointProvider* mount_point_provider = | 104 FileSystemMountPointProvider* mount_point_provider = |
102 GetMountPointProvider(type); | 105 GetMountPointProvider(type); |
103 if (!mount_point_provider) | 106 if (!mount_point_provider) |
104 return NULL; | 107 return NULL; |
105 return mount_point_provider->GetQuotaUtil(); | 108 return mount_point_provider->GetQuotaUtil(); |
106 } | 109 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 | 145 |
143 ExternalFileSystemMountPointProvider* | 146 ExternalFileSystemMountPointProvider* |
144 FileSystemContext::external_provider() const { | 147 FileSystemContext::external_provider() const { |
145 return external_provider_.get(); | 148 return external_provider_.get(); |
146 } | 149 } |
147 | 150 |
148 void FileSystemContext::OpenFileSystem( | 151 void FileSystemContext::OpenFileSystem( |
149 const GURL& origin_url, | 152 const GURL& origin_url, |
150 FileSystemType type, | 153 FileSystemType type, |
151 bool create, | 154 bool create, |
152 OpenFileSystemCallback callback) { | 155 const OpenFileSystemCallback& callback) { |
153 DCHECK(!callback.is_null()); | 156 DCHECK(!callback.is_null()); |
154 | 157 |
155 FileSystemMountPointProvider* mount_point_provider = | 158 FileSystemMountPointProvider* mount_point_provider = |
156 GetMountPointProvider(type); | 159 GetMountPointProvider(type); |
157 if (!mount_point_provider) { | 160 if (!mount_point_provider) { |
158 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, std::string(), GURL()); | 161 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, std::string(), GURL()); |
159 return; | 162 return; |
160 } | 163 } |
161 | 164 |
162 GURL root_url = GetFileSystemRootURI(origin_url, type); | 165 GURL root_url = GetFileSystemRootURI(origin_url, type); |
163 std::string name = GetFileSystemName(origin_url, type); | 166 std::string name = GetFileSystemName(origin_url, type); |
164 | 167 |
165 mount_point_provider->ValidateFileSystemRoot( | 168 mount_point_provider->ValidateFileSystemRoot( |
166 origin_url, type, create, | 169 origin_url, type, create, |
167 base::Bind(&DidOpenFileSystem, callback, root_url, name)); | 170 base::Bind(&DidOpenFileSystem, callback, root_url, name)); |
168 } | 171 } |
169 | 172 |
173 void FileSystemContext::DeleteFileSystem( | |
174 const GURL& origin_url, | |
175 FileSystemType type, | |
176 const DeleteFileSystemCallback& callback) { | |
177 FileSystemMountPointProvider* mount_point_provider = | |
178 GetMountPointProvider(type); | |
179 if (!mount_point_provider) { | |
180 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY); | |
181 return; | |
182 } | |
183 | |
184 mount_point_provider->DeleteFileSystem(origin_url, type, this, callback); | |
185 } | |
186 | |
170 FileSystemOperationInterface* FileSystemContext::CreateFileSystemOperation( | 187 FileSystemOperationInterface* FileSystemContext::CreateFileSystemOperation( |
171 const FileSystemURL& url) { | 188 const FileSystemURL& url) { |
172 if (!url.is_valid()) | 189 if (!url.is_valid()) |
173 return NULL; | 190 return NULL; |
174 FileSystemMountPointProvider* mount_point_provider = | 191 FileSystemMountPointProvider* mount_point_provider = |
175 GetMountPointProvider(url.type()); | 192 GetMountPointProvider(url.type()); |
176 if (!mount_point_provider) | 193 if (!mount_point_provider) |
177 return NULL; | 194 return NULL; |
178 return mount_point_provider->CreateFileSystemOperation(url, this); | 195 return mount_point_provider->CreateFileSystemOperation(url, this); |
179 } | 196 } |
(...skipping 24 matching lines...) Expand all Loading... | |
204 if (!io_task_runner_->RunsTasksOnCurrentThread() && | 221 if (!io_task_runner_->RunsTasksOnCurrentThread() && |
205 io_task_runner_->DeleteSoon(FROM_HERE, this)) { | 222 io_task_runner_->DeleteSoon(FROM_HERE, this)) { |
206 return; | 223 return; |
207 } | 224 } |
208 STLDeleteContainerPairSecondPointers(provider_map_.begin(), | 225 STLDeleteContainerPairSecondPointers(provider_map_.begin(), |
209 provider_map_.end()); | 226 provider_map_.end()); |
210 delete this; | 227 delete this; |
211 } | 228 } |
212 | 229 |
213 } // namespace fileapi | 230 } // namespace fileapi |
OLD | NEW |