OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/mtp_file_system_backend_delegate.h" | 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" | 6 #include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h" |
7 #include "webkit/browser/blob/file_stream_reader.h" | 7 #include "webkit/browser/blob/file_stream_reader.h" |
8 #include "webkit/browser/fileapi/file_stream_writer.h" | 8 #include "webkit/browser/fileapi/file_stream_writer.h" |
9 #include "webkit/browser/fileapi/file_system_url.h" | 9 #include "webkit/browser/fileapi/file_system_url.h" |
10 | 10 |
11 namespace chromeos { | 11 namespace chromeos { |
12 | 12 |
13 MTPFileSystemBackendDelegate::MTPFileSystemBackendDelegate( | 13 MTPFileSystemBackendDelegate::MTPFileSystemBackendDelegate( |
14 const base::FilePath& storage_partition_path) | 14 const base::FilePath& storage_partition_path) |
15 : device_media_async_file_util_( | 15 : device_media_async_file_util_( |
16 DeviceMediaAsyncFileUtil::Create(storage_partition_path)) { | 16 DeviceMediaAsyncFileUtil::Create(storage_partition_path, |
| 17 NO_MEDIA_FILE_VALIDATION)) { |
17 } | 18 } |
18 | 19 |
19 MTPFileSystemBackendDelegate::~MTPFileSystemBackendDelegate() { | 20 MTPFileSystemBackendDelegate::~MTPFileSystemBackendDelegate() { |
20 } | 21 } |
21 | 22 |
22 fileapi::AsyncFileUtil* MTPFileSystemBackendDelegate::GetAsyncFileUtil( | 23 fileapi::AsyncFileUtil* MTPFileSystemBackendDelegate::GetAsyncFileUtil( |
23 fileapi::FileSystemType type) { | 24 fileapi::FileSystemType type) { |
24 DCHECK_EQ(fileapi::kFileSystemTypeDeviceMediaAsFileStorage, type); | 25 DCHECK_EQ(fileapi::kFileSystemTypeDeviceMediaAsFileStorage, type); |
25 | 26 |
26 return device_media_async_file_util_.get(); | 27 return device_media_async_file_util_.get(); |
27 } | 28 } |
28 | 29 |
29 scoped_ptr<webkit_blob::FileStreamReader> | 30 scoped_ptr<webkit_blob::FileStreamReader> |
30 MTPFileSystemBackendDelegate::CreateFileStreamReader( | 31 MTPFileSystemBackendDelegate::CreateFileStreamReader( |
31 const fileapi::FileSystemURL& url, | 32 const fileapi::FileSystemURL& url, |
32 int64 offset, | 33 int64 offset, |
33 const base::Time& expected_modification_time, | 34 const base::Time& expected_modification_time, |
34 fileapi::FileSystemContext* context) { | 35 fileapi::FileSystemContext* context) { |
35 DCHECK_EQ(fileapi::kFileSystemTypeDeviceMediaAsFileStorage, url.type()); | 36 DCHECK_EQ(fileapi::kFileSystemTypeDeviceMediaAsFileStorage, url.type()); |
36 | 37 |
37 // TODO(kinaba): Returned MediaFileStreamReader verifies file header and | |
38 // stops reading if the stream does not represent a media file. We might | |
39 // want to remove the verification here since we want to mount MTP devices | |
40 // as normal file storage in Chrome OS file manager. | |
41 return device_media_async_file_util_->GetFileStreamReader( | 38 return device_media_async_file_util_->GetFileStreamReader( |
42 url, offset, expected_modification_time, context); | 39 url, offset, expected_modification_time, context); |
43 } | 40 } |
44 | 41 |
45 scoped_ptr<fileapi::FileStreamWriter> | 42 scoped_ptr<fileapi::FileStreamWriter> |
46 MTPFileSystemBackendDelegate::CreateFileStreamWriter( | 43 MTPFileSystemBackendDelegate::CreateFileStreamWriter( |
47 const fileapi::FileSystemURL& url, | 44 const fileapi::FileSystemURL& url, |
48 int64 offset, | 45 int64 offset, |
49 fileapi::FileSystemContext* context) { | 46 fileapi::FileSystemContext* context) { |
50 DCHECK_EQ(fileapi::kFileSystemTypeDeviceMediaAsFileStorage, url.type()); | 47 DCHECK_EQ(fileapi::kFileSystemTypeDeviceMediaAsFileStorage, url.type()); |
51 | 48 |
52 // TODO(kinaba): support writing. | 49 // TODO(kinaba): support writing. |
53 return scoped_ptr<fileapi::FileStreamWriter>(); | 50 return scoped_ptr<fileapi::FileStreamWriter>(); |
54 } | 51 } |
55 | 52 |
56 } // namespace chromeos | 53 } // namespace chromeos |
OLD | NEW |