Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / fileapi / mtp_file_system_backend_delegate.cc
blobe0b88eb790c454fd4e3a9d656611a1d2b08afa1a
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"
11 namespace chromeos {
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 mtp_watcher_manager_(
19 new MTPWatcherManager(device_media_async_file_util_.get())) {
22 MTPFileSystemBackendDelegate::~MTPFileSystemBackendDelegate() {
25 storage::AsyncFileUtil* MTPFileSystemBackendDelegate::GetAsyncFileUtil(
26 storage::FileSystemType type) {
27 DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, type);
29 return device_media_async_file_util_.get();
32 scoped_ptr<storage::FileStreamReader>
33 MTPFileSystemBackendDelegate::CreateFileStreamReader(
34 const storage::FileSystemURL& url,
35 int64 offset,
36 int64 max_bytes_to_read,
37 const base::Time& expected_modification_time,
38 storage::FileSystemContext* context) {
39 DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, url.type());
41 return device_media_async_file_util_->GetFileStreamReader(
42 url, offset, expected_modification_time, context);
45 scoped_ptr<storage::FileStreamWriter>
46 MTPFileSystemBackendDelegate::CreateFileStreamWriter(
47 const storage::FileSystemURL& url,
48 int64 offset,
49 storage::FileSystemContext* context) {
50 DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, url.type());
52 // TODO(kinaba): support writing.
53 return scoped_ptr<storage::FileStreamWriter>();
56 storage::WatcherManager* MTPFileSystemBackendDelegate::GetWatcherManager(
57 storage::FileSystemType type) {
58 DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, type);
59 return mtp_watcher_manager_.get();
62 void MTPFileSystemBackendDelegate::GetRedirectURLForContents(
63 const storage::FileSystemURL& url,
64 const storage::URLCallback& callback) {
65 DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, url.type());
67 callback.Run(GURL());
70 } // namespace chromeos