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

Side by Side Diff: webkit/browser/fileapi/plugin_private_file_system_backend.cc

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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 "webkit/browser/fileapi/plugin_private_file_system_backend.h" 5 #include "webkit/browser/fileapi/plugin_private_file_system_backend.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 Map map_; 59 Map map_;
60 }; 60 };
61 61
62 namespace { 62 namespace {
63 63
64 const base::FilePath::CharType* kFileSystemDirectory = 64 const base::FilePath::CharType* kFileSystemDirectory =
65 SandboxFileSystemBackendDelegate::kFileSystemDirectory; 65 SandboxFileSystemBackendDelegate::kFileSystemDirectory;
66 const base::FilePath::CharType* kPluginPrivateDirectory = 66 const base::FilePath::CharType* kPluginPrivateDirectory =
67 FILE_PATH_LITERAL("Plugins"); 67 FILE_PATH_LITERAL("Plugins");
68 68
69 base::PlatformFileError OpenFileSystemOnFileTaskRunner( 69 base::File::Error OpenFileSystemOnFileTaskRunner(
70 ObfuscatedFileUtil* file_util, 70 ObfuscatedFileUtil* file_util,
71 PluginPrivateFileSystemBackend::FileSystemIDToPluginMap* plugin_map, 71 PluginPrivateFileSystemBackend::FileSystemIDToPluginMap* plugin_map,
72 const GURL& origin_url, 72 const GURL& origin_url,
73 const std::string& filesystem_id, 73 const std::string& filesystem_id,
74 const std::string& plugin_id, 74 const std::string& plugin_id,
75 OpenFileSystemMode mode) { 75 OpenFileSystemMode mode) {
76 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; 76 base::File::Error error = base::File::FILE_ERROR_FAILED;
77 const bool create = (mode == OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT); 77 const bool create = (mode == OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT);
78 file_util->GetDirectoryForOriginAndType( 78 file_util->GetDirectoryForOriginAndType(
79 origin_url, plugin_id, create, &error); 79 origin_url, plugin_id, create, &error);
80 if (error == base::PLATFORM_FILE_OK) 80 if (error == base::File::FILE_OK)
81 plugin_map->RegisterFileSystem(filesystem_id, plugin_id); 81 plugin_map->RegisterFileSystem(filesystem_id, plugin_id);
82 return error; 82 return error;
83 } 83 }
84 84
85 } // namespace 85 } // namespace
86 86
87 PluginPrivateFileSystemBackend::PluginPrivateFileSystemBackend( 87 PluginPrivateFileSystemBackend::PluginPrivateFileSystemBackend(
88 base::SequencedTaskRunner* file_task_runner, 88 base::SequencedTaskRunner* file_task_runner,
89 const base::FilePath& profile_path, 89 const base::FilePath& profile_path,
90 quota::SpecialStoragePolicy* special_storage_policy, 90 quota::SpecialStoragePolicy* special_storage_policy,
(...skipping 25 matching lines...) Expand all
116 116
117 void PluginPrivateFileSystemBackend::OpenPrivateFileSystem( 117 void PluginPrivateFileSystemBackend::OpenPrivateFileSystem(
118 const GURL& origin_url, 118 const GURL& origin_url,
119 FileSystemType type, 119 FileSystemType type,
120 const std::string& filesystem_id, 120 const std::string& filesystem_id,
121 const std::string& plugin_id, 121 const std::string& plugin_id,
122 OpenFileSystemMode mode, 122 OpenFileSystemMode mode,
123 const StatusCallback& callback) { 123 const StatusCallback& callback) {
124 if (!CanHandleType(type) || file_system_options_.is_incognito()) { 124 if (!CanHandleType(type) || file_system_options_.is_incognito()) {
125 base::MessageLoopProxy::current()->PostTask( 125 base::MessageLoopProxy::current()->PostTask(
126 FROM_HERE, base::Bind(callback, base::PLATFORM_FILE_ERROR_SECURITY)); 126 FROM_HERE, base::Bind(callback, base::File::FILE_ERROR_SECURITY));
127 return; 127 return;
128 } 128 }
129 129
130 PostTaskAndReplyWithResult( 130 PostTaskAndReplyWithResult(
131 file_task_runner_.get(), 131 file_task_runner_.get(),
132 FROM_HERE, 132 FROM_HERE,
133 base::Bind(&OpenFileSystemOnFileTaskRunner, 133 base::Bind(&OpenFileSystemOnFileTaskRunner,
134 obfuscated_file_util(), plugin_map_, 134 obfuscated_file_util(), plugin_map_,
135 origin_url, filesystem_id, plugin_id, mode), 135 origin_url, filesystem_id, plugin_id, mode),
136 callback); 136 callback);
137 } 137 }
138 138
139 bool PluginPrivateFileSystemBackend::CanHandleType(FileSystemType type) const { 139 bool PluginPrivateFileSystemBackend::CanHandleType(FileSystemType type) const {
140 return type == kFileSystemTypePluginPrivate; 140 return type == kFileSystemTypePluginPrivate;
141 } 141 }
142 142
143 void PluginPrivateFileSystemBackend::Initialize(FileSystemContext* context) { 143 void PluginPrivateFileSystemBackend::Initialize(FileSystemContext* context) {
144 } 144 }
145 145
146 void PluginPrivateFileSystemBackend::OpenFileSystem( 146 void PluginPrivateFileSystemBackend::OpenFileSystem(
147 const GURL& origin_url, 147 const GURL& origin_url,
148 FileSystemType type, 148 FileSystemType type,
149 OpenFileSystemMode mode, 149 OpenFileSystemMode mode,
150 const OpenFileSystemCallback& callback) { 150 const OpenFileSystemCallback& callback) {
151 // We never allow opening a new plugin-private filesystem via usual 151 // We never allow opening a new plugin-private filesystem via usual
152 // OpenFileSystem. 152 // OpenFileSystem.
153 base::MessageLoopProxy::current()->PostTask( 153 base::MessageLoopProxy::current()->PostTask(
154 FROM_HERE, 154 FROM_HERE,
155 base::Bind(callback, GURL(), std::string(), 155 base::Bind(callback, GURL(), std::string(),
156 base::PLATFORM_FILE_ERROR_SECURITY)); 156 base::File::FILE_ERROR_SECURITY));
157 } 157 }
158 158
159 AsyncFileUtil* 159 AsyncFileUtil*
160 PluginPrivateFileSystemBackend::GetAsyncFileUtil(FileSystemType type) { 160 PluginPrivateFileSystemBackend::GetAsyncFileUtil(FileSystemType type) {
161 return file_util_.get(); 161 return file_util_.get();
162 } 162 }
163 163
164 CopyOrMoveFileValidatorFactory* 164 CopyOrMoveFileValidatorFactory*
165 PluginPrivateFileSystemBackend::GetCopyOrMoveFileValidatorFactory( 165 PluginPrivateFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
166 FileSystemType type, 166 FileSystemType type,
167 base::PlatformFileError* error_code) { 167 base::File::Error* error_code) {
168 DCHECK(error_code); 168 DCHECK(error_code);
169 *error_code = base::PLATFORM_FILE_OK; 169 *error_code = base::File::FILE_OK;
170 return NULL; 170 return NULL;
171 } 171 }
172 172
173 FileSystemOperation* PluginPrivateFileSystemBackend::CreateFileSystemOperation( 173 FileSystemOperation* PluginPrivateFileSystemBackend::CreateFileSystemOperation(
174 const FileSystemURL& url, 174 const FileSystemURL& url,
175 FileSystemContext* context, 175 FileSystemContext* context,
176 base::PlatformFileError* error_code) const { 176 base::File::Error* error_code) const {
177 scoped_ptr<FileSystemOperationContext> operation_context( 177 scoped_ptr<FileSystemOperationContext> operation_context(
178 new FileSystemOperationContext(context)); 178 new FileSystemOperationContext(context));
179 return FileSystemOperation::Create(url, context, operation_context.Pass()); 179 return FileSystemOperation::Create(url, context, operation_context.Pass());
180 } 180 }
181 181
182 scoped_ptr<webkit_blob::FileStreamReader> 182 scoped_ptr<webkit_blob::FileStreamReader>
183 PluginPrivateFileSystemBackend::CreateFileStreamReader( 183 PluginPrivateFileSystemBackend::CreateFileStreamReader(
184 const FileSystemURL& url, 184 const FileSystemURL& url,
185 int64 offset, 185 int64 offset,
186 const base::Time& expected_modification_time, 186 const base::Time& expected_modification_time,
187 FileSystemContext* context) const { 187 FileSystemContext* context) const {
188 return scoped_ptr<webkit_blob::FileStreamReader>(); 188 return scoped_ptr<webkit_blob::FileStreamReader>();
189 } 189 }
190 190
191 scoped_ptr<FileStreamWriter> 191 scoped_ptr<FileStreamWriter>
192 PluginPrivateFileSystemBackend::CreateFileStreamWriter( 192 PluginPrivateFileSystemBackend::CreateFileStreamWriter(
193 const FileSystemURL& url, 193 const FileSystemURL& url,
194 int64 offset, 194 int64 offset,
195 FileSystemContext* context) const { 195 FileSystemContext* context) const {
196 return scoped_ptr<FileStreamWriter>(); 196 return scoped_ptr<FileStreamWriter>();
197 } 197 }
198 198
199 FileSystemQuotaUtil* PluginPrivateFileSystemBackend::GetQuotaUtil() { 199 FileSystemQuotaUtil* PluginPrivateFileSystemBackend::GetQuotaUtil() {
200 return this; 200 return this;
201 } 201 }
202 202
203 base::PlatformFileError 203 base::File::Error
204 PluginPrivateFileSystemBackend::DeleteOriginDataOnFileTaskRunner( 204 PluginPrivateFileSystemBackend::DeleteOriginDataOnFileTaskRunner(
205 FileSystemContext* context, 205 FileSystemContext* context,
206 quota::QuotaManagerProxy* proxy, 206 quota::QuotaManagerProxy* proxy,
207 const GURL& origin_url, 207 const GURL& origin_url,
208 FileSystemType type) { 208 FileSystemType type) {
209 if (!CanHandleType(type)) 209 if (!CanHandleType(type))
210 return base::PLATFORM_FILE_ERROR_SECURITY; 210 return base::File::FILE_ERROR_SECURITY;
211 bool result = obfuscated_file_util()->DeleteDirectoryForOriginAndType( 211 bool result = obfuscated_file_util()->DeleteDirectoryForOriginAndType(
212 origin_url, std::string()); 212 origin_url, std::string());
213 if (result) 213 if (result)
214 return base::PLATFORM_FILE_OK; 214 return base::File::FILE_OK;
215 return base::PLATFORM_FILE_ERROR_FAILED; 215 return base::File::FILE_ERROR_FAILED;
216 } 216 }
217 217
218 void PluginPrivateFileSystemBackend::GetOriginsForTypeOnFileTaskRunner( 218 void PluginPrivateFileSystemBackend::GetOriginsForTypeOnFileTaskRunner(
219 FileSystemType type, 219 FileSystemType type,
220 std::set<GURL>* origins) { 220 std::set<GURL>* origins) {
221 if (!CanHandleType(type)) 221 if (!CanHandleType(type))
222 return; 222 return;
223 scoped_ptr<ObfuscatedFileUtil::AbstractOriginEnumerator> enumerator( 223 scoped_ptr<ObfuscatedFileUtil::AbstractOriginEnumerator> enumerator(
224 obfuscated_file_util()->CreateOriginEnumerator()); 224 obfuscated_file_util()->CreateOriginEnumerator());
225 GURL origin; 225 GURL origin;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 FileSystemType type) const { 288 FileSystemType type) const {
289 return NULL; 289 return NULL;
290 } 290 }
291 291
292 ObfuscatedFileUtil* PluginPrivateFileSystemBackend::obfuscated_file_util() { 292 ObfuscatedFileUtil* PluginPrivateFileSystemBackend::obfuscated_file_util() {
293 return static_cast<ObfuscatedFileUtil*>( 293 return static_cast<ObfuscatedFileUtil*>(
294 static_cast<AsyncFileUtilAdapter*>(file_util_.get())->sync_file_util()); 294 static_cast<AsyncFileUtilAdapter*>(file_util_.get())->sync_file_util());
295 } 295 }
296 296
297 } // namespace fileapi 297 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/plugin_private_file_system_backend.h ('k') | webkit/browser/fileapi/quota/quota_backend_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698