Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chrome/browser/media_galleries/fileapi/itunes_file_util.cc

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "webkit/browser/fileapi/file_system_operation_context.h"
19 #include "webkit/browser/fileapi/file_system_url.h" 19 #include "webkit/browser/fileapi/file_system_url.h"
20 #include "webkit/browser/fileapi/native_file_util.h" 20 #include "webkit/browser/fileapi/native_file_util.h"
21 #include "webkit/common/blob/shareable_file_reference.h" 21 #include "webkit/common/blob/shareable_file_reference.h"
22 #include "webkit/common/fileapi/file_system_util.h" 22 #include "webkit/common/fileapi/file_system_util.h"
23 23
24 using fileapi::DirectoryEntry; 24 using fileapi::DirectoryEntry;
25 25
26 namespace itunes { 26 namespace itunes {
27 27
28 namespace { 28 namespace {
29 29
30 base::PlatformFileError MakeDirectoryFileInfo( 30 base::File::Error MakeDirectoryFileInfo(base::File::Info* file_info) {
31 base::PlatformFileInfo* file_info) { 31 base::File::Info result;
32 base::PlatformFileInfo result;
33 result.is_directory = true; 32 result.is_directory = true;
34 *file_info = result; 33 *file_info = result;
35 return base::PLATFORM_FILE_OK; 34 return base::File::FILE_OK;
36 } 35 }
37 36
38 } // namespace 37 } // namespace
39 38
40 const char kITunesLibraryXML[] = "iTunes Music Library.xml"; 39 const char kITunesLibraryXML[] = "iTunes Music Library.xml";
41 const char kITunesMediaDir[] = "iTunes Media"; 40 const char kITunesMediaDir[] = "iTunes Media";
42 const char kITunesMusicDir[] = "Music"; 41 const char kITunesMusicDir[] = "Music";
43 const char kITunesAutoAddDir[] = "Automatically Add to iTunes"; 42 const char kITunesAutoAddDir[] = "Automatically Add to iTunes";
44 43
45 ITunesFileUtil::ITunesFileUtil(MediaPathFilter* media_path_filter) 44 ITunesFileUtil::ITunesFileUtil(MediaPathFilter* media_path_filter)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 weak_factory_.GetWeakPtr(), base::Passed(&context), url, 79 weak_factory_.GetWeakPtr(), base::Passed(&context), url,
81 callback)); 80 callback));
82 } 81 }
83 82
84 // Contents of the iTunes media gallery: 83 // Contents of the iTunes media gallery:
85 // / - root directory 84 // / - root directory
86 // /iTunes Music Library.xml - library xml file 85 // /iTunes Music Library.xml - library xml file
87 // /iTunes Media/Automatically Add to iTunes - auto-import directory 86 // /iTunes Media/Automatically Add to iTunes - auto-import directory
88 // /iTunes Media/Music/<Artist>/<Album>/<Track> - tracks 87 // /iTunes Media/Music/<Artist>/<Album>/<Track> - tracks
89 // 88 //
90 base::PlatformFileError ITunesFileUtil::GetFileInfoSync( 89 base::File::Error ITunesFileUtil::GetFileInfoSync(
91 fileapi::FileSystemOperationContext* context, 90 fileapi::FileSystemOperationContext* context,
92 const fileapi::FileSystemURL& url, 91 const fileapi::FileSystemURL& url,
93 base::PlatformFileInfo* file_info, 92 base::File::Info* file_info,
94 base::FilePath* platform_path) { 93 base::FilePath* platform_path) {
95 std::vector<std::string> components; 94 std::vector<std::string> components;
96 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); 95 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components);
97 96
98 if (components.size() == 0) 97 if (components.size() == 0)
99 return MakeDirectoryFileInfo(file_info); 98 return MakeDirectoryFileInfo(file_info);
100 99
101 if (components.size() == 1 && components[0] == kITunesLibraryXML) { 100 if (components.size() == 1 && components[0] == kITunesLibraryXML) {
102 // We can't just call NativeMediaFileUtil::GetFileInfoSync() here because it 101 // We can't just call NativeMediaFileUtil::GetFileInfoSync() here because it
103 // uses the MediaPathFilter. At this point, |library_path_| is known good 102 // uses the MediaPathFilter. At this point, |library_path_| is known good
104 // because GetFileInfoWithFreshDataProvider() gates access to this method. 103 // because GetFileInfoWithFreshDataProvider() gates access to this method.
105 base::FilePath file_path = GetDataProvider()->library_path(); 104 base::FilePath file_path = GetDataProvider()->library_path();
106 if (platform_path) 105 if (platform_path)
107 *platform_path = file_path; 106 *platform_path = file_path;
108 return fileapi::NativeFileUtil::GetFileInfo(file_path, file_info); 107 return fileapi::NativeFileUtil::GetFileInfo(file_path, file_info);
109 } 108 }
110 109
111 if (components[0] != kITunesMediaDir) 110 if (components[0] != kITunesMediaDir)
112 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 111 return base::File::FILE_ERROR_NOT_FOUND;
113 112
114 if (components[1] == kITunesAutoAddDir) { 113 if (components[1] == kITunesAutoAddDir) {
115 if (GetDataProvider()->auto_add_path().empty()) 114 if (GetDataProvider()->auto_add_path().empty())
116 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 115 return base::File::FILE_ERROR_NOT_FOUND;
117 return NativeMediaFileUtil::GetFileInfoSync(context, url, file_info, 116 return NativeMediaFileUtil::GetFileInfoSync(context, url, file_info,
118 platform_path); 117 platform_path);
119 } 118 }
120 119
121 if (components[1] == kITunesMusicDir) { 120 if (components[1] == kITunesMusicDir) {
122 switch (components.size()) { 121 switch (components.size()) {
123 case 2: 122 case 2:
124 return MakeDirectoryFileInfo(file_info); 123 return MakeDirectoryFileInfo(file_info);
125 124
126 case 3: 125 case 3:
(...skipping 12 matching lines...) Expand all
139 components[4]); 138 components[4]);
140 if (!location.empty()) { 139 if (!location.empty()) {
141 return NativeMediaFileUtil::GetFileInfoSync(context, url, file_info, 140 return NativeMediaFileUtil::GetFileInfoSync(context, url, file_info,
142 platform_path); 141 platform_path);
143 } 142 }
144 break; 143 break;
145 } 144 }
146 } 145 }
147 } 146 }
148 147
149 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 148 return base::File::FILE_ERROR_NOT_FOUND;
150 } 149 }
151 150
152 base::PlatformFileError ITunesFileUtil::ReadDirectorySync( 151 base::File::Error ITunesFileUtil::ReadDirectorySync(
153 fileapi::FileSystemOperationContext* context, 152 fileapi::FileSystemOperationContext* context,
154 const fileapi::FileSystemURL& url, 153 const fileapi::FileSystemURL& url,
155 EntryList* file_list) { 154 EntryList* file_list) {
156 DCHECK(file_list->empty()); 155 DCHECK(file_list->empty());
157 std::vector<std::string> components; 156 std::vector<std::string> components;
158 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); 157 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components);
159 158
160 if (components.size() == 0) { 159 if (components.size() == 0) {
161 base::File::Info xml_info; 160 base::File::Info xml_info;
162 if (!base::GetFileInfo(GetDataProvider()->library_path(), &xml_info)) 161 if (!base::GetFileInfo(GetDataProvider()->library_path(), &xml_info))
163 return base::PLATFORM_FILE_ERROR_IO; 162 return base::File::FILE_ERROR_IO;
164 file_list->push_back(DirectoryEntry(kITunesLibraryXML, 163 file_list->push_back(DirectoryEntry(kITunesLibraryXML,
165 DirectoryEntry::FILE, 164 DirectoryEntry::FILE,
166 xml_info.size, xml_info.last_modified)); 165 xml_info.size, xml_info.last_modified));
167 file_list->push_back(DirectoryEntry(kITunesMediaDir, 166 file_list->push_back(DirectoryEntry(kITunesMediaDir,
168 DirectoryEntry::DIRECTORY, 167 DirectoryEntry::DIRECTORY,
169 0, base::Time())); 168 0, base::Time()));
170 return base::PLATFORM_FILE_OK; 169 return base::File::FILE_OK;
171 } 170 }
172 171
173 if (components.size() == 1 && components[0] == kITunesLibraryXML) 172 if (components.size() == 1 && components[0] == kITunesLibraryXML)
174 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; 173 return base::File::FILE_ERROR_NOT_A_DIRECTORY;
175 174
176 if (components[0] != kITunesMediaDir || components.size() > 5) 175 if (components[0] != kITunesMediaDir || components.size() > 5)
177 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 176 return base::File::FILE_ERROR_NOT_FOUND;
178 177
179 if (components.size() == 1) { 178 if (components.size() == 1) {
180 if (!GetDataProvider()->auto_add_path().empty()) { 179 if (!GetDataProvider()->auto_add_path().empty()) {
181 file_list->push_back(DirectoryEntry(kITunesAutoAddDir, 180 file_list->push_back(DirectoryEntry(kITunesAutoAddDir,
182 DirectoryEntry::DIRECTORY, 181 DirectoryEntry::DIRECTORY,
183 0, base::Time())); 182 0, base::Time()));
184 } 183 }
185 file_list->push_back(DirectoryEntry(kITunesMusicDir, 184 file_list->push_back(DirectoryEntry(kITunesMusicDir,
186 DirectoryEntry::DIRECTORY, 185 DirectoryEntry::DIRECTORY,
187 0, base::Time())); 186 0, base::Time()));
188 return base::PLATFORM_FILE_OK; 187 return base::File::FILE_OK;
189 } 188 }
190 189
191 if (components[1] == kITunesAutoAddDir && 190 if (components[1] == kITunesAutoAddDir &&
192 !GetDataProvider()->auto_add_path().empty()) { 191 !GetDataProvider()->auto_add_path().empty()) {
193 return NativeMediaFileUtil::ReadDirectorySync(context, url, file_list); 192 return NativeMediaFileUtil::ReadDirectorySync(context, url, file_list);
194 } 193 }
195 194
196 if (components[1] != kITunesMusicDir) 195 if (components[1] != kITunesMusicDir)
197 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 196 return base::File::FILE_ERROR_NOT_FOUND;
198 197
199 if (components.size() == 2) { 198 if (components.size() == 2) {
200 std::set<ITunesDataProvider::ArtistName> artists = 199 std::set<ITunesDataProvider::ArtistName> artists =
201 GetDataProvider()->GetArtistNames(); 200 GetDataProvider()->GetArtistNames();
202 std::set<ITunesDataProvider::ArtistName>::const_iterator it; 201 std::set<ITunesDataProvider::ArtistName>::const_iterator it;
203 for (it = artists.begin(); it != artists.end(); ++it) 202 for (it = artists.begin(); it != artists.end(); ++it)
204 file_list->push_back(DirectoryEntry(*it, DirectoryEntry::DIRECTORY, 203 file_list->push_back(DirectoryEntry(*it, DirectoryEntry::DIRECTORY,
205 0, base::Time())); 204 0, base::Time()));
206 return base::PLATFORM_FILE_OK; 205 return base::File::FILE_OK;
207 } 206 }
208 207
209 if (components.size() == 3) { 208 if (components.size() == 3) {
210 std::set<ITunesDataProvider::AlbumName> albums = 209 std::set<ITunesDataProvider::AlbumName> albums =
211 GetDataProvider()->GetAlbumNames(components[2]); 210 GetDataProvider()->GetAlbumNames(components[2]);
212 if (albums.size() == 0) 211 if (albums.size() == 0)
213 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 212 return base::File::FILE_ERROR_NOT_FOUND;
214 std::set<ITunesDataProvider::AlbumName>::const_iterator it; 213 std::set<ITunesDataProvider::AlbumName>::const_iterator it;
215 for (it = albums.begin(); it != albums.end(); ++it) 214 for (it = albums.begin(); it != albums.end(); ++it)
216 file_list->push_back(DirectoryEntry(*it, DirectoryEntry::DIRECTORY, 215 file_list->push_back(DirectoryEntry(*it, DirectoryEntry::DIRECTORY,
217 0, base::Time())); 216 0, base::Time()));
218 return base::PLATFORM_FILE_OK; 217 return base::File::FILE_OK;
219 } 218 }
220 219
221 if (components.size() == 4) { 220 if (components.size() == 4) {
222 ITunesDataProvider::Album album = 221 ITunesDataProvider::Album album =
223 GetDataProvider()->GetAlbum(components[2], components[3]); 222 GetDataProvider()->GetAlbum(components[2], components[3]);
224 if (album.size() == 0) 223 if (album.size() == 0)
225 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 224 return base::File::FILE_ERROR_NOT_FOUND;
226 ITunesDataProvider::Album::const_iterator it; 225 ITunesDataProvider::Album::const_iterator it;
227 for (it = album.begin(); it != album.end(); ++it) { 226 for (it = album.begin(); it != album.end(); ++it) {
228 base::File::Info file_info; 227 base::File::Info file_info;
229 if (media_path_filter()->Match(it->second) && 228 if (media_path_filter()->Match(it->second) &&
230 base::GetFileInfo(it->second, &file_info)) { 229 base::GetFileInfo(it->second, &file_info)) {
231 file_list->push_back(DirectoryEntry(it->first, DirectoryEntry::FILE, 230 file_list->push_back(DirectoryEntry(it->first, DirectoryEntry::FILE,
232 file_info.size, 231 file_info.size,
233 file_info.last_modified)); 232 file_info.last_modified));
234 } 233 }
235 } 234 }
236 return base::PLATFORM_FILE_OK; 235 return base::File::FILE_OK;
237 } 236 }
238 237
239 // At this point, the only choice is one of two errors, but figuring out 238 // At this point, the only choice is one of two errors, but figuring out
240 // which one is required. 239 // which one is required.
241 DCHECK_EQ(4UL, components.size()); 240 DCHECK_EQ(4UL, components.size());
242 base::FilePath location; 241 base::FilePath location;
243 location = GetDataProvider()->GetTrackLocation(components[1], components[2], 242 location = GetDataProvider()->GetTrackLocation(components[1], components[2],
244 components[3]); 243 components[3]);
245 if (!location.empty()) 244 if (!location.empty())
246 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; 245 return base::File::FILE_ERROR_NOT_A_DIRECTORY;
247 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 246 return base::File::FILE_ERROR_NOT_FOUND;
248 } 247 }
249 248
250 base::PlatformFileError ITunesFileUtil::DeleteDirectorySync( 249 base::File::Error ITunesFileUtil::DeleteDirectorySync(
251 fileapi::FileSystemOperationContext* context, 250 fileapi::FileSystemOperationContext* context,
252 const fileapi::FileSystemURL& url) { 251 const fileapi::FileSystemURL& url) {
253 return base::PLATFORM_FILE_ERROR_SECURITY; 252 return base::File::FILE_ERROR_SECURITY;
254 } 253 }
255 254
256 base::PlatformFileError ITunesFileUtil::DeleteFileSync( 255 base::File::Error ITunesFileUtil::DeleteFileSync(
257 fileapi::FileSystemOperationContext* context, 256 fileapi::FileSystemOperationContext* context,
258 const fileapi::FileSystemURL& url) { 257 const fileapi::FileSystemURL& url) {
259 return base::PLATFORM_FILE_ERROR_SECURITY; 258 return base::File::FILE_ERROR_SECURITY;
260 } 259 }
261 260
262 base::PlatformFileError ITunesFileUtil::CreateSnapshotFileSync( 261 base::File::Error ITunesFileUtil::CreateSnapshotFileSync(
263 fileapi::FileSystemOperationContext* context, 262 fileapi::FileSystemOperationContext* context,
264 const fileapi::FileSystemURL& url, 263 const fileapi::FileSystemURL& url,
265 base::PlatformFileInfo* file_info, 264 base::File::Info* file_info,
266 base::FilePath* platform_path, 265 base::FilePath* platform_path,
267 scoped_refptr<webkit_blob::ShareableFileReference>* file_ref) { 266 scoped_refptr<webkit_blob::ShareableFileReference>* file_ref) {
268 DCHECK(!url.path().IsAbsolute()); 267 DCHECK(!url.path().IsAbsolute());
269 if (url.path() != base::FilePath().AppendASCII(kITunesLibraryXML)) { 268 if (url.path() != base::FilePath().AppendASCII(kITunesLibraryXML)) {
270 return NativeMediaFileUtil::CreateSnapshotFileSync(context, url, file_info, 269 return NativeMediaFileUtil::CreateSnapshotFileSync(context, url, file_info,
271 platform_path, file_ref); 270 platform_path, file_ref);
272 } 271 }
273 272
274 // The following code is different than 273 // The following code is different than
275 // NativeMediaFileUtil::CreateSnapshotFileSync in that it knows that the 274 // NativeMediaFileUtil::CreateSnapshotFileSync in that it knows that the
276 // library xml file is not a directory and it doesn't run mime sniffing on the 275 // library xml file is not a directory and it doesn't run mime sniffing on the
277 // file. The only way to get here is by way of 276 // file. The only way to get here is by way of
278 // CreateSnapshotFileWithFreshDataProvider() so the file has already been 277 // CreateSnapshotFileWithFreshDataProvider() so the file has already been
279 // parsed and deemed valid. 278 // parsed and deemed valid.
280 *file_ref = scoped_refptr<webkit_blob::ShareableFileReference>(); 279 *file_ref = scoped_refptr<webkit_blob::ShareableFileReference>();
281 return GetFileInfoSync(context, url, file_info, platform_path); 280 return GetFileInfoSync(context, url, file_info, platform_path);
282 } 281 }
283 282
284 base::PlatformFileError ITunesFileUtil::GetLocalFilePath( 283 base::File::Error ITunesFileUtil::GetLocalFilePath(
285 fileapi::FileSystemOperationContext* context, 284 fileapi::FileSystemOperationContext* context,
286 const fileapi::FileSystemURL& url, 285 const fileapi::FileSystemURL& url,
287 base::FilePath* local_file_path) { 286 base::FilePath* local_file_path) {
288 std::vector<std::string> components; 287 std::vector<std::string> components;
289 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); 288 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components);
290 289
291 if (components.size() == 1 && components[0] == kITunesLibraryXML) { 290 if (components.size() == 1 && components[0] == kITunesLibraryXML) {
292 *local_file_path = GetDataProvider()->library_path(); 291 *local_file_path = GetDataProvider()->library_path();
293 return base::PLATFORM_FILE_OK; 292 return base::File::FILE_OK;
294 } 293 }
295 294
296 if (components.size() >= 2 && components[0] == kITunesMediaDir && 295 if (components.size() >= 2 && components[0] == kITunesMediaDir &&
297 components[1] == kITunesAutoAddDir) { 296 components[1] == kITunesAutoAddDir) {
298 *local_file_path = GetDataProvider()->auto_add_path(); 297 *local_file_path = GetDataProvider()->auto_add_path();
299 if (local_file_path->empty()) 298 if (local_file_path->empty())
300 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 299 return base::File::FILE_ERROR_NOT_FOUND;
301 300
302 for (size_t i = 2; i < components.size(); ++i) { 301 for (size_t i = 2; i < components.size(); ++i) {
303 *local_file_path = local_file_path->Append( 302 *local_file_path = local_file_path->Append(
304 base::FilePath::FromUTF8Unsafe(components[i])); 303 base::FilePath::FromUTF8Unsafe(components[i]));
305 } 304 }
306 return base::PLATFORM_FILE_OK; 305 return base::File::FILE_OK;
307 } 306 }
308 307
309 // Should only get here for files, i.e. the xml file and tracks. 308 // Should only get here for files, i.e. the xml file and tracks.
310 if (components[0] != kITunesMediaDir || components[1] != kITunesMusicDir|| 309 if (components[0] != kITunesMediaDir || components[1] != kITunesMusicDir||
311 components.size() != 5) { 310 components.size() != 5) {
312 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 311 return base::File::FILE_ERROR_NOT_FOUND;
313 } 312 }
314 313
315 *local_file_path = GetDataProvider()->GetTrackLocation(components[2], 314 *local_file_path = GetDataProvider()->GetTrackLocation(components[2],
316 components[3], 315 components[3],
317 components[4]); 316 components[4]);
318 if (!local_file_path->empty()) 317 if (!local_file_path->empty())
319 return base::PLATFORM_FILE_OK; 318 return base::File::FILE_OK;
320 319
321 return base::PLATFORM_FILE_ERROR_NOT_FOUND; 320 return base::File::FILE_ERROR_NOT_FOUND;
322 } 321 }
323 322
324 void ITunesFileUtil::GetFileInfoWithFreshDataProvider( 323 void ITunesFileUtil::GetFileInfoWithFreshDataProvider(
325 scoped_ptr<fileapi::FileSystemOperationContext> context, 324 scoped_ptr<fileapi::FileSystemOperationContext> context,
326 const fileapi::FileSystemURL& url, 325 const fileapi::FileSystemURL& url,
327 const GetFileInfoCallback& callback, 326 const GetFileInfoCallback& callback,
328 bool valid_parse) { 327 bool valid_parse) {
329 if (!valid_parse) { 328 if (!valid_parse) {
330 if (!callback.is_null()) { 329 if (!callback.is_null()) {
331 content::BrowserThread::PostTask( 330 content::BrowserThread::PostTask(
332 content::BrowserThread::IO, 331 content::BrowserThread::IO,
333 FROM_HERE, 332 FROM_HERE,
334 base::Bind(callback, base::PLATFORM_FILE_ERROR_IO, 333 base::Bind(callback, base::File::FILE_ERROR_IO,
335 base::PlatformFileInfo())); 334 base::File::Info()));
336 } 335 }
337 return; 336 return;
338 } 337 }
339 NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread(context.Pass(), url, 338 NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread(context.Pass(), url,
340 callback); 339 callback);
341 } 340 }
342 341
343 void ITunesFileUtil::ReadDirectoryWithFreshDataProvider( 342 void ITunesFileUtil::ReadDirectoryWithFreshDataProvider(
344 scoped_ptr<fileapi::FileSystemOperationContext> context, 343 scoped_ptr<fileapi::FileSystemOperationContext> context,
345 const fileapi::FileSystemURL& url, 344 const fileapi::FileSystemURL& url,
346 const ReadDirectoryCallback& callback, 345 const ReadDirectoryCallback& callback,
347 bool valid_parse) { 346 bool valid_parse) {
348 if (!valid_parse) { 347 if (!valid_parse) {
349 if (!callback.is_null()) { 348 if (!callback.is_null()) {
350 content::BrowserThread::PostTask( 349 content::BrowserThread::PostTask(
351 content::BrowserThread::IO, 350 content::BrowserThread::IO,
352 FROM_HERE, 351 FROM_HERE,
353 base::Bind(callback, base::PLATFORM_FILE_ERROR_IO, EntryList(), 352 base::Bind(callback, base::File::FILE_ERROR_IO, EntryList(), false));
354 false));
355 } 353 }
356 return; 354 return;
357 } 355 }
358 NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread(context.Pass(), url, 356 NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread(context.Pass(), url,
359 callback); 357 callback);
360 } 358 }
361 359
362 void ITunesFileUtil::CreateSnapshotFileWithFreshDataProvider( 360 void ITunesFileUtil::CreateSnapshotFileWithFreshDataProvider(
363 scoped_ptr<fileapi::FileSystemOperationContext> context, 361 scoped_ptr<fileapi::FileSystemOperationContext> context,
364 const fileapi::FileSystemURL& url, 362 const fileapi::FileSystemURL& url,
365 const CreateSnapshotFileCallback& callback, 363 const CreateSnapshotFileCallback& callback,
366 bool valid_parse) { 364 bool valid_parse) {
367 if (!valid_parse) { 365 if (!valid_parse) {
368 if (!callback.is_null()) { 366 if (!callback.is_null()) {
369 base::PlatformFileInfo file_info; 367 base::File::Info file_info;
370 base::FilePath platform_path; 368 base::FilePath platform_path;
371 scoped_refptr<webkit_blob::ShareableFileReference> file_ref; 369 scoped_refptr<webkit_blob::ShareableFileReference> file_ref;
372 content::BrowserThread::PostTask( 370 content::BrowserThread::PostTask(
373 content::BrowserThread::IO, 371 content::BrowserThread::IO,
374 FROM_HERE, 372 FROM_HERE,
375 base::Bind(callback, base::PLATFORM_FILE_ERROR_IO, file_info, 373 base::Bind(callback, base::File::FILE_ERROR_IO, file_info,
376 platform_path, file_ref)); 374 platform_path, file_ref));
377 } 375 }
378 return; 376 return;
379 } 377 }
380 NativeMediaFileUtil::CreateSnapshotFileOnTaskRunnerThread(context.Pass(), url, 378 NativeMediaFileUtil::CreateSnapshotFileOnTaskRunnerThread(context.Pass(), url,
381 callback); 379 callback);
382 } 380 }
383 381
384 ITunesDataProvider* ITunesFileUtil::GetDataProvider() { 382 ITunesDataProvider* ITunesFileUtil::GetDataProvider() {
385 if (!imported_registry_) 383 if (!imported_registry_)
386 imported_registry_ = ImportedMediaGalleryRegistry::GetInstance(); 384 imported_registry_ = ImportedMediaGalleryRegistry::GetInstance();
387 return imported_registry_->ITunesDataProvider(); 385 return imported_registry_->ITunesDataProvider();
388 } 386 }
389 387
390 } // namespace itunes 388 } // namespace itunes
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698