15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ 6c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/weak_ptr.h" 101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "storage/browser/fileapi/async_file_util.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace net { 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class IOBuffer; 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 16bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdochclass MediaPathFilter; 17bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// This class handles native file system operations with media type filtering. 19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// To support virtual file systems it implements the AsyncFileUtil interface 20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// from scratch and provides synchronous override points. 2103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)class NativeMediaFileUtil : public storage::AsyncFileUtil { 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 23bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch explicit NativeMediaFileUtil(MediaPathFilter* media_path_filter); 24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual ~NativeMediaFileUtil(); 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Uses the MIME sniffer code, which actually looks into the file, 27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // to determine if it is really a media file (to avoid exposing 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // non-media files with a media file extension.) 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) static base::File::Error IsMediaFile(const base::FilePath& path); 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) static base::File::Error BufferIsMediaHeader(net::IOBuffer* buf, 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) size_t length); 32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 33a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // Methods to support CreateOrOpen. Public so they can be shared with 34a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // DeviceMediaAsyncFileUtil. 35a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch static void CreatedSnapshotFileForCreateOrOpen( 36a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch base::SequencedTaskRunner* media_task_runner, 37a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch int file_flags, 3803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::AsyncFileUtil::CreateOrOpenCallback& callback, 39a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch base::File::Error result, 40a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch const base::File::Info& file_info, 41a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch const base::FilePath& platform_path, 4203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const scoped_refptr<storage::ShareableFileReference>& file_ref); 43a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // AsyncFileUtil overrides. 457dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void CreateOrOpen( 4603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 4703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int file_flags, 49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const CreateOrOpenCallback& callback) OVERRIDE; 507dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void EnsureFileExists( 5103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 5203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const EnsureFileExistsCallback& callback) OVERRIDE; 547dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void CreateDirectory( 5503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 5603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool exclusive, 58868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool recursive, 59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const StatusCallback& callback) OVERRIDE; 607dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void GetFileInfo( 6103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 6203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const GetFileInfoCallback& callback) OVERRIDE; 647dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void ReadDirectory( 6503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 6603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const ReadDirectoryCallback& callback) OVERRIDE; 6803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) virtual void Touch(scoped_ptr<storage::FileSystemOperationContext> context, 6903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 7003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const base::Time& last_access_time, 7103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const base::Time& last_modified_time, 7203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const StatusCallback& callback) OVERRIDE; 7303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) virtual void Truncate(scoped_ptr<storage::FileSystemOperationContext> context, 7403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 7503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) int64 length, 7603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const StatusCallback& callback) OVERRIDE; 777dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void CopyFileLocal( 7803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 7903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& src_url, 8003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& dest_url, 8168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) CopyOrMoveOption option, 8258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) const CopyFileProgressCallback& progress_callback, 83868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const StatusCallback& callback) OVERRIDE; 847dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void MoveFileLocal( 8503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 8603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& src_url, 8703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& dest_url, 8868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) CopyOrMoveOption option, 89868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const StatusCallback& callback) OVERRIDE; 907dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void CopyInForeignFile( 9103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 92868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const base::FilePath& src_file_path, 9303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& dest_url, 94868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const StatusCallback& callback) OVERRIDE; 957dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void DeleteFile( 9603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 9703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 98868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const StatusCallback& callback) OVERRIDE; 997dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void DeleteDirectory( 10003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 10103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 102868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const StatusCallback& callback) OVERRIDE; 1037dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void DeleteRecursively( 10403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 10503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 106eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch const StatusCallback& callback) OVERRIDE; 1077dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void CreateSnapshotFile( 10803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 10903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 110868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const CreateSnapshotFileCallback& callback) OVERRIDE; 111868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 112868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) protected: 113868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void CreateDirectoryOnTaskRunnerThread( 11403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 11503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 116868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool exclusive, 117868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool recursive, 118868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const StatusCallback& callback); 119868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void GetFileInfoOnTaskRunnerThread( 12003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 12103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 122868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const GetFileInfoCallback& callback); 123868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void ReadDirectoryOnTaskRunnerThread( 12403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 12503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 126868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const ReadDirectoryCallback& callback); 127868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void CopyOrMoveFileLocalOnTaskRunnerThread( 12803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 12903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& src_url, 13003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& dest_url, 13168043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) CopyOrMoveOption option, 132868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool copy, 133868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const StatusCallback& callback); 134868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void CopyInForeignFileOnTaskRunnerThread( 13503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 136868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const base::FilePath& src_file_path, 13703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& dest_url, 138868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const StatusCallback& callback); 139f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual void DeleteFileOnTaskRunnerThread( 14003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 14103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 142f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) const StatusCallback& callback); 143868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void DeleteDirectoryOnTaskRunnerThread( 14403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 14503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 146868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const StatusCallback& callback); 147868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) virtual void CreateSnapshotFileOnTaskRunnerThread( 14803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_ptr<storage::FileSystemOperationContext> context, 14903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 150868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const CreateSnapshotFileCallback& callback); 151868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 152868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // The following methods should only be called on the task runner thread. 153868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 154868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Necessary for copy/move to succeed. 1555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual base::File::Error CreateDirectorySync( 15603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemOperationContext* context, 15703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 158868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool exclusive, 159868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool recursive); 1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual base::File::Error CopyOrMoveFileSync( 16103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemOperationContext* context, 16203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& src_url, 16303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& dest_url, 16468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) CopyOrMoveOption option, 165868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool copy); 1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual base::File::Error CopyInForeignFileSync( 16703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemOperationContext* context, 168868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const base::FilePath& src_file_path, 16903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& dest_url); 1705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual base::File::Error GetFileInfoSync( 17103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemOperationContext* context, 17203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 1735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::File::Info* file_info, 174868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::FilePath* platform_path); 175868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Called by GetFileInfoSync. Meant to be overridden by subclasses that 176868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // have special mappings from URLs to platform paths (virtual filesystems). 1775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual base::File::Error GetLocalFilePath( 17803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemOperationContext* context, 17903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& file_system_url, 180868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::FilePath* local_file_path); 1815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual base::File::Error ReadDirectorySync( 18203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemOperationContext* context, 18303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 184868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) EntryList* file_list); 1855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual base::File::Error DeleteFileSync( 18603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemOperationContext* context, 18703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url); 188868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Necessary for move to succeed. 1895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual base::File::Error DeleteDirectorySync( 19003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemOperationContext* context, 19103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url); 1925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual base::File::Error CreateSnapshotFileSync( 19303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemOperationContext* context, 19403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& url, 1955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::File::Info* file_info, 196868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) base::FilePath* platform_path, 19703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_refptr<storage::ShareableFileReference>* file_ref); 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 199d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) MediaPathFilter* media_path_filter() { 200bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch return media_path_filter_; 201bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch } 202bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 2042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Like GetLocalFilePath(), but always take media_path_filter() into 2052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // consideration. If the media_path_filter() check fails, return 206cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Fila::FILE_ERROR_SECURITY. |local_file_path| does not have to exist. 2075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::File::Error GetFilteredLocalFilePath( 20803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemOperationContext* context, 20903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& file_system_url, 2102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath* local_file_path); 2112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Like GetLocalFilePath(), but if the file does not exist, then return 2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // |failure_error|. 2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // If |local_file_path| is a file, then take media_path_filter() into 2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // consideration. 2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // If the media_path_filter() check fails, return |failure_error|. 217cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // If |local_file_path| is a directory, return File::FILE_OK. 2185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::File::Error GetFilteredLocalFilePathForExistingFileOrDirectory( 21903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) storage::FileSystemOperationContext* context, 22003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) const storage::FileSystemURL& file_system_url, 2215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::File::Error failure_error, 2222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath* local_file_path); 2232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 224bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch // Not owned, owned by the backend which owns this. 225cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) MediaPathFilter* const media_path_filter_; 226bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 2274e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) base::WeakPtrFactory<NativeMediaFileUtil> weak_factory_; 2284e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(NativeMediaFileUtil); 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 232c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ 233