| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/media_galleries/fileapi/itunes_file_util.h" | 5 #include "chrome/browser/media_galleries/fileapi/itunes_file_util.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/media_galleries/fileapi/itunes_data_provider.h" | 14 #include "chrome/browser/media_galleries/fileapi/itunes_data_provider.h" |
| 15 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" | 15 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
| 16 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" | 16 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "webkit/browser/fileapi/file_system_operation_context.h" | 18 #include "storage/browser/fileapi/file_system_operation_context.h" |
| 19 #include "webkit/browser/fileapi/file_system_url.h" | 19 #include "storage/browser/fileapi/file_system_url.h" |
| 20 #include "webkit/browser/fileapi/native_file_util.h" | 20 #include "storage/browser/fileapi/native_file_util.h" |
| 21 #include "webkit/common/blob/shareable_file_reference.h" | 21 #include "storage/common/blob/shareable_file_reference.h" |
| 22 #include "webkit/common/fileapi/file_system_util.h" | 22 #include "storage/common/fileapi/file_system_util.h" |
| 23 | 23 |
| 24 using fileapi::DirectoryEntry; | 24 using storage::DirectoryEntry; |
| 25 | 25 |
| 26 namespace itunes { | 26 namespace itunes { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 base::File::Error MakeDirectoryFileInfo(base::File::Info* file_info) { | 30 base::File::Error MakeDirectoryFileInfo(base::File::Info* file_info) { |
| 31 base::File::Info result; | 31 base::File::Info result; |
| 32 result.is_directory = true; | 32 result.is_directory = true; |
| 33 *file_info = result; | 33 *file_info = result; |
| 34 return base::File::FILE_OK; | 34 return base::File::FILE_OK; |
| 35 } | 35 } |
| 36 | 36 |
| 37 std::vector<std::string> GetVirtualPathComponents( | 37 std::vector<std::string> GetVirtualPathComponents( |
| 38 const fileapi::FileSystemURL& url) { | 38 const storage::FileSystemURL& url) { |
| 39 ImportedMediaGalleryRegistry* imported_registry = | 39 ImportedMediaGalleryRegistry* imported_registry = |
| 40 ImportedMediaGalleryRegistry::GetInstance(); | 40 ImportedMediaGalleryRegistry::GetInstance(); |
| 41 base::FilePath root = imported_registry->ImportedRoot().AppendASCII("itunes"); | 41 base::FilePath root = imported_registry->ImportedRoot().AppendASCII("itunes"); |
| 42 | 42 |
| 43 DCHECK(root.IsParent(url.path()) || root == url.path()); | 43 DCHECK(root.IsParent(url.path()) || root == url.path()); |
| 44 base::FilePath virtual_path; | 44 base::FilePath virtual_path; |
| 45 root.AppendRelativePath(url.path(), &virtual_path); | 45 root.AppendRelativePath(url.path(), &virtual_path); |
| 46 | 46 |
| 47 std::vector<std::string> result; | 47 std::vector<std::string> result; |
| 48 fileapi::VirtualPath::GetComponentsUTF8Unsafe(virtual_path, &result); | 48 storage::VirtualPath::GetComponentsUTF8Unsafe(virtual_path, &result); |
| 49 return result; | 49 return result; |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 const char kITunesLibraryXML[] = "iTunes Music Library.xml"; | 54 const char kITunesLibraryXML[] = "iTunes Music Library.xml"; |
| 55 const char kITunesMediaDir[] = "iTunes Media"; | 55 const char kITunesMediaDir[] = "iTunes Media"; |
| 56 const char kITunesMusicDir[] = "Music"; | 56 const char kITunesMusicDir[] = "Music"; |
| 57 const char kITunesAutoAddDir[] = "Automatically Add to iTunes"; | 57 const char kITunesAutoAddDir[] = "Automatically Add to iTunes"; |
| 58 | 58 |
| 59 ITunesFileUtil::ITunesFileUtil(MediaPathFilter* media_path_filter) | 59 ITunesFileUtil::ITunesFileUtil(MediaPathFilter* media_path_filter) |
| 60 : NativeMediaFileUtil(media_path_filter), | 60 : NativeMediaFileUtil(media_path_filter), |
| 61 weak_factory_(this), | 61 weak_factory_(this), |
| 62 imported_registry_(NULL) { | 62 imported_registry_(NULL) { |
| 63 } | 63 } |
| 64 | 64 |
| 65 ITunesFileUtil::~ITunesFileUtil() { | 65 ITunesFileUtil::~ITunesFileUtil() { |
| 66 } | 66 } |
| 67 | 67 |
| 68 void ITunesFileUtil::GetFileInfoOnTaskRunnerThread( | 68 void ITunesFileUtil::GetFileInfoOnTaskRunnerThread( |
| 69 scoped_ptr<fileapi::FileSystemOperationContext> context, | 69 scoped_ptr<storage::FileSystemOperationContext> context, |
| 70 const fileapi::FileSystemURL& url, | 70 const storage::FileSystemURL& url, |
| 71 const GetFileInfoCallback& callback) { | 71 const GetFileInfoCallback& callback) { |
| 72 ITunesDataProvider* data_provider = GetDataProvider(); | 72 ITunesDataProvider* data_provider = GetDataProvider(); |
| 73 // |data_provider| may be NULL if the file system was revoked before this | 73 // |data_provider| may be NULL if the file system was revoked before this |
| 74 // operation had a chance to run. | 74 // operation had a chance to run. |
| 75 if (!data_provider) { | 75 if (!data_provider) { |
| 76 GetFileInfoWithFreshDataProvider(context.Pass(), url, callback, false); | 76 GetFileInfoWithFreshDataProvider(context.Pass(), url, callback, false); |
| 77 } else { | 77 } else { |
| 78 data_provider->RefreshData( | 78 data_provider->RefreshData( |
| 79 base::Bind(&ITunesFileUtil::GetFileInfoWithFreshDataProvider, | 79 base::Bind(&ITunesFileUtil::GetFileInfoWithFreshDataProvider, |
| 80 weak_factory_.GetWeakPtr(), base::Passed(&context), url, | 80 weak_factory_.GetWeakPtr(), base::Passed(&context), url, |
| 81 callback)); | 81 callback)); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 void ITunesFileUtil::ReadDirectoryOnTaskRunnerThread( | 85 void ITunesFileUtil::ReadDirectoryOnTaskRunnerThread( |
| 86 scoped_ptr<fileapi::FileSystemOperationContext> context, | 86 scoped_ptr<storage::FileSystemOperationContext> context, |
| 87 const fileapi::FileSystemURL& url, | 87 const storage::FileSystemURL& url, |
| 88 const ReadDirectoryCallback& callback) { | 88 const ReadDirectoryCallback& callback) { |
| 89 ITunesDataProvider* data_provider = GetDataProvider(); | 89 ITunesDataProvider* data_provider = GetDataProvider(); |
| 90 // |data_provider| may be NULL if the file system was revoked before this | 90 // |data_provider| may be NULL if the file system was revoked before this |
| 91 // operation had a chance to run. | 91 // operation had a chance to run. |
| 92 if (!data_provider) { | 92 if (!data_provider) { |
| 93 ReadDirectoryWithFreshDataProvider(context.Pass(), url, callback, false); | 93 ReadDirectoryWithFreshDataProvider(context.Pass(), url, callback, false); |
| 94 } else { | 94 } else { |
| 95 data_provider->RefreshData( | 95 data_provider->RefreshData( |
| 96 base::Bind(&ITunesFileUtil::ReadDirectoryWithFreshDataProvider, | 96 base::Bind(&ITunesFileUtil::ReadDirectoryWithFreshDataProvider, |
| 97 weak_factory_.GetWeakPtr(), base::Passed(&context), url, | 97 weak_factory_.GetWeakPtr(), base::Passed(&context), url, |
| 98 callback)); | 98 callback)); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 void ITunesFileUtil::CreateSnapshotFileOnTaskRunnerThread( | 102 void ITunesFileUtil::CreateSnapshotFileOnTaskRunnerThread( |
| 103 scoped_ptr<fileapi::FileSystemOperationContext> context, | 103 scoped_ptr<storage::FileSystemOperationContext> context, |
| 104 const fileapi::FileSystemURL& url, | 104 const storage::FileSystemURL& url, |
| 105 const CreateSnapshotFileCallback& callback) { | 105 const CreateSnapshotFileCallback& callback) { |
| 106 ITunesDataProvider* data_provider = GetDataProvider(); | 106 ITunesDataProvider* data_provider = GetDataProvider(); |
| 107 // |data_provider| may be NULL if the file system was revoked before this | 107 // |data_provider| may be NULL if the file system was revoked before this |
| 108 // operation had a chance to run. | 108 // operation had a chance to run. |
| 109 if (!data_provider) { | 109 if (!data_provider) { |
| 110 CreateSnapshotFileWithFreshDataProvider(context.Pass(), url, callback, | 110 CreateSnapshotFileWithFreshDataProvider(context.Pass(), url, callback, |
| 111 false); | 111 false); |
| 112 } else { | 112 } else { |
| 113 data_provider->RefreshData( | 113 data_provider->RefreshData( |
| 114 base::Bind(&ITunesFileUtil::CreateSnapshotFileWithFreshDataProvider, | 114 base::Bind(&ITunesFileUtil::CreateSnapshotFileWithFreshDataProvider, |
| 115 weak_factory_.GetWeakPtr(), base::Passed(&context), url, | 115 weak_factory_.GetWeakPtr(), base::Passed(&context), url, |
| 116 callback)); | 116 callback)); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Contents of the iTunes media gallery: | 120 // Contents of the iTunes media gallery: |
| 121 // / - root directory | 121 // / - root directory |
| 122 // /iTunes Music Library.xml - library xml file | 122 // /iTunes Music Library.xml - library xml file |
| 123 // /iTunes Media/Automatically Add to iTunes - auto-import directory | 123 // /iTunes Media/Automatically Add to iTunes - auto-import directory |
| 124 // /iTunes Media/Music/<Artist>/<Album>/<Track> - tracks | 124 // /iTunes Media/Music/<Artist>/<Album>/<Track> - tracks |
| 125 // | 125 // |
| 126 base::File::Error ITunesFileUtil::GetFileInfoSync( | 126 base::File::Error ITunesFileUtil::GetFileInfoSync( |
| 127 fileapi::FileSystemOperationContext* context, | 127 storage::FileSystemOperationContext* context, |
| 128 const fileapi::FileSystemURL& url, | 128 const storage::FileSystemURL& url, |
| 129 base::File::Info* file_info, | 129 base::File::Info* file_info, |
| 130 base::FilePath* platform_path) { | 130 base::FilePath* platform_path) { |
| 131 std::vector<std::string> components = GetVirtualPathComponents(url); | 131 std::vector<std::string> components = GetVirtualPathComponents(url); |
| 132 | 132 |
| 133 if (components.size() == 0) | 133 if (components.size() == 0) |
| 134 return MakeDirectoryFileInfo(file_info); | 134 return MakeDirectoryFileInfo(file_info); |
| 135 | 135 |
| 136 if (components.size() == 1 && components[0] == kITunesLibraryXML) { | 136 if (components.size() == 1 && components[0] == kITunesLibraryXML) { |
| 137 // We can't just call NativeMediaFileUtil::GetFileInfoSync() here because it | 137 // We can't just call NativeMediaFileUtil::GetFileInfoSync() here because it |
| 138 // uses the MediaPathFilter. At this point, |library_path_| is known good | 138 // uses the MediaPathFilter. At this point, |library_path_| is known good |
| 139 // because GetFileInfoWithFreshDataProvider() gates access to this method. | 139 // because GetFileInfoWithFreshDataProvider() gates access to this method. |
| 140 base::FilePath file_path = GetDataProvider()->library_path(); | 140 base::FilePath file_path = GetDataProvider()->library_path(); |
| 141 if (platform_path) | 141 if (platform_path) |
| 142 *platform_path = file_path; | 142 *platform_path = file_path; |
| 143 return fileapi::NativeFileUtil::GetFileInfo(file_path, file_info); | 143 return storage::NativeFileUtil::GetFileInfo(file_path, file_info); |
| 144 } | 144 } |
| 145 | 145 |
| 146 if (components[0] != kITunesMediaDir) | 146 if (components[0] != kITunesMediaDir) |
| 147 return base::File::FILE_ERROR_NOT_FOUND; | 147 return base::File::FILE_ERROR_NOT_FOUND; |
| 148 | 148 |
| 149 if (components[1] == kITunesAutoAddDir) { | 149 if (components[1] == kITunesAutoAddDir) { |
| 150 if (GetDataProvider()->auto_add_path().empty()) | 150 if (GetDataProvider()->auto_add_path().empty()) |
| 151 return base::File::FILE_ERROR_NOT_FOUND; | 151 return base::File::FILE_ERROR_NOT_FOUND; |
| 152 return NativeMediaFileUtil::GetFileInfoSync(context, url, file_info, | 152 return NativeMediaFileUtil::GetFileInfoSync(context, url, file_info, |
| 153 platform_path); | 153 platform_path); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 178 } | 178 } |
| 179 break; | 179 break; |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 return base::File::FILE_ERROR_NOT_FOUND; | 184 return base::File::FILE_ERROR_NOT_FOUND; |
| 185 } | 185 } |
| 186 | 186 |
| 187 base::File::Error ITunesFileUtil::ReadDirectorySync( | 187 base::File::Error ITunesFileUtil::ReadDirectorySync( |
| 188 fileapi::FileSystemOperationContext* context, | 188 storage::FileSystemOperationContext* context, |
| 189 const fileapi::FileSystemURL& url, | 189 const storage::FileSystemURL& url, |
| 190 EntryList* file_list) { | 190 EntryList* file_list) { |
| 191 DCHECK(file_list->empty()); | 191 DCHECK(file_list->empty()); |
| 192 std::vector<std::string> components = GetVirtualPathComponents(url); | 192 std::vector<std::string> components = GetVirtualPathComponents(url); |
| 193 | 193 |
| 194 if (components.size() == 0) { | 194 if (components.size() == 0) { |
| 195 base::File::Info xml_info; | 195 base::File::Info xml_info; |
| 196 if (!base::GetFileInfo(GetDataProvider()->library_path(), &xml_info)) | 196 if (!base::GetFileInfo(GetDataProvider()->library_path(), &xml_info)) |
| 197 return base::File::FILE_ERROR_IO; | 197 return base::File::FILE_ERROR_IO; |
| 198 file_list->push_back(DirectoryEntry(kITunesLibraryXML, | 198 file_list->push_back(DirectoryEntry(kITunesLibraryXML, |
| 199 DirectoryEntry::FILE, | 199 DirectoryEntry::FILE, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 DCHECK_EQ(4UL, components.size()); | 275 DCHECK_EQ(4UL, components.size()); |
| 276 base::FilePath location; | 276 base::FilePath location; |
| 277 location = GetDataProvider()->GetTrackLocation(components[1], components[2], | 277 location = GetDataProvider()->GetTrackLocation(components[1], components[2], |
| 278 components[3]); | 278 components[3]); |
| 279 if (!location.empty()) | 279 if (!location.empty()) |
| 280 return base::File::FILE_ERROR_NOT_A_DIRECTORY; | 280 return base::File::FILE_ERROR_NOT_A_DIRECTORY; |
| 281 return base::File::FILE_ERROR_NOT_FOUND; | 281 return base::File::FILE_ERROR_NOT_FOUND; |
| 282 } | 282 } |
| 283 | 283 |
| 284 base::File::Error ITunesFileUtil::DeleteDirectorySync( | 284 base::File::Error ITunesFileUtil::DeleteDirectorySync( |
| 285 fileapi::FileSystemOperationContext* context, | 285 storage::FileSystemOperationContext* context, |
| 286 const fileapi::FileSystemURL& url) { | 286 const storage::FileSystemURL& url) { |
| 287 return base::File::FILE_ERROR_SECURITY; | 287 return base::File::FILE_ERROR_SECURITY; |
| 288 } | 288 } |
| 289 | 289 |
| 290 base::File::Error ITunesFileUtil::DeleteFileSync( | 290 base::File::Error ITunesFileUtil::DeleteFileSync( |
| 291 fileapi::FileSystemOperationContext* context, | 291 storage::FileSystemOperationContext* context, |
| 292 const fileapi::FileSystemURL& url) { | 292 const storage::FileSystemURL& url) { |
| 293 return base::File::FILE_ERROR_SECURITY; | 293 return base::File::FILE_ERROR_SECURITY; |
| 294 } | 294 } |
| 295 | 295 |
| 296 base::File::Error ITunesFileUtil::CreateSnapshotFileSync( | 296 base::File::Error ITunesFileUtil::CreateSnapshotFileSync( |
| 297 fileapi::FileSystemOperationContext* context, | 297 storage::FileSystemOperationContext* context, |
| 298 const fileapi::FileSystemURL& url, | 298 const storage::FileSystemURL& url, |
| 299 base::File::Info* file_info, | 299 base::File::Info* file_info, |
| 300 base::FilePath* platform_path, | 300 base::FilePath* platform_path, |
| 301 scoped_refptr<webkit_blob::ShareableFileReference>* file_ref) { | 301 scoped_refptr<storage::ShareableFileReference>* file_ref) { |
| 302 std::vector<std::string> components = GetVirtualPathComponents(url); | 302 std::vector<std::string> components = GetVirtualPathComponents(url); |
| 303 if (components.size() != 1 || components[0] != kITunesLibraryXML) { | 303 if (components.size() != 1 || components[0] != kITunesLibraryXML) { |
| 304 return NativeMediaFileUtil::CreateSnapshotFileSync(context, url, file_info, | 304 return NativeMediaFileUtil::CreateSnapshotFileSync(context, url, file_info, |
| 305 platform_path, file_ref); | 305 platform_path, file_ref); |
| 306 } | 306 } |
| 307 | 307 |
| 308 // The following code is different than | 308 // The following code is different than |
| 309 // NativeMediaFileUtil::CreateSnapshotFileSync in that it knows that the | 309 // NativeMediaFileUtil::CreateSnapshotFileSync in that it knows that the |
| 310 // library xml file is not a directory and it doesn't run mime sniffing on the | 310 // library xml file is not a directory and it doesn't run mime sniffing on the |
| 311 // file. The only way to get here is by way of | 311 // file. The only way to get here is by way of |
| 312 // CreateSnapshotFileWithFreshDataProvider() so the file has already been | 312 // CreateSnapshotFileWithFreshDataProvider() so the file has already been |
| 313 // parsed and deemed valid. | 313 // parsed and deemed valid. |
| 314 *file_ref = scoped_refptr<webkit_blob::ShareableFileReference>(); | 314 *file_ref = scoped_refptr<storage::ShareableFileReference>(); |
| 315 return GetFileInfoSync(context, url, file_info, platform_path); | 315 return GetFileInfoSync(context, url, file_info, platform_path); |
| 316 } | 316 } |
| 317 | 317 |
| 318 base::File::Error ITunesFileUtil::GetLocalFilePath( | 318 base::File::Error ITunesFileUtil::GetLocalFilePath( |
| 319 fileapi::FileSystemOperationContext* context, | 319 storage::FileSystemOperationContext* context, |
| 320 const fileapi::FileSystemURL& url, | 320 const storage::FileSystemURL& url, |
| 321 base::FilePath* local_file_path) { | 321 base::FilePath* local_file_path) { |
| 322 std::vector<std::string> components = GetVirtualPathComponents(url); | 322 std::vector<std::string> components = GetVirtualPathComponents(url); |
| 323 | 323 |
| 324 if (components.size() == 1 && components[0] == kITunesLibraryXML) { | 324 if (components.size() == 1 && components[0] == kITunesLibraryXML) { |
| 325 *local_file_path = GetDataProvider()->library_path(); | 325 *local_file_path = GetDataProvider()->library_path(); |
| 326 return base::File::FILE_OK; | 326 return base::File::FILE_OK; |
| 327 } | 327 } |
| 328 | 328 |
| 329 if (components.size() >= 2 && components[0] == kITunesMediaDir && | 329 if (components.size() >= 2 && components[0] == kITunesMediaDir && |
| 330 components[1] == kITunesAutoAddDir) { | 330 components[1] == kITunesAutoAddDir) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 348 *local_file_path = GetDataProvider()->GetTrackLocation(components[2], | 348 *local_file_path = GetDataProvider()->GetTrackLocation(components[2], |
| 349 components[3], | 349 components[3], |
| 350 components[4]); | 350 components[4]); |
| 351 if (!local_file_path->empty()) | 351 if (!local_file_path->empty()) |
| 352 return base::File::FILE_OK; | 352 return base::File::FILE_OK; |
| 353 | 353 |
| 354 return base::File::FILE_ERROR_NOT_FOUND; | 354 return base::File::FILE_ERROR_NOT_FOUND; |
| 355 } | 355 } |
| 356 | 356 |
| 357 void ITunesFileUtil::GetFileInfoWithFreshDataProvider( | 357 void ITunesFileUtil::GetFileInfoWithFreshDataProvider( |
| 358 scoped_ptr<fileapi::FileSystemOperationContext> context, | 358 scoped_ptr<storage::FileSystemOperationContext> context, |
| 359 const fileapi::FileSystemURL& url, | 359 const storage::FileSystemURL& url, |
| 360 const GetFileInfoCallback& callback, | 360 const GetFileInfoCallback& callback, |
| 361 bool valid_parse) { | 361 bool valid_parse) { |
| 362 if (!valid_parse) { | 362 if (!valid_parse) { |
| 363 if (!callback.is_null()) { | 363 if (!callback.is_null()) { |
| 364 content::BrowserThread::PostTask( | 364 content::BrowserThread::PostTask( |
| 365 content::BrowserThread::IO, | 365 content::BrowserThread::IO, |
| 366 FROM_HERE, | 366 FROM_HERE, |
| 367 base::Bind(callback, base::File::FILE_ERROR_IO, | 367 base::Bind(callback, base::File::FILE_ERROR_IO, |
| 368 base::File::Info())); | 368 base::File::Info())); |
| 369 } | 369 } |
| 370 return; | 370 return; |
| 371 } | 371 } |
| 372 NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread(context.Pass(), url, | 372 NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread(context.Pass(), url, |
| 373 callback); | 373 callback); |
| 374 } | 374 } |
| 375 | 375 |
| 376 void ITunesFileUtil::ReadDirectoryWithFreshDataProvider( | 376 void ITunesFileUtil::ReadDirectoryWithFreshDataProvider( |
| 377 scoped_ptr<fileapi::FileSystemOperationContext> context, | 377 scoped_ptr<storage::FileSystemOperationContext> context, |
| 378 const fileapi::FileSystemURL& url, | 378 const storage::FileSystemURL& url, |
| 379 const ReadDirectoryCallback& callback, | 379 const ReadDirectoryCallback& callback, |
| 380 bool valid_parse) { | 380 bool valid_parse) { |
| 381 if (!valid_parse) { | 381 if (!valid_parse) { |
| 382 if (!callback.is_null()) { | 382 if (!callback.is_null()) { |
| 383 content::BrowserThread::PostTask( | 383 content::BrowserThread::PostTask( |
| 384 content::BrowserThread::IO, | 384 content::BrowserThread::IO, |
| 385 FROM_HERE, | 385 FROM_HERE, |
| 386 base::Bind(callback, base::File::FILE_ERROR_IO, EntryList(), false)); | 386 base::Bind(callback, base::File::FILE_ERROR_IO, EntryList(), false)); |
| 387 } | 387 } |
| 388 return; | 388 return; |
| 389 } | 389 } |
| 390 NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread(context.Pass(), url, | 390 NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread(context.Pass(), url, |
| 391 callback); | 391 callback); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void ITunesFileUtil::CreateSnapshotFileWithFreshDataProvider( | 394 void ITunesFileUtil::CreateSnapshotFileWithFreshDataProvider( |
| 395 scoped_ptr<fileapi::FileSystemOperationContext> context, | 395 scoped_ptr<storage::FileSystemOperationContext> context, |
| 396 const fileapi::FileSystemURL& url, | 396 const storage::FileSystemURL& url, |
| 397 const CreateSnapshotFileCallback& callback, | 397 const CreateSnapshotFileCallback& callback, |
| 398 bool valid_parse) { | 398 bool valid_parse) { |
| 399 if (!valid_parse) { | 399 if (!valid_parse) { |
| 400 if (!callback.is_null()) { | 400 if (!callback.is_null()) { |
| 401 base::File::Info file_info; | 401 base::File::Info file_info; |
| 402 base::FilePath platform_path; | 402 base::FilePath platform_path; |
| 403 scoped_refptr<webkit_blob::ShareableFileReference> file_ref; | 403 scoped_refptr<storage::ShareableFileReference> file_ref; |
| 404 content::BrowserThread::PostTask( | 404 content::BrowserThread::PostTask( |
| 405 content::BrowserThread::IO, | 405 content::BrowserThread::IO, |
| 406 FROM_HERE, | 406 FROM_HERE, |
| 407 base::Bind(callback, base::File::FILE_ERROR_IO, file_info, | 407 base::Bind(callback, base::File::FILE_ERROR_IO, file_info, |
| 408 platform_path, file_ref)); | 408 platform_path, file_ref)); |
| 409 } | 409 } |
| 410 return; | 410 return; |
| 411 } | 411 } |
| 412 NativeMediaFileUtil::CreateSnapshotFileOnTaskRunnerThread(context.Pass(), url, | 412 NativeMediaFileUtil::CreateSnapshotFileOnTaskRunnerThread(context.Pass(), url, |
| 413 callback); | 413 callback); |
| 414 } | 414 } |
| 415 | 415 |
| 416 ITunesDataProvider* ITunesFileUtil::GetDataProvider() { | 416 ITunesDataProvider* ITunesFileUtil::GetDataProvider() { |
| 417 if (!imported_registry_) | 417 if (!imported_registry_) |
| 418 imported_registry_ = ImportedMediaGalleryRegistry::GetInstance(); | 418 imported_registry_ = ImportedMediaGalleryRegistry::GetInstance(); |
| 419 return imported_registry_->ITunesDataProvider(); | 419 return imported_registry_->ITunesDataProvider(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 } // namespace itunes | 422 } // namespace itunes |
| OLD | NEW |