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.
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/fileapi/file_stream_reader.h"
8 #include "storage/browser/fileapi/file_stream_writer.h"
9 #include "storage/browser/fileapi/file_system_url.h"
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
)) {
20 MTPFileSystemBackendDelegate::~MTPFileSystemBackendDelegate() {
23 storage::AsyncFileUtil
* MTPFileSystemBackendDelegate::GetAsyncFileUtil(
24 storage::FileSystemType type
) {
25 DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage
, type
);
27 return device_media_async_file_util_
.get();
30 scoped_ptr
<storage::FileStreamReader
>
31 MTPFileSystemBackendDelegate::CreateFileStreamReader(
32 const storage::FileSystemURL
& url
,
34 int64 max_bytes_to_read
,
35 const base::Time
& expected_modification_time
,
36 storage::FileSystemContext
* context
) {
37 DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage
, url
.type());
39 return device_media_async_file_util_
->GetFileStreamReader(
40 url
, offset
, expected_modification_time
, context
);
43 scoped_ptr
<storage::FileStreamWriter
>
44 MTPFileSystemBackendDelegate::CreateFileStreamWriter(
45 const storage::FileSystemURL
& url
,
47 storage::FileSystemContext
* context
) {
48 DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage
, url
.type());
50 // TODO(kinaba): support writing.
51 return scoped_ptr
<storage::FileStreamWriter
>();
54 storage::WatcherManager
* MTPFileSystemBackendDelegate::GetWatcherManager(
55 storage::FileSystemType type
) {
60 void MTPFileSystemBackendDelegate::GetRedirectURLForContents(
61 const storage::FileSystemURL
& url
,
62 const storage::URLCallback
& callback
) {
63 DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage
, url
.type());
68 } // namespace chromeos