Chromium Code Reviews| Index: chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.cc |
| diff --git a/chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.cc b/chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4feebf8a4b2857443ab139a5352b01e8c53191d5 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.cc |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.h" |
| +#include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h" |
| +#include "webkit/browser/blob/file_stream_reader.h" |
| +#include "webkit/browser/fileapi/file_stream_writer.h" |
| + |
| +namespace chromeos { |
| + |
| +MTPFileSystemBackendDelegate::MTPFileSystemBackendDelegate( |
| + const base::FilePath& storage_partition_path) |
| + : device_media_async_file_util_( |
| + DeviceMediaAsyncFileUtil::Create(storage_partition_path)) { |
| +} |
| + |
| +MTPFileSystemBackendDelegate::~MTPFileSystemBackendDelegate() { |
| +} |
| + |
| +fileapi::AsyncFileUtil* MTPFileSystemBackendDelegate::GetAsyncFileUtil( |
| + fileapi::FileSystemType type) { |
| + return device_media_async_file_util_.get(); |
|
mtomasz
2014/04/24 01:41:42
nit: How about a DCHECK for a type as in https://c
kinaba
2014/04/24 01:52:34
Done.
|
| +} |
| + |
| +scoped_ptr<webkit_blob::FileStreamReader> |
| +MTPFileSystemBackendDelegate::CreateFileStreamReader( |
| + const fileapi::FileSystemURL& url, |
| + int64 offset, |
| + const base::Time& expected_modification_time, |
| + fileapi::FileSystemContext* context) { |
| + // TODO(kinaba): Returned MediaFileStreamReader verifies file header and |
| + // stops reading if the stream does not represent a media file. We might |
| + // want to remove the verification here since we want to mount MTP devices |
| + // as normal file storage in Chrome OS file manager. |
| + return device_media_async_file_util_->GetFileStreamReader( |
| + url, offset, expected_modification_time, context); |
| +} |
| + |
| +scoped_ptr<fileapi::FileStreamWriter> |
| +MTPFileSystemBackendDelegate::CreateFileStreamWriter( |
| + const fileapi::FileSystemURL& url, |
| + int64 offset, |
| + fileapi::FileSystemContext* context) { |
| + // TODO(kinaba): support writing. |
| + return scoped_ptr<fileapi::FileStreamWriter>(); |
| +} |
| + |
| +} // namespace chromeos |