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

Side by Side Diff: chrome/browser/chromeos/fileapi/file_system_backend.cc

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build 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 "webkit/browser/blob/file_stream_reader.h"
15 #include "webkit/browser/fileapi/async_file_util.h" 15 #include "webkit/browser/fileapi/async_file_util.h"
16 #include "webkit/browser/fileapi/external_mount_points.h" 16 #include "webkit/browser/fileapi/external_mount_points.h"
17 #include "webkit/browser/fileapi/file_stream_writer.h" 17 #include "webkit/browser/fileapi/file_stream_writer.h"
18 #include "webkit/browser/fileapi/file_system_context.h" 18 #include "webkit/browser/fileapi/file_system_context.h"
19 #include "webkit/browser/fileapi/file_system_operation.h" 19 #include "webkit/browser/fileapi/file_system_operation.h"
20 #include "webkit/browser/fileapi/file_system_operation_context.h" 20 #include "webkit/browser/fileapi/file_system_operation_context.h"
21 #include "webkit/browser/fileapi/file_system_url.h" 21 #include "webkit/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<storage::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 bool FileSystemBackend::HasInplaceCopyImplementation( 298 bool FileSystemBackend::HasInplaceCopyImplementation(
295 fileapi::FileSystemType type) const { 299 storage::FileSystemType type) const {
296 switch (type) { 300 switch (type) {
297 case fileapi::kFileSystemTypeDrive: 301 case storage::kFileSystemTypeDrive:
298 case fileapi::kFileSystemTypeProvided: 302 case storage::kFileSystemTypeProvided:
299 case fileapi::kFileSystemTypeDeviceMediaAsFileStorage: 303 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
300 return true; 304 return true;
301 case fileapi::kFileSystemTypeNativeLocal: 305 case storage::kFileSystemTypeNativeLocal:
302 case fileapi::kFileSystemTypeRestrictedNativeLocal: 306 case storage::kFileSystemTypeRestrictedNativeLocal:
303 return false; 307 return false;
304 default: 308 default:
305 NOTREACHED(); 309 NOTREACHED();
306 } 310 }
307 return true; 311 return true;
308 } 312 }
309 313
310 scoped_ptr<webkit_blob::FileStreamReader> 314 scoped_ptr<storage::FileStreamReader> FileSystemBackend::CreateFileStreamReader(
311 FileSystemBackend::CreateFileStreamReader( 315 const storage::FileSystemURL& url,
312 const fileapi::FileSystemURL& url,
313 int64 offset, 316 int64 offset,
314 const base::Time& expected_modification_time, 317 const base::Time& expected_modification_time,
315 fileapi::FileSystemContext* context) const { 318 storage::FileSystemContext* context) const {
316 DCHECK(url.is_valid()); 319 DCHECK(url.is_valid());
317 320
318 if (!IsAccessAllowed(url)) 321 if (!IsAccessAllowed(url))
319 return scoped_ptr<webkit_blob::FileStreamReader>(); 322 return scoped_ptr<storage::FileStreamReader>();
320 323
321 switch (url.type()) { 324 switch (url.type()) {
322 case fileapi::kFileSystemTypeDrive: 325 case storage::kFileSystemTypeDrive:
323 return drive_delegate_->CreateFileStreamReader( 326 return drive_delegate_->CreateFileStreamReader(
324 url, offset, expected_modification_time, context); 327 url, offset, expected_modification_time, context);
325 case fileapi::kFileSystemTypeProvided: 328 case storage::kFileSystemTypeProvided:
326 return file_system_provider_delegate_->CreateFileStreamReader( 329 return file_system_provider_delegate_->CreateFileStreamReader(
327 url, offset, expected_modification_time, context); 330 url, offset, expected_modification_time, context);
328 case fileapi::kFileSystemTypeNativeLocal: 331 case storage::kFileSystemTypeNativeLocal:
329 case fileapi::kFileSystemTypeRestrictedNativeLocal: 332 case storage::kFileSystemTypeRestrictedNativeLocal:
330 return scoped_ptr<webkit_blob::FileStreamReader>( 333 return scoped_ptr<storage::FileStreamReader>(
331 webkit_blob::FileStreamReader::CreateForFileSystemFile( 334 storage::FileStreamReader::CreateForFileSystemFile(
332 context, url, offset, expected_modification_time)); 335 context, url, offset, expected_modification_time));
333 case fileapi::kFileSystemTypeDeviceMediaAsFileStorage: 336 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
334 return mtp_delegate_->CreateFileStreamReader( 337 return mtp_delegate_->CreateFileStreamReader(
335 url, offset, expected_modification_time, context); 338 url, offset, expected_modification_time, context);
336 default: 339 default:
337 NOTREACHED(); 340 NOTREACHED();
338 } 341 }
339 return scoped_ptr<webkit_blob::FileStreamReader>(); 342 return scoped_ptr<storage::FileStreamReader>();
340 } 343 }
341 344
342 scoped_ptr<fileapi::FileStreamWriter> 345 scoped_ptr<storage::FileStreamWriter> FileSystemBackend::CreateFileStreamWriter(
343 FileSystemBackend::CreateFileStreamWriter( 346 const storage::FileSystemURL& url,
344 const fileapi::FileSystemURL& url,
345 int64 offset, 347 int64 offset,
346 fileapi::FileSystemContext* context) const { 348 storage::FileSystemContext* context) const {
347 DCHECK(url.is_valid()); 349 DCHECK(url.is_valid());
348 350
349 if (!IsAccessAllowed(url)) 351 if (!IsAccessAllowed(url))
350 return scoped_ptr<fileapi::FileStreamWriter>(); 352 return scoped_ptr<storage::FileStreamWriter>();
351 353
352 switch (url.type()) { 354 switch (url.type()) {
353 case fileapi::kFileSystemTypeDrive: 355 case storage::kFileSystemTypeDrive:
354 return drive_delegate_->CreateFileStreamWriter(url, offset, context); 356 return drive_delegate_->CreateFileStreamWriter(url, offset, context);
355 case fileapi::kFileSystemTypeProvided: 357 case storage::kFileSystemTypeProvided:
356 return file_system_provider_delegate_->CreateFileStreamWriter( 358 return file_system_provider_delegate_->CreateFileStreamWriter(
357 url, offset, context); 359 url, offset, context);
358 case fileapi::kFileSystemTypeNativeLocal: 360 case storage::kFileSystemTypeNativeLocal:
359 return scoped_ptr<fileapi::FileStreamWriter>( 361 return scoped_ptr<storage::FileStreamWriter>(
360 fileapi::FileStreamWriter::CreateForLocalFile( 362 storage::FileStreamWriter::CreateForLocalFile(
361 context->default_file_task_runner(), url.path(), offset, 363 context->default_file_task_runner(),
362 fileapi::FileStreamWriter::OPEN_EXISTING_FILE)); 364 url.path(),
363 case fileapi::kFileSystemTypeRestrictedNativeLocal: 365 offset,
366 storage::FileStreamWriter::OPEN_EXISTING_FILE));
367 case storage::kFileSystemTypeRestrictedNativeLocal:
364 // Restricted native local file system is read only. 368 // Restricted native local file system is read only.
365 return scoped_ptr<fileapi::FileStreamWriter>(); 369 return scoped_ptr<storage::FileStreamWriter>();
366 case fileapi::kFileSystemTypeDeviceMediaAsFileStorage: 370 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
367 return mtp_delegate_->CreateFileStreamWriter(url, offset, context); 371 return mtp_delegate_->CreateFileStreamWriter(url, offset, context);
368 default: 372 default:
369 NOTREACHED(); 373 NOTREACHED();
370 } 374 }
371 return scoped_ptr<fileapi::FileStreamWriter>(); 375 return scoped_ptr<storage::FileStreamWriter>();
372 } 376 }
373 377
374 bool FileSystemBackend::GetVirtualPath( 378 bool FileSystemBackend::GetVirtualPath(
375 const base::FilePath& filesystem_path, 379 const base::FilePath& filesystem_path,
376 base::FilePath* virtual_path) { 380 base::FilePath* virtual_path) {
377 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || 381 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) ||
378 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); 382 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path);
379 } 383 }
380 384
381 } // namespace chromeos 385 } // 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