15c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// Copyright 2014 The Chromium Authors. All rights reserved. 25c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// Use of this source code is governed by a BSD-style license that can be 35c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// found in the LICENSE file. 45c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 55c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.h" 65c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h" 71320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "storage/browser/blob/file_stream_reader.h" 81320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "storage/browser/fileapi/file_stream_writer.h" 91320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "storage/browser/fileapi/file_system_url.h" 105c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 115c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liunamespace chromeos { 125c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 135c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuMTPFileSystemBackendDelegate::MTPFileSystemBackendDelegate( 145c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu const base::FilePath& storage_partition_path) 155c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu : device_media_async_file_util_( 165c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu DeviceMediaAsyncFileUtil::Create(storage_partition_path, 175c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu NO_MEDIA_FILE_VALIDATION)) { 185c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 195c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 205c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuMTPFileSystemBackendDelegate::~MTPFileSystemBackendDelegate() { 215c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 225c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 2303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)storage::AsyncFileUtil* MTPFileSystemBackendDelegate::GetAsyncFileUtil( 2403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemType type) { 2503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, type); 265c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 275c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return device_media_async_file_util_.get(); 285c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 295c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 3003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)scoped_ptr<storage::FileStreamReader> 315c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuMTPFileSystemBackendDelegate::CreateFileStreamReader( 3203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 335c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu int64 offset, 341320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci int64 max_bytes_to_read, 355c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu const base::Time& expected_modification_time, 3603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemContext* context) { 3703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, url.type()); 385c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 395c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu return device_media_async_file_util_->GetFileStreamReader( 405c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu url, offset, expected_modification_time, context); 415c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 425c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 4303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)scoped_ptr<storage::FileStreamWriter> 445c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuMTPFileSystemBackendDelegate::CreateFileStreamWriter( 4503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 465c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu int64 offset, 4703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemContext* context) { 4803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, url.type()); 495c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 505c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // TODO(kinaba): support writing. 5103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) return scoped_ptr<storage::FileStreamWriter>(); 525c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} 535c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccistorage::WatcherManager* MTPFileSystemBackendDelegate::GetWatcherManager( 551320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const storage::FileSystemURL& url) { 561320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci NOTIMPLEMENTED(); 571320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci return NULL; 581320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 591320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 601320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid MTPFileSystemBackendDelegate::GetRedirectURLForContents( 611320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const storage::FileSystemURL& url, 621320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const storage::URLCallback& callback) { 631320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci DCHECK_EQ(storage::kFileSystemTypeDeviceMediaAsFileStorage, url.type()); 641320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 651320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci callback.Run(GURL()); 661320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci} 671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 685c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu} // namespace chromeos 69