| OLD | NEW |
| 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> |
| 8 |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 11 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" | 13 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" |
| 12 #include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h" | 14 #include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h" |
| 13 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" | 15 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
| 14 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 15 #include "chromeos/chromeos_switches.h" | 17 #include "chromeos/chromeos_switches.h" |
| 16 #include "chromeos/dbus/cros_disks_client.h" | 18 #include "chromeos/dbus/cros_disks_client.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 case storage::kFileSystemTypeRestrictedNativeLocal: | 314 case storage::kFileSystemTypeRestrictedNativeLocal: |
| 313 return false; | 315 return false; |
| 314 default: | 316 default: |
| 315 NOTREACHED(); | 317 NOTREACHED(); |
| 316 } | 318 } |
| 317 return true; | 319 return true; |
| 318 } | 320 } |
| 319 | 321 |
| 320 scoped_ptr<storage::FileStreamReader> FileSystemBackend::CreateFileStreamReader( | 322 scoped_ptr<storage::FileStreamReader> FileSystemBackend::CreateFileStreamReader( |
| 321 const storage::FileSystemURL& url, | 323 const storage::FileSystemURL& url, |
| 322 int64 offset, | 324 int64_t offset, |
| 323 int64 max_bytes_to_read, | 325 int64_t max_bytes_to_read, |
| 324 const base::Time& expected_modification_time, | 326 const base::Time& expected_modification_time, |
| 325 storage::FileSystemContext* context) const { | 327 storage::FileSystemContext* context) const { |
| 326 DCHECK(url.is_valid()); | 328 DCHECK(url.is_valid()); |
| 327 | 329 |
| 328 if (!IsAccessAllowed(url)) | 330 if (!IsAccessAllowed(url)) |
| 329 return scoped_ptr<storage::FileStreamReader>(); | 331 return scoped_ptr<storage::FileStreamReader>(); |
| 330 | 332 |
| 331 switch (url.type()) { | 333 switch (url.type()) { |
| 332 case storage::kFileSystemTypeDrive: | 334 case storage::kFileSystemTypeDrive: |
| 333 return drive_delegate_->CreateFileStreamReader( | 335 return drive_delegate_->CreateFileStreamReader( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 344 return mtp_delegate_->CreateFileStreamReader( | 346 return mtp_delegate_->CreateFileStreamReader( |
| 345 url, offset, max_bytes_to_read, expected_modification_time, context); | 347 url, offset, max_bytes_to_read, expected_modification_time, context); |
| 346 default: | 348 default: |
| 347 NOTREACHED(); | 349 NOTREACHED(); |
| 348 } | 350 } |
| 349 return scoped_ptr<storage::FileStreamReader>(); | 351 return scoped_ptr<storage::FileStreamReader>(); |
| 350 } | 352 } |
| 351 | 353 |
| 352 scoped_ptr<storage::FileStreamWriter> FileSystemBackend::CreateFileStreamWriter( | 354 scoped_ptr<storage::FileStreamWriter> FileSystemBackend::CreateFileStreamWriter( |
| 353 const storage::FileSystemURL& url, | 355 const storage::FileSystemURL& url, |
| 354 int64 offset, | 356 int64_t offset, |
| 355 storage::FileSystemContext* context) const { | 357 storage::FileSystemContext* context) const { |
| 356 DCHECK(url.is_valid()); | 358 DCHECK(url.is_valid()); |
| 357 | 359 |
| 358 if (!IsAccessAllowed(url)) | 360 if (!IsAccessAllowed(url)) |
| 359 return scoped_ptr<storage::FileStreamWriter>(); | 361 return scoped_ptr<storage::FileStreamWriter>(); |
| 360 | 362 |
| 361 switch (url.type()) { | 363 switch (url.type()) { |
| 362 case storage::kFileSystemTypeDrive: | 364 case storage::kFileSystemTypeDrive: |
| 363 return drive_delegate_->CreateFileStreamWriter(url, offset, context); | 365 return drive_delegate_->CreateFileStreamWriter(url, offset, context); |
| 364 case storage::kFileSystemTypeProvided: | 366 case storage::kFileSystemTypeProvided: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 const base::FilePath& entry_path) const { | 424 const base::FilePath& entry_path) const { |
| 423 base::FilePath virtual_path; | 425 base::FilePath virtual_path; |
| 424 if (!GetVirtualPath(entry_path, &virtual_path)) | 426 if (!GetVirtualPath(entry_path, &virtual_path)) |
| 425 return storage::FileSystemURL(); | 427 return storage::FileSystemURL(); |
| 426 | 428 |
| 427 return context->CreateCrackedFileSystemURL( | 429 return context->CreateCrackedFileSystemURL( |
| 428 GURL() /* origin */, storage::kFileSystemTypeExternal, virtual_path); | 430 GURL() /* origin */, storage::kFileSystemTypeExternal, virtual_path); |
| 429 } | 431 } |
| 430 | 432 |
| 431 } // namespace chromeos | 433 } // namespace chromeos |
| OLD | NEW |