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

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

Issue 2568033002: mediaview: Skeleton for ARC Documents Provider FS. (Closed)
Patch Set: IWYU and comments. Created 4 years 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 // static 43 // static
44 bool FileSystemBackend::CanHandleURL(const storage::FileSystemURL& url) { 44 bool FileSystemBackend::CanHandleURL(const storage::FileSystemURL& url) {
45 if (!url.is_valid()) 45 if (!url.is_valid())
46 return false; 46 return false;
47 return url.type() == storage::kFileSystemTypeNativeLocal || 47 return url.type() == storage::kFileSystemTypeNativeLocal ||
48 url.type() == storage::kFileSystemTypeRestrictedNativeLocal || 48 url.type() == storage::kFileSystemTypeRestrictedNativeLocal ||
49 url.type() == storage::kFileSystemTypeDrive || 49 url.type() == storage::kFileSystemTypeDrive ||
50 url.type() == storage::kFileSystemTypeProvided || 50 url.type() == storage::kFileSystemTypeProvided ||
51 url.type() == storage::kFileSystemTypeDeviceMediaAsFileStorage || 51 url.type() == storage::kFileSystemTypeDeviceMediaAsFileStorage ||
52 url.type() == storage::kFileSystemTypeArcContent; 52 url.type() == storage::kFileSystemTypeArcContent ||
53 url.type() == storage::kFileSystemTypeArcDocumentsProvider;
53 } 54 }
54 55
55 FileSystemBackend::FileSystemBackend( 56 FileSystemBackend::FileSystemBackend(
56 std::unique_ptr<FileSystemBackendDelegate> drive_delegate, 57 std::unique_ptr<FileSystemBackendDelegate> drive_delegate,
57 std::unique_ptr<FileSystemBackendDelegate> file_system_provider_delegate, 58 std::unique_ptr<FileSystemBackendDelegate> file_system_provider_delegate,
58 std::unique_ptr<FileSystemBackendDelegate> mtp_delegate, 59 std::unique_ptr<FileSystemBackendDelegate> mtp_delegate,
59 std::unique_ptr<FileSystemBackendDelegate> arc_content_delegate, 60 std::unique_ptr<FileSystemBackendDelegate> arc_content_delegate,
61 std::unique_ptr<FileSystemBackendDelegate> arc_documents_provider_delegate,
60 scoped_refptr<storage::ExternalMountPoints> mount_points, 62 scoped_refptr<storage::ExternalMountPoints> mount_points,
61 storage::ExternalMountPoints* system_mount_points) 63 storage::ExternalMountPoints* system_mount_points)
62 : file_access_permissions_(new FileAccessPermissions()), 64 : file_access_permissions_(new FileAccessPermissions()),
63 local_file_util_(storage::AsyncFileUtil::CreateForLocalFileSystem()), 65 local_file_util_(storage::AsyncFileUtil::CreateForLocalFileSystem()),
64 drive_delegate_(std::move(drive_delegate)), 66 drive_delegate_(std::move(drive_delegate)),
65 file_system_provider_delegate_(std::move(file_system_provider_delegate)), 67 file_system_provider_delegate_(std::move(file_system_provider_delegate)),
66 mtp_delegate_(std::move(mtp_delegate)), 68 mtp_delegate_(std::move(mtp_delegate)),
67 arc_content_delegate_(std::move(arc_content_delegate)), 69 arc_content_delegate_(std::move(arc_content_delegate)),
70 arc_documents_provider_delegate_(
71 std::move(arc_documents_provider_delegate)),
68 mount_points_(mount_points), 72 mount_points_(mount_points),
69 system_mount_points_(system_mount_points) {} 73 system_mount_points_(system_mount_points) {}
70 74
71 FileSystemBackend::~FileSystemBackend() { 75 FileSystemBackend::~FileSystemBackend() {
72 } 76 }
73 77
74 void FileSystemBackend::AddSystemMountPoints() { 78 void FileSystemBackend::AddSystemMountPoints() {
75 // RegisterFileSystem() is no-op if the mount point with the same name 79 // RegisterFileSystem() is no-op if the mount point with the same name
76 // already exists, hence it's safe to call without checking if a mount 80 // already exists, hence it's safe to call without checking if a mount
77 // point already exists or not. 81 // point already exists or not.
(...skipping 16 matching lines...) Expand all
94 bool FileSystemBackend::CanHandleType(storage::FileSystemType type) const { 98 bool FileSystemBackend::CanHandleType(storage::FileSystemType type) const {
95 switch (type) { 99 switch (type) {
96 case storage::kFileSystemTypeExternal: 100 case storage::kFileSystemTypeExternal:
97 case storage::kFileSystemTypeDrive: 101 case storage::kFileSystemTypeDrive:
98 case storage::kFileSystemTypeRestrictedNativeLocal: 102 case storage::kFileSystemTypeRestrictedNativeLocal:
99 case storage::kFileSystemTypeNativeLocal: 103 case storage::kFileSystemTypeNativeLocal:
100 case storage::kFileSystemTypeNativeForPlatformApp: 104 case storage::kFileSystemTypeNativeForPlatformApp:
101 case storage::kFileSystemTypeDeviceMediaAsFileStorage: 105 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
102 case storage::kFileSystemTypeProvided: 106 case storage::kFileSystemTypeProvided:
103 case storage::kFileSystemTypeArcContent: 107 case storage::kFileSystemTypeArcContent:
108 case storage::kFileSystemTypeArcDocumentsProvider:
104 return true; 109 return true;
105 default: 110 default:
106 return false; 111 return false;
107 } 112 }
108 } 113 }
109 114
110 void FileSystemBackend::Initialize(storage::FileSystemContext* context) { 115 void FileSystemBackend::Initialize(storage::FileSystemContext* context) {
111 } 116 }
112 117
113 void FileSystemBackend::ResolveURL(const storage::FileSystemURL& url, 118 void FileSystemBackend::ResolveURL(const storage::FileSystemURL& url,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 return drive_delegate_->GetAsyncFileUtil(type); 251 return drive_delegate_->GetAsyncFileUtil(type);
247 case storage::kFileSystemTypeProvided: 252 case storage::kFileSystemTypeProvided:
248 return file_system_provider_delegate_->GetAsyncFileUtil(type); 253 return file_system_provider_delegate_->GetAsyncFileUtil(type);
249 case storage::kFileSystemTypeNativeLocal: 254 case storage::kFileSystemTypeNativeLocal:
250 case storage::kFileSystemTypeRestrictedNativeLocal: 255 case storage::kFileSystemTypeRestrictedNativeLocal:
251 return local_file_util_.get(); 256 return local_file_util_.get();
252 case storage::kFileSystemTypeDeviceMediaAsFileStorage: 257 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
253 return mtp_delegate_->GetAsyncFileUtil(type); 258 return mtp_delegate_->GetAsyncFileUtil(type);
254 case storage::kFileSystemTypeArcContent: 259 case storage::kFileSystemTypeArcContent:
255 return arc_content_delegate_->GetAsyncFileUtil(type); 260 return arc_content_delegate_->GetAsyncFileUtil(type);
261 case storage::kFileSystemTypeArcDocumentsProvider:
262 return arc_documents_provider_delegate_->GetAsyncFileUtil(type);
256 default: 263 default:
257 NOTREACHED(); 264 NOTREACHED();
258 } 265 }
259 return NULL; 266 return NULL;
260 } 267 }
261 268
262 storage::WatcherManager* FileSystemBackend::GetWatcherManager( 269 storage::WatcherManager* FileSystemBackend::GetWatcherManager(
263 storage::FileSystemType type) { 270 storage::FileSystemType type) {
264 if (type == storage::kFileSystemTypeProvided) 271 if (type == storage::kFileSystemTypeProvided)
265 return file_system_provider_delegate_->GetWatcherManager(type); 272 return file_system_provider_delegate_->GetWatcherManager(type);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 return storage::FileSystemOperation::Create( 306 return storage::FileSystemOperation::Create(
300 url, context, 307 url, context,
301 base::MakeUnique<storage::FileSystemOperationContext>( 308 base::MakeUnique<storage::FileSystemOperationContext>(
302 context, MediaFileSystemBackend::MediaTaskRunner().get())); 309 context, MediaFileSystemBackend::MediaTaskRunner().get()));
303 } 310 }
304 311
305 DCHECK(url.type() == storage::kFileSystemTypeNativeLocal || 312 DCHECK(url.type() == storage::kFileSystemTypeNativeLocal ||
306 url.type() == storage::kFileSystemTypeRestrictedNativeLocal || 313 url.type() == storage::kFileSystemTypeRestrictedNativeLocal ||
307 url.type() == storage::kFileSystemTypeDrive || 314 url.type() == storage::kFileSystemTypeDrive ||
308 url.type() == storage::kFileSystemTypeProvided || 315 url.type() == storage::kFileSystemTypeProvided ||
309 url.type() == storage::kFileSystemTypeArcContent); 316 url.type() == storage::kFileSystemTypeArcContent ||
317 url.type() == storage::kFileSystemTypeArcDocumentsProvider);
310 return storage::FileSystemOperation::Create( 318 return storage::FileSystemOperation::Create(
311 url, context, 319 url, context,
312 base::MakeUnique<storage::FileSystemOperationContext>(context)); 320 base::MakeUnique<storage::FileSystemOperationContext>(context));
313 } 321 }
314 322
315 bool FileSystemBackend::SupportsStreaming( 323 bool FileSystemBackend::SupportsStreaming(
316 const storage::FileSystemURL& url) const { 324 const storage::FileSystemURL& url) const {
317 return url.type() == storage::kFileSystemTypeDrive || 325 return url.type() == storage::kFileSystemTypeDrive ||
318 url.type() == storage::kFileSystemTypeProvided || 326 url.type() == storage::kFileSystemTypeProvided ||
319 url.type() == storage::kFileSystemTypeDeviceMediaAsFileStorage || 327 url.type() == storage::kFileSystemTypeDeviceMediaAsFileStorage ||
320 url.type() == storage::kFileSystemTypeArcContent; 328 url.type() == storage::kFileSystemTypeArcContent ||
329 url.type() == storage::kFileSystemTypeArcDocumentsProvider;
321 } 330 }
322 331
323 bool FileSystemBackend::HasInplaceCopyImplementation( 332 bool FileSystemBackend::HasInplaceCopyImplementation(
324 storage::FileSystemType type) const { 333 storage::FileSystemType type) const {
325 switch (type) { 334 switch (type) {
326 case storage::kFileSystemTypeDrive: 335 case storage::kFileSystemTypeDrive:
327 case storage::kFileSystemTypeProvided: 336 case storage::kFileSystemTypeProvided:
328 case storage::kFileSystemTypeDeviceMediaAsFileStorage: 337 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
329 return true; 338 return true;
330 case storage::kFileSystemTypeNativeLocal: 339 case storage::kFileSystemTypeNativeLocal:
331 case storage::kFileSystemTypeRestrictedNativeLocal: 340 case storage::kFileSystemTypeRestrictedNativeLocal:
332 case storage::kFileSystemTypeArcContent: 341 case storage::kFileSystemTypeArcContent:
342 case storage::kFileSystemTypeArcDocumentsProvider:
333 return false; 343 return false;
334 default: 344 default:
335 NOTREACHED(); 345 NOTREACHED();
336 } 346 }
337 return true; 347 return true;
338 } 348 }
339 349
340 std::unique_ptr<storage::FileStreamReader> 350 std::unique_ptr<storage::FileStreamReader>
341 FileSystemBackend::CreateFileStreamReader( 351 FileSystemBackend::CreateFileStreamReader(
342 const storage::FileSystemURL& url, 352 const storage::FileSystemURL& url,
(...skipping 17 matching lines...) Expand all
360 case storage::kFileSystemTypeRestrictedNativeLocal: 370 case storage::kFileSystemTypeRestrictedNativeLocal:
361 return std::unique_ptr<storage::FileStreamReader>( 371 return std::unique_ptr<storage::FileStreamReader>(
362 storage::FileStreamReader::CreateForFileSystemFile( 372 storage::FileStreamReader::CreateForFileSystemFile(
363 context, url, offset, expected_modification_time)); 373 context, url, offset, expected_modification_time));
364 case storage::kFileSystemTypeDeviceMediaAsFileStorage: 374 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
365 return mtp_delegate_->CreateFileStreamReader( 375 return mtp_delegate_->CreateFileStreamReader(
366 url, offset, max_bytes_to_read, expected_modification_time, context); 376 url, offset, max_bytes_to_read, expected_modification_time, context);
367 case storage::kFileSystemTypeArcContent: 377 case storage::kFileSystemTypeArcContent:
368 return arc_content_delegate_->CreateFileStreamReader( 378 return arc_content_delegate_->CreateFileStreamReader(
369 url, offset, max_bytes_to_read, expected_modification_time, context); 379 url, offset, max_bytes_to_read, expected_modification_time, context);
380 case storage::kFileSystemTypeArcDocumentsProvider:
381 return arc_documents_provider_delegate_->CreateFileStreamReader(
382 url, offset, max_bytes_to_read, expected_modification_time, context);
370 default: 383 default:
371 NOTREACHED(); 384 NOTREACHED();
372 } 385 }
373 return std::unique_ptr<storage::FileStreamReader>(); 386 return std::unique_ptr<storage::FileStreamReader>();
374 } 387 }
375 388
376 std::unique_ptr<storage::FileStreamWriter> 389 std::unique_ptr<storage::FileStreamWriter>
377 FileSystemBackend::CreateFileStreamWriter( 390 FileSystemBackend::CreateFileStreamWriter(
378 const storage::FileSystemURL& url, 391 const storage::FileSystemURL& url,
379 int64_t offset, 392 int64_t offset,
(...skipping 12 matching lines...) Expand all
392 case storage::kFileSystemTypeNativeLocal: 405 case storage::kFileSystemTypeNativeLocal:
393 return std::unique_ptr<storage::FileStreamWriter>( 406 return std::unique_ptr<storage::FileStreamWriter>(
394 storage::FileStreamWriter::CreateForLocalFile( 407 storage::FileStreamWriter::CreateForLocalFile(
395 context->default_file_task_runner(), url.path(), offset, 408 context->default_file_task_runner(), url.path(), offset,
396 storage::FileStreamWriter::OPEN_EXISTING_FILE)); 409 storage::FileStreamWriter::OPEN_EXISTING_FILE));
397 case storage::kFileSystemTypeDeviceMediaAsFileStorage: 410 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
398 return mtp_delegate_->CreateFileStreamWriter(url, offset, context); 411 return mtp_delegate_->CreateFileStreamWriter(url, offset, context);
399 // Read only file systems. 412 // Read only file systems.
400 case storage::kFileSystemTypeRestrictedNativeLocal: 413 case storage::kFileSystemTypeRestrictedNativeLocal:
401 case storage::kFileSystemTypeArcContent: 414 case storage::kFileSystemTypeArcContent:
415 case storage::kFileSystemTypeArcDocumentsProvider:
402 return std::unique_ptr<storage::FileStreamWriter>(); 416 return std::unique_ptr<storage::FileStreamWriter>();
403 default: 417 default:
404 NOTREACHED(); 418 NOTREACHED();
405 } 419 }
406 return std::unique_ptr<storage::FileStreamWriter>(); 420 return std::unique_ptr<storage::FileStreamWriter>();
407 } 421 }
408 422
409 bool FileSystemBackend::GetVirtualPath(const base::FilePath& filesystem_path, 423 bool FileSystemBackend::GetVirtualPath(const base::FilePath& filesystem_path,
410 base::FilePath* virtual_path) const { 424 base::FilePath* virtual_path) const {
411 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || 425 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) ||
(...skipping 15 matching lines...) Expand all
427 case storage::kFileSystemTypeProvided: 441 case storage::kFileSystemTypeProvided:
428 file_system_provider_delegate_->GetRedirectURLForContents(url, 442 file_system_provider_delegate_->GetRedirectURLForContents(url,
429 callback); 443 callback);
430 return; 444 return;
431 case storage::kFileSystemTypeDeviceMediaAsFileStorage: 445 case storage::kFileSystemTypeDeviceMediaAsFileStorage:
432 mtp_delegate_->GetRedirectURLForContents(url, callback); 446 mtp_delegate_->GetRedirectURLForContents(url, callback);
433 return; 447 return;
434 case storage::kFileSystemTypeNativeLocal: 448 case storage::kFileSystemTypeNativeLocal:
435 case storage::kFileSystemTypeRestrictedNativeLocal: 449 case storage::kFileSystemTypeRestrictedNativeLocal:
436 case storage::kFileSystemTypeArcContent: 450 case storage::kFileSystemTypeArcContent:
451 case storage::kFileSystemTypeArcDocumentsProvider:
437 callback.Run(GURL()); 452 callback.Run(GURL());
438 return; 453 return;
439 default: 454 default:
440 NOTREACHED(); 455 NOTREACHED();
441 } 456 }
442 callback.Run(GURL()); 457 callback.Run(GURL());
443 } 458 }
444 459
445 storage::FileSystemURL FileSystemBackend::CreateInternalURL( 460 storage::FileSystemURL FileSystemBackend::CreateInternalURL(
446 storage::FileSystemContext* context, 461 storage::FileSystemContext* context,
447 const base::FilePath& entry_path) const { 462 const base::FilePath& entry_path) const {
448 base::FilePath virtual_path; 463 base::FilePath virtual_path;
449 if (!GetVirtualPath(entry_path, &virtual_path)) 464 if (!GetVirtualPath(entry_path, &virtual_path))
450 return storage::FileSystemURL(); 465 return storage::FileSystemURL();
451 466
452 return context->CreateCrackedFileSystemURL( 467 return context->CreateCrackedFileSystemURL(
453 GURL() /* origin */, storage::kFileSystemTypeExternal, virtual_path); 468 GURL() /* origin */, storage::kFileSystemTypeExternal, virtual_path);
454 } 469 }
455 470
456 } // namespace chromeos 471 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/fileapi/file_system_backend.h ('k') | chrome/browser/chromeos/fileapi/file_system_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698