1 // Copyright 2013 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. 4 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_FILE_UTIL_H_ 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_FILE_UTIL_H_ 7 8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/weak_ptr.h" 10 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" 11 12 namespace chrome { 13 class ImportedMediaGalleryRegistry; 14 } 15 16 namespace itunes { 17 18 class ITunesDataProvider; 19 20 extern const char kITunesLibraryXML[]; 21 extern const char kITunesMediaDir[]; 22 extern const char kITunesMusicDir[]; 23 extern const char kITunesAutoAddDir[]; 24 25 class ITunesFileUtil : public chrome::NativeMediaFileUtil { 26 public: 27 explicit ITunesFileUtil(chrome::MediaPathFilter* media_path_filter); 28 virtual ~ITunesFileUtil(); 29 30 protected: 31 // NativeMediaFileUtil overrides. 32 virtual void GetFileInfoOnTaskRunnerThread( 33 scoped_ptr<fileapi::FileSystemOperationContext> context, 34 const fileapi::FileSystemURL& url, 35 const GetFileInfoCallback& callback) OVERRIDE; 36 virtual void ReadDirectoryOnTaskRunnerThread( 37 scoped_ptr<fileapi::FileSystemOperationContext> context, 38 const fileapi::FileSystemURL& url, 39 const ReadDirectoryCallback& callback) OVERRIDE; 40 virtual void CreateSnapshotFileOnTaskRunnerThread( 41 scoped_ptr<fileapi::FileSystemOperationContext> context, 42 const fileapi::FileSystemURL& url, 43 const CreateSnapshotFileCallback& callback) OVERRIDE; 44 virtual base::PlatformFileError GetFileInfoSync( 45 fileapi::FileSystemOperationContext* context, 46 const fileapi::FileSystemURL& url, 47 base::PlatformFileInfo* file_info, 48 base::FilePath* platform_path) OVERRIDE; 49 virtual base::PlatformFileError ReadDirectorySync( 50 fileapi::FileSystemOperationContext* context, 51 const fileapi::FileSystemURL& url, 52 EntryList* file_list) OVERRIDE; 53 virtual base::PlatformFileError CreateSnapshotFileSync( 54 fileapi::FileSystemOperationContext* context, 55 const fileapi::FileSystemURL& url, 56 base::PlatformFileInfo* file_info, 57 base::FilePath* platform_path, 58 scoped_refptr<webkit_blob::ShareableFileReference>* file_ref) OVERRIDE; 59 virtual base::PlatformFileError GetLocalFilePath( 60 fileapi::FileSystemOperationContext* context, 61 const fileapi::FileSystemURL& url, 62 base::FilePath* local_file_path) OVERRIDE; 63 64 private: 65 void GetFileInfoWithFreshDataProvider( 66 scoped_ptr<fileapi::FileSystemOperationContext> context, 67 const fileapi::FileSystemURL& url, 68 const GetFileInfoCallback& callback, 69 bool valid_parse); 70 void ReadDirectoryWithFreshDataProvider( 71 scoped_ptr<fileapi::FileSystemOperationContext> context, 72 const fileapi::FileSystemURL& url, 73 const ReadDirectoryCallback& callback, 74 bool valid_parse); 75 virtual void CreateSnapshotFileWithFreshDataProvider( 76 scoped_ptr<fileapi::FileSystemOperationContext> context, 77 const fileapi::FileSystemURL& url, 78 const CreateSnapshotFileCallback& callback, 79 bool valid_parse); 80 81 virtual ITunesDataProvider* GetDataProvider(); 82 83 base::WeakPtrFactory<ITunesFileUtil> weak_factory_; 84 85 chrome::ImportedMediaGalleryRegistry* imported_registry_; 86 87 DISALLOW_COPY_AND_ASSIGN(ITunesFileUtil); 88 }; 89 90 } // namespace itunes 91 92 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_ITUNES_FILE_UTIL_H_ 93