Home | History | Annotate | Download | only in fileapi
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.h"
      6 #include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h"
      7 #include "storage/browser/blob/file_stream_reader.h"
      8 #include "storage/browser/fileapi/file_stream_writer.h"
      9 #include "storage/browser/fileapi/file_system_url.h"
     10 
     11 namespace chromeos {
     12 
     13 MTPFileSystemBackendDelegate::MTPFileSystemBackendDelegate(
     14     const base::FilePath& storage_partition_path)
     15     : device_media_async_file_util_(
     16           DeviceMediaAsyncFileUtil::Create(storage_partition_path,
     17                                            NO_MEDIA_FILE_VALIDATION)) {
     18 }
     19 
     20 MTPFileSystemBackendDelegate::~MTPFileSystemBackendDelegate() {
     21 }
     22 
     23 storage::AsyncFileUtil* MTPFileSystemBackendDelegate::GetAsyncFileUtil(
     24     storage::FileSystemType type) {
     25   DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, type);
     26 
     27   return device_media_async_file_util_.get();
     28 }
     29 
     30 scoped_ptr<storage::FileStreamReader>
     31 MTPFileSystemBackendDelegate::CreateFileStreamReader(
     32     const storage::FileSystemURL& url,
     33     int64 offset,
     34     int64 max_bytes_to_read,
     35     const base::Time& expected_modification_time,
     36     storage::FileSystemContext* context) {
     37   DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, url.type());
     38 
     39   return device_media_async_file_util_->GetFileStreamReader(
     40       url, offset, expected_modification_time, context);
     41 }
     42 
     43 scoped_ptr<storage::FileStreamWriter>
     44 MTPFileSystemBackendDelegate::CreateFileStreamWriter(
     45     const storage::FileSystemURL& url,
     46     int64 offset,
     47     storage::FileSystemContext* context) {
     48   DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, url.type());
     49 
     50   // TODO(kinaba): support writing.
     51   return scoped_ptr<storage::FileStreamWriter>();
     52 }
     53 
     54 storage::WatcherManager* MTPFileSystemBackendDelegate::GetWatcherManager(
     55     const storage::FileSystemURL& url) {
     56   NOTIMPLEMENTED();
     57   return NULL;
     58 }
     59 
     60 void MTPFileSystemBackendDelegate::GetRedirectURLForContents(
     61     const storage::FileSystemURL& url,
     62     const storage::URLCallback& callback) {
     63   DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, url.type());
     64 
     65   callback.Run(GURL());
     66 }
     67 
     68 }  // namespace chromeos
     69