| 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 "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" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 return false; | 312 return false; |
| 313 default: | 313 default: |
| 314 NOTREACHED(); | 314 NOTREACHED(); |
| 315 } | 315 } |
| 316 return true; | 316 return true; |
| 317 } | 317 } |
| 318 | 318 |
| 319 scoped_ptr<storage::FileStreamReader> FileSystemBackend::CreateFileStreamReader( | 319 scoped_ptr<storage::FileStreamReader> FileSystemBackend::CreateFileStreamReader( |
| 320 const storage::FileSystemURL& url, | 320 const storage::FileSystemURL& url, |
| 321 int64 offset, | 321 int64 offset, |
| 322 int64 max_bytes_to_read, |
| 322 const base::Time& expected_modification_time, | 323 const base::Time& expected_modification_time, |
| 323 storage::FileSystemContext* context) const { | 324 storage::FileSystemContext* context) const { |
| 324 DCHECK(url.is_valid()); | 325 DCHECK(url.is_valid()); |
| 325 | 326 |
| 326 if (!IsAccessAllowed(url)) | 327 if (!IsAccessAllowed(url)) |
| 327 return scoped_ptr<storage::FileStreamReader>(); | 328 return scoped_ptr<storage::FileStreamReader>(); |
| 328 | 329 |
| 329 switch (url.type()) { | 330 switch (url.type()) { |
| 330 case storage::kFileSystemTypeDrive: | 331 case storage::kFileSystemTypeDrive: |
| 331 return drive_delegate_->CreateFileStreamReader( | 332 return drive_delegate_->CreateFileStreamReader( |
| 332 url, offset, expected_modification_time, context); | 333 url, offset, max_bytes_to_read, expected_modification_time, context); |
| 333 case storage::kFileSystemTypeProvided: | 334 case storage::kFileSystemTypeProvided: |
| 334 return file_system_provider_delegate_->CreateFileStreamReader( | 335 return file_system_provider_delegate_->CreateFileStreamReader( |
| 335 url, offset, expected_modification_time, context); | 336 url, offset, max_bytes_to_read, expected_modification_time, context); |
| 336 case storage::kFileSystemTypeNativeLocal: | 337 case storage::kFileSystemTypeNativeLocal: |
| 337 case storage::kFileSystemTypeRestrictedNativeLocal: | 338 case storage::kFileSystemTypeRestrictedNativeLocal: |
| 338 return scoped_ptr<storage::FileStreamReader>( | 339 return scoped_ptr<storage::FileStreamReader>( |
| 339 storage::FileStreamReader::CreateForFileSystemFile( | 340 storage::FileStreamReader::CreateForFileSystemFile( |
| 340 context, url, offset, expected_modification_time)); | 341 context, url, offset, expected_modification_time)); |
| 341 case storage::kFileSystemTypeDeviceMediaAsFileStorage: | 342 case storage::kFileSystemTypeDeviceMediaAsFileStorage: |
| 342 return mtp_delegate_->CreateFileStreamReader( | 343 return mtp_delegate_->CreateFileStreamReader( |
| 343 url, offset, expected_modification_time, context); | 344 url, offset, max_bytes_to_read, expected_modification_time, context); |
| 344 default: | 345 default: |
| 345 NOTREACHED(); | 346 NOTREACHED(); |
| 346 } | 347 } |
| 347 return scoped_ptr<storage::FileStreamReader>(); | 348 return scoped_ptr<storage::FileStreamReader>(); |
| 348 } | 349 } |
| 349 | 350 |
| 350 scoped_ptr<storage::FileStreamWriter> FileSystemBackend::CreateFileStreamWriter( | 351 scoped_ptr<storage::FileStreamWriter> FileSystemBackend::CreateFileStreamWriter( |
| 351 const storage::FileSystemURL& url, | 352 const storage::FileSystemURL& url, |
| 352 int64 offset, | 353 int64 offset, |
| 353 storage::FileSystemContext* context) const { | 354 storage::FileSystemContext* context) const { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 381 } | 382 } |
| 382 | 383 |
| 383 bool FileSystemBackend::GetVirtualPath( | 384 bool FileSystemBackend::GetVirtualPath( |
| 384 const base::FilePath& filesystem_path, | 385 const base::FilePath& filesystem_path, |
| 385 base::FilePath* virtual_path) { | 386 base::FilePath* virtual_path) { |
| 386 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || | 387 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || |
| 387 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); | 388 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); |
| 388 } | 389 } |
| 389 | 390 |
| 390 } // namespace chromeos | 391 } // namespace chromeos |
| OLD | NEW |