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: chrome/browser/chromeos/fileapi/file_system_backend.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/chromeos/fileapi/file_system_backend.h" 5 #include "chrome/browser/chromeos/fileapi/file_system_backend.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" 10 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h"
11 #include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h" 11 #include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h"
12 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" 12 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h"
13 #include "chromeos/dbus/cros_disks_client.h" 13 #include "chromeos/dbus/cros_disks_client.h"
14 #include "webkit/browser/blob/file_stream_reader.h" 14 #include "storage/browser/blob/file_stream_reader.h"
15 #include "webkit/browser/fileapi/async_file_util.h" 15 #include "storage/browser/fileapi/async_file_util.h"
16 #include "webkit/browser/fileapi/external_mount_points.h" 16 #include "storage/browser/fileapi/external_mount_points.h"
17 #include "webkit/browser/fileapi/file_stream_writer.h" 17 #include "storage/browser/fileapi/file_stream_writer.h"
18 #include "webkit/browser/fileapi/file_system_context.h" 18 #include "storage/browser/fileapi/file_system_context.h"
19 #include "webkit/browser/fileapi/file_system_operation.h" 19 #include "storage/browser/fileapi/file_system_operation.h"
20 #include "webkit/browser/fileapi/file_system_operation_context.h" 20 #include "storage/browser/fileapi/file_system_operation_context.h"
21 #include "webkit/browser/fileapi/file_system_url.h" 21 #include "storage/browser/fileapi/file_system_url.h"
22 22
23 namespace chromeos { 23 namespace chromeos {
24 24
25 // static 25 // static
26 bool FileSystemBackend::CanHandleURL(const fileapi::FileSystemURL& url) { 26 bool FileSystemBackend::CanHandleURL(const storage::FileSystemURL& url) {
27 if (!url.is_valid()) 27 if (!url.is_valid())
28 return false; 28 return false;
29 return url.type() == fileapi::kFileSystemTypeNativeLocal || 29 return url.type() == storage::kFileSystemTypeNativeLocal ||
30 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal || 30 url.type() == storage::kFileSystemTypeRestrictedNativeLocal ||
31 url.type() == fileapi::kFileSystemTypeDrive || 31 url.type() == storage::kFileSystemTypeDrive ||
32 url.type() == fileapi::kFileSystemTypeProvided || 32 url.type() == storage::kFileSystemTypeProvided ||
33 url.type() == fileapi::kFileSystemTypeDeviceMediaAsFileStorage; 33 url.type() == storage::kFileSystemTypeDeviceMediaAsFileStorage;
34 } 34 }
35 35
36 FileSystemBackend::FileSystemBackend( 36 FileSystemBackend::FileSystemBackend(
37 FileSystemBackendDelegate* drive_delegate, 37 FileSystemBackendDelegate* drive_delegate,
38 FileSystemBackendDelegate* file_system_provider_delegate, 38 FileSystemBackendDelegate* file_system_provider_delegate,
39 FileSystemBackendDelegate* mtp_delegate, 39 FileSystemBackendDelegate* mtp_delegate,
40 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, 40 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
41 scoped_refptr<fileapi::ExternalMountPoints> mount_points, 41 scoped_refptr<storage::ExternalMountPoints> mount_points,
42 fileapi::ExternalMountPoints* system_mount_points) 42 storage::ExternalMountPoints* system_mount_points)
43 : special_storage_policy_(special_storage_policy), 43 : special_storage_policy_(special_storage_policy),
44 file_access_permissions_(new FileAccessPermissions()), 44 file_access_permissions_(new FileAccessPermissions()),
45 local_file_util_(fileapi::AsyncFileUtil::CreateForLocalFileSystem()), 45 local_file_util_(storage::AsyncFileUtil::CreateForLocalFileSystem()),
46 drive_delegate_(drive_delegate), 46 drive_delegate_(drive_delegate),
47 file_system_provider_delegate_(file_system_provider_delegate), 47 file_system_provider_delegate_(file_system_provider_delegate),
48 mtp_delegate_(mtp_delegate), 48 mtp_delegate_(mtp_delegate),
49 mount_points_(mount_points), 49 mount_points_(mount_points),
50 system_mount_points_(system_mount_points) {} 50 system_mount_points_(system_mount_points) {
51 }
51 52
52 FileSystemBackend::~FileSystemBackend() { 53 FileSystemBackend::~FileSystemBackend() {
53 } 54 }
54 55
55 void FileSystemBackend::AddSystemMountPoints() { 56 void FileSystemBackend::AddSystemMountPoints() {
56 // RegisterFileSystem() is no-op if the mount point with the same name 57 // RegisterFileSystem() is no-op if the mount point with the same name
57 // already exists, hence it's safe to call without checking if a mount 58 // already exists, hence it's safe to call without checking if a mount
58 // point already exists or not. 59 // point already exists or not.
59 system_mount_points_->RegisterFileSystem( 60 system_mount_points_->RegisterFileSystem(
60 "archive", 61 "archive",
61 fileapi::kFileSystemTypeNativeLocal, 62 storage::kFileSystemTypeNativeLocal,
62 fileapi::FileSystemMountOption(), 63 storage::FileSystemMountOption(),
63 chromeos::CrosDisksClient::GetArchiveMountPoint()); 64 chromeos::CrosDisksClient::GetArchiveMountPoint());
64 system_mount_points_->RegisterFileSystem( 65 system_mount_points_->RegisterFileSystem(
65 "removable", 66 "removable",
66 fileapi::kFileSystemTypeNativeLocal, 67 storage::kFileSystemTypeNativeLocal,
67 fileapi::FileSystemMountOption(fileapi::COPY_SYNC_OPTION_SYNC), 68 storage::FileSystemMountOption(storage::COPY_SYNC_OPTION_SYNC),
68 chromeos::CrosDisksClient::GetRemovableDiskMountPoint()); 69 chromeos::CrosDisksClient::GetRemovableDiskMountPoint());
69 system_mount_points_->RegisterFileSystem( 70 system_mount_points_->RegisterFileSystem(
70 "oem", 71 "oem",
71 fileapi::kFileSystemTypeRestrictedNativeLocal, 72 storage::kFileSystemTypeRestrictedNativeLocal,
72 fileapi::FileSystemMountOption(), 73 storage::FileSystemMountOption(),
73 base::FilePath(FILE_PATH_LITERAL("/usr/share/oem"))); 74 base::FilePath(FILE_PATH_LITERAL("/usr/share/oem")));
74 } 75 }
75 76
76 bool FileSystemBackend::CanHandleType(fileapi::FileSystemType type) const { 77 bool FileSystemBackend::CanHandleType(storage::FileSystemType type) const {
77 switch (type) { 78 switch (type) {
78 case fileapi::kFileSystemTypeExternal: 79 case storage::kFileSystemTypeExternal:
79 case fileapi::kFileSystemTypeDrive: 80 case storage::kFileSystemTypeDrive:
80 case fileapi::kFileSystemTypeRestrictedNativeLocal: 81 case storage::kFileSystemTypeRestrictedNativeLocal:
81 case fileapi::kFileSystemTypeNativeLocal: 82 case storage::kFileSystemTypeNativeLocal:
82 case fileapi::kFileSystemTypeNativeForPlatformApp: 83 case storage::kFileSystemTypeNativeForPlatformApp:
83 case fileapi::kFileSystemTypeDeviceMediaAsFileStorage: 84 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
84 case fileapi::kFileSystemTypeProvided: 85 case storage::kFileSystemTypeProvided:
85 return true; 86 return true;
86 default: 87 default:
87 return false; 88 return false;
88 } 89 }
89 } 90 }
90 91
91 void FileSystemBackend::Initialize(fileapi::FileSystemContext* context) { 92 void FileSystemBackend::Initialize(storage::FileSystemContext* context) {
92 } 93 }
93 94
94 void FileSystemBackend::ResolveURL(const fileapi::FileSystemURL& url, 95 void FileSystemBackend::ResolveURL(const storage::FileSystemURL& url,
95 fileapi::OpenFileSystemMode mode, 96 storage::OpenFileSystemMode mode,
96 const OpenFileSystemCallback& callback) { 97 const OpenFileSystemCallback& callback) {
97 std::string id; 98 std::string id;
98 fileapi::FileSystemType type; 99 storage::FileSystemType type;
99 std::string cracked_id; 100 std::string cracked_id;
100 base::FilePath path; 101 base::FilePath path;
101 fileapi::FileSystemMountOption option; 102 storage::FileSystemMountOption option;
102 if (!mount_points_->CrackVirtualPath( 103 if (!mount_points_->CrackVirtualPath(
103 url.virtual_path(), &id, &type, &cracked_id, &path, &option) && 104 url.virtual_path(), &id, &type, &cracked_id, &path, &option) &&
104 !system_mount_points_->CrackVirtualPath( 105 !system_mount_points_->CrackVirtualPath(
105 url.virtual_path(), &id, &type, &cracked_id, &path, &option)) { 106 url.virtual_path(), &id, &type, &cracked_id, &path, &option)) {
106 // Not under a mount point, so return an error, since the root is not 107 // Not under a mount point, so return an error, since the root is not
107 // accessible. 108 // accessible.
108 GURL root_url = GURL(fileapi::GetExternalFileSystemRootURIString( 109 GURL root_url = GURL(storage::GetExternalFileSystemRootURIString(
109 url.origin(), std::string())); 110 url.origin(), std::string()));
110 callback.Run(root_url, std::string(), base::File::FILE_ERROR_SECURITY); 111 callback.Run(root_url, std::string(), base::File::FILE_ERROR_SECURITY);
111 return; 112 return;
112 } 113 }
113 114
114 std::string name; 115 std::string name;
115 // Construct a URL restricted to the found mount point. 116 // Construct a URL restricted to the found mount point.
116 std::string root_url = 117 std::string root_url =
117 fileapi::GetExternalFileSystemRootURIString(url.origin(), id); 118 storage::GetExternalFileSystemRootURIString(url.origin(), id);
118 119
119 // For removable and archives, the file system root is the external mount 120 // For removable and archives, the file system root is the external mount
120 // point plus the inner mount point. 121 // point plus the inner mount point.
121 if (id == "archive" || id == "removable") { 122 if (id == "archive" || id == "removable") {
122 std::vector<std::string> components; 123 std::vector<std::string> components;
123 url.virtual_path().GetComponents(&components); 124 url.virtual_path().GetComponents(&components);
124 DCHECK_EQ(id, components.at(0)); 125 DCHECK_EQ(id, components.at(0));
125 if (components.size() < 2) { 126 if (components.size() < 2) {
126 // Unable to access /archive and /removable directories directly. The 127 // Unable to access /archive and /removable directories directly. The
127 // inner mount name must be specified. 128 // inner mount name must be specified.
128 callback.Run( 129 callback.Run(
129 GURL(root_url), std::string(), base::File::FILE_ERROR_SECURITY); 130 GURL(root_url), std::string(), base::File::FILE_ERROR_SECURITY);
130 return; 131 return;
131 } 132 }
132 std::string inner_mount_name = components[1]; 133 std::string inner_mount_name = components[1];
133 root_url += inner_mount_name + "/"; 134 root_url += inner_mount_name + "/";
134 name = inner_mount_name; 135 name = inner_mount_name;
135 } else { 136 } else {
136 name = id; 137 name = id;
137 } 138 }
138 139
139 callback.Run(GURL(root_url), name, base::File::FILE_OK); 140 callback.Run(GURL(root_url), name, base::File::FILE_OK);
140 } 141 }
141 142
142 fileapi::FileSystemQuotaUtil* FileSystemBackend::GetQuotaUtil() { 143 storage::FileSystemQuotaUtil* FileSystemBackend::GetQuotaUtil() {
143 // No quota support. 144 // No quota support.
144 return NULL; 145 return NULL;
145 } 146 }
146 147
147 bool FileSystemBackend::IsAccessAllowed( 148 bool FileSystemBackend::IsAccessAllowed(
148 const fileapi::FileSystemURL& url) const { 149 const storage::FileSystemURL& url) const {
149 if (!url.is_valid()) 150 if (!url.is_valid())
150 return false; 151 return false;
151 152
152 // No extra check is needed for isolated file systems. 153 // No extra check is needed for isolated file systems.
153 if (url.mount_type() == fileapi::kFileSystemTypeIsolated) 154 if (url.mount_type() == storage::kFileSystemTypeIsolated)
154 return true; 155 return true;
155 156
156 if (!CanHandleURL(url)) 157 if (!CanHandleURL(url))
157 return false; 158 return false;
158 159
159 std::string extension_id = url.origin().host(); 160 std::string extension_id = url.origin().host();
160 // TODO(mtomasz): Temporarily whitelist TimeScapes. Remove this in M-31. 161 // TODO(mtomasz): Temporarily whitelist TimeScapes. Remove this in M-31.
161 // See: crbug.com/271946 162 // See: crbug.com/271946
162 if (extension_id == "mlbmkoenclnokonejhlfakkeabdlmpek" && 163 if (extension_id == "mlbmkoenclnokonejhlfakkeabdlmpek" &&
163 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal) { 164 url.type() == storage::kFileSystemTypeRestrictedNativeLocal) {
164 return true; 165 return true;
165 } 166 }
166 167
167 // Check first to make sure this extension has fileBrowserHander permissions. 168 // Check first to make sure this extension has fileBrowserHander permissions.
168 if (!special_storage_policy_ || 169 if (!special_storage_policy_ ||
169 !special_storage_policy_->IsFileHandler(extension_id)) 170 !special_storage_policy_->IsFileHandler(extension_id))
170 return false; 171 return false;
171 172
172 return file_access_permissions_->HasAccessPermission(extension_id, 173 return file_access_permissions_->HasAccessPermission(extension_id,
173 url.virtual_path()); 174 url.virtual_path());
(...skipping 14 matching lines...) Expand all
188 const std::string& extension_id, const base::FilePath& virtual_path) { 189 const std::string& extension_id, const base::FilePath& virtual_path) {
189 if (!special_storage_policy_) 190 if (!special_storage_policy_)
190 return; 191 return;
191 // All we care about here is access from extensions for now. 192 // All we care about here is access from extensions for now.
192 if (!special_storage_policy_->IsFileHandler(extension_id)) { 193 if (!special_storage_policy_->IsFileHandler(extension_id)) {
193 NOTREACHED(); 194 NOTREACHED();
194 return; 195 return;
195 } 196 }
196 197
197 std::string id; 198 std::string id;
198 fileapi::FileSystemType type; 199 storage::FileSystemType type;
199 std::string cracked_id; 200 std::string cracked_id;
200 base::FilePath path; 201 base::FilePath path;
201 fileapi::FileSystemMountOption option; 202 storage::FileSystemMountOption option;
202 if (!mount_points_->CrackVirtualPath(virtual_path, &id, &type, &cracked_id, 203 if (!mount_points_->CrackVirtualPath(virtual_path, &id, &type, &cracked_id,
203 &path, &option) && 204 &path, &option) &&
204 !system_mount_points_->CrackVirtualPath(virtual_path, &id, &type, 205 !system_mount_points_->CrackVirtualPath(virtual_path, &id, &type,
205 &cracked_id, &path, &option)) { 206 &cracked_id, &path, &option)) {
206 return; 207 return;
207 } 208 }
208 209
209 if (type == fileapi::kFileSystemTypeRestrictedNativeLocal) { 210 if (type == storage::kFileSystemTypeRestrictedNativeLocal) {
210 LOG(ERROR) << "Can't grant access for restricted mount point"; 211 LOG(ERROR) << "Can't grant access for restricted mount point";
211 return; 212 return;
212 } 213 }
213 214
214 file_access_permissions_->GrantAccessPermission(extension_id, virtual_path); 215 file_access_permissions_->GrantAccessPermission(extension_id, virtual_path);
215 } 216 }
216 217
217 void FileSystemBackend::RevokeAccessForExtension( 218 void FileSystemBackend::RevokeAccessForExtension(
218 const std::string& extension_id) { 219 const std::string& extension_id) {
219 file_access_permissions_->RevokePermissions(extension_id); 220 file_access_permissions_->RevokePermissions(extension_id);
220 } 221 }
221 222
222 std::vector<base::FilePath> FileSystemBackend::GetRootDirectories() const { 223 std::vector<base::FilePath> FileSystemBackend::GetRootDirectories() const {
223 std::vector<fileapi::MountPoints::MountPointInfo> mount_points; 224 std::vector<storage::MountPoints::MountPointInfo> mount_points;
224 mount_points_->AddMountPointInfosTo(&mount_points); 225 mount_points_->AddMountPointInfosTo(&mount_points);
225 system_mount_points_->AddMountPointInfosTo(&mount_points); 226 system_mount_points_->AddMountPointInfosTo(&mount_points);
226 227
227 std::vector<base::FilePath> root_dirs; 228 std::vector<base::FilePath> root_dirs;
228 for (size_t i = 0; i < mount_points.size(); ++i) 229 for (size_t i = 0; i < mount_points.size(); ++i)
229 root_dirs.push_back(mount_points[i].path); 230 root_dirs.push_back(mount_points[i].path);
230 return root_dirs; 231 return root_dirs;
231 } 232 }
232 233
233 fileapi::AsyncFileUtil* FileSystemBackend::GetAsyncFileUtil( 234 storage::AsyncFileUtil* FileSystemBackend::GetAsyncFileUtil(
234 fileapi::FileSystemType type) { 235 storage::FileSystemType type) {
235 switch (type) { 236 switch (type) {
236 case fileapi::kFileSystemTypeDrive: 237 case storage::kFileSystemTypeDrive:
237 return drive_delegate_->GetAsyncFileUtil(type); 238 return drive_delegate_->GetAsyncFileUtil(type);
238 case fileapi::kFileSystemTypeProvided: 239 case storage::kFileSystemTypeProvided:
239 return file_system_provider_delegate_->GetAsyncFileUtil(type); 240 return file_system_provider_delegate_->GetAsyncFileUtil(type);
240 case fileapi::kFileSystemTypeNativeLocal: 241 case storage::kFileSystemTypeNativeLocal:
241 case fileapi::kFileSystemTypeRestrictedNativeLocal: 242 case storage::kFileSystemTypeRestrictedNativeLocal:
242 return local_file_util_.get(); 243 return local_file_util_.get();
243 case fileapi::kFileSystemTypeDeviceMediaAsFileStorage: 244 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
244 return mtp_delegate_->GetAsyncFileUtil(type); 245 return mtp_delegate_->GetAsyncFileUtil(type);
245 default: 246 default:
246 NOTREACHED(); 247 NOTREACHED();
247 } 248 }
248 return NULL; 249 return NULL;
249 } 250 }
250 251
251 fileapi::CopyOrMoveFileValidatorFactory* 252 storage::CopyOrMoveFileValidatorFactory*
252 FileSystemBackend::GetCopyOrMoveFileValidatorFactory( 253 FileSystemBackend::GetCopyOrMoveFileValidatorFactory(
253 fileapi::FileSystemType type, base::File::Error* error_code) { 254 storage::FileSystemType type,
255 base::File::Error* error_code) {
254 DCHECK(error_code); 256 DCHECK(error_code);
255 *error_code = base::File::FILE_OK; 257 *error_code = base::File::FILE_OK;
256 return NULL; 258 return NULL;
257 } 259 }
258 260
259 fileapi::FileSystemOperation* FileSystemBackend::CreateFileSystemOperation( 261 storage::FileSystemOperation* FileSystemBackend::CreateFileSystemOperation(
260 const fileapi::FileSystemURL& url, 262 const storage::FileSystemURL& url,
261 fileapi::FileSystemContext* context, 263 storage::FileSystemContext* context,
262 base::File::Error* error_code) const { 264 base::File::Error* error_code) const {
263 DCHECK(url.is_valid()); 265 DCHECK(url.is_valid());
264 266
265 if (!IsAccessAllowed(url)) { 267 if (!IsAccessAllowed(url)) {
266 *error_code = base::File::FILE_ERROR_SECURITY; 268 *error_code = base::File::FILE_ERROR_SECURITY;
267 return NULL; 269 return NULL;
268 } 270 }
269 271
270 if (url.type() == fileapi::kFileSystemTypeDeviceMediaAsFileStorage) { 272 if (url.type() == storage::kFileSystemTypeDeviceMediaAsFileStorage) {
271 // MTP file operations run on MediaTaskRunner. 273 // MTP file operations run on MediaTaskRunner.
272 return fileapi::FileSystemOperation::Create( 274 return storage::FileSystemOperation::Create(
273 url, context, 275 url,
274 make_scoped_ptr(new fileapi::FileSystemOperationContext( 276 context,
277 make_scoped_ptr(new storage::FileSystemOperationContext(
275 context, MediaFileSystemBackend::MediaTaskRunner()))); 278 context, MediaFileSystemBackend::MediaTaskRunner())));
276 } 279 }
277 280
278 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal || 281 DCHECK(url.type() == storage::kFileSystemTypeNativeLocal ||
279 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal || 282 url.type() == storage::kFileSystemTypeRestrictedNativeLocal ||
280 url.type() == fileapi::kFileSystemTypeDrive || 283 url.type() == storage::kFileSystemTypeDrive ||
281 url.type() == fileapi::kFileSystemTypeProvided); 284 url.type() == storage::kFileSystemTypeProvided);
282 return fileapi::FileSystemOperation::Create( 285 return storage::FileSystemOperation::Create(
283 url, context, 286 url,
284 make_scoped_ptr(new fileapi::FileSystemOperationContext(context))); 287 context,
288 make_scoped_ptr(new storage::FileSystemOperationContext(context)));
285 } 289 }
286 290
287 bool FileSystemBackend::SupportsStreaming( 291 bool FileSystemBackend::SupportsStreaming(
288 const fileapi::FileSystemURL& url) const { 292 const storage::FileSystemURL& url) const {
289 return url.type() == fileapi::kFileSystemTypeDrive || 293 return url.type() == storage::kFileSystemTypeDrive ||
290 url.type() == fileapi::kFileSystemTypeProvided || 294 url.type() == storage::kFileSystemTypeProvided ||
291 url.type() == fileapi::kFileSystemTypeDeviceMediaAsFileStorage; 295 url.type() == storage::kFileSystemTypeDeviceMediaAsFileStorage;
292 } 296 }
293 297
294 scoped_ptr<webkit_blob::FileStreamReader> 298 scoped_ptr<storage::FileStreamReader> FileSystemBackend::CreateFileStreamReader(
295 FileSystemBackend::CreateFileStreamReader( 299 const storage::FileSystemURL& url,
296 const fileapi::FileSystemURL& url,
297 int64 offset, 300 int64 offset,
298 const base::Time& expected_modification_time, 301 const base::Time& expected_modification_time,
299 fileapi::FileSystemContext* context) const { 302 storage::FileSystemContext* context) const {
300 DCHECK(url.is_valid()); 303 DCHECK(url.is_valid());
301 304
302 if (!IsAccessAllowed(url)) 305 if (!IsAccessAllowed(url))
303 return scoped_ptr<webkit_blob::FileStreamReader>(); 306 return scoped_ptr<storage::FileStreamReader>();
304 307
305 switch (url.type()) { 308 switch (url.type()) {
306 case fileapi::kFileSystemTypeDrive: 309 case storage::kFileSystemTypeDrive:
307 return drive_delegate_->CreateFileStreamReader( 310 return drive_delegate_->CreateFileStreamReader(
308 url, offset, expected_modification_time, context); 311 url, offset, expected_modification_time, context);
309 case fileapi::kFileSystemTypeProvided: 312 case storage::kFileSystemTypeProvided:
310 return file_system_provider_delegate_->CreateFileStreamReader( 313 return file_system_provider_delegate_->CreateFileStreamReader(
311 url, offset, expected_modification_time, context); 314 url, offset, expected_modification_time, context);
312 case fileapi::kFileSystemTypeNativeLocal: 315 case storage::kFileSystemTypeNativeLocal:
313 case fileapi::kFileSystemTypeRestrictedNativeLocal: 316 case storage::kFileSystemTypeRestrictedNativeLocal:
314 return scoped_ptr<webkit_blob::FileStreamReader>( 317 return scoped_ptr<storage::FileStreamReader>(
315 webkit_blob::FileStreamReader::CreateForFileSystemFile( 318 storage::FileStreamReader::CreateForFileSystemFile(
316 context, url, offset, expected_modification_time)); 319 context, url, offset, expected_modification_time));
317 case fileapi::kFileSystemTypeDeviceMediaAsFileStorage: 320 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
318 return mtp_delegate_->CreateFileStreamReader( 321 return mtp_delegate_->CreateFileStreamReader(
319 url, offset, expected_modification_time, context); 322 url, offset, expected_modification_time, context);
320 default: 323 default:
321 NOTREACHED(); 324 NOTREACHED();
322 } 325 }
323 return scoped_ptr<webkit_blob::FileStreamReader>(); 326 return scoped_ptr<storage::FileStreamReader>();
324 } 327 }
325 328
326 scoped_ptr<fileapi::FileStreamWriter> 329 scoped_ptr<storage::FileStreamWriter> FileSystemBackend::CreateFileStreamWriter(
327 FileSystemBackend::CreateFileStreamWriter( 330 const storage::FileSystemURL& url,
328 const fileapi::FileSystemURL& url,
329 int64 offset, 331 int64 offset,
330 fileapi::FileSystemContext* context) const { 332 storage::FileSystemContext* context) const {
331 DCHECK(url.is_valid()); 333 DCHECK(url.is_valid());
332 334
333 if (!IsAccessAllowed(url)) 335 if (!IsAccessAllowed(url))
334 return scoped_ptr<fileapi::FileStreamWriter>(); 336 return scoped_ptr<storage::FileStreamWriter>();
335 337
336 switch (url.type()) { 338 switch (url.type()) {
337 case fileapi::kFileSystemTypeDrive: 339 case storage::kFileSystemTypeDrive:
338 return drive_delegate_->CreateFileStreamWriter(url, offset, context); 340 return drive_delegate_->CreateFileStreamWriter(url, offset, context);
339 case fileapi::kFileSystemTypeProvided: 341 case storage::kFileSystemTypeProvided:
340 return file_system_provider_delegate_->CreateFileStreamWriter( 342 return file_system_provider_delegate_->CreateFileStreamWriter(
341 url, offset, context); 343 url, offset, context);
342 case fileapi::kFileSystemTypeNativeLocal: 344 case storage::kFileSystemTypeNativeLocal:
343 return scoped_ptr<fileapi::FileStreamWriter>( 345 return scoped_ptr<storage::FileStreamWriter>(
344 fileapi::FileStreamWriter::CreateForLocalFile( 346 storage::FileStreamWriter::CreateForLocalFile(
345 context->default_file_task_runner(), url.path(), offset, 347 context->default_file_task_runner(),
346 fileapi::FileStreamWriter::OPEN_EXISTING_FILE)); 348 url.path(),
347 case fileapi::kFileSystemTypeRestrictedNativeLocal: 349 offset,
350 storage::FileStreamWriter::OPEN_EXISTING_FILE));
351 case storage::kFileSystemTypeRestrictedNativeLocal:
348 // Restricted native local file system is read only. 352 // Restricted native local file system is read only.
349 return scoped_ptr<fileapi::FileStreamWriter>(); 353 return scoped_ptr<storage::FileStreamWriter>();
350 case fileapi::kFileSystemTypeDeviceMediaAsFileStorage: 354 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
351 return mtp_delegate_->CreateFileStreamWriter(url, offset, context); 355 return mtp_delegate_->CreateFileStreamWriter(url, offset, context);
352 default: 356 default:
353 NOTREACHED(); 357 NOTREACHED();
354 } 358 }
355 return scoped_ptr<fileapi::FileStreamWriter>(); 359 return scoped_ptr<storage::FileStreamWriter>();
356 } 360 }
357 361
358 bool FileSystemBackend::GetVirtualPath( 362 bool FileSystemBackend::GetVirtualPath(
359 const base::FilePath& filesystem_path, 363 const base::FilePath& filesystem_path,
360 base::FilePath* virtual_path) { 364 base::FilePath* virtual_path) {
361 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || 365 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) ||
362 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); 366 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path);
363 } 367 }
364 368
365 } // namespace chromeos 369 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/fileapi/file_system_backend.h ('k') | chrome/browser/chromeos/fileapi/file_system_backend_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698