| 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/picasa_file_util.h" | 5 #include "chrome/browser/media_galleries/fileapi/picasa_file_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 using base::FilePath; | 26 using base::FilePath; |
| 27 using fileapi::DirectoryEntry; | 27 using fileapi::DirectoryEntry; |
| 28 using fileapi::FileSystemOperationContext; | 28 using fileapi::FileSystemOperationContext; |
| 29 using fileapi::FileSystemURL; | 29 using fileapi::FileSystemURL; |
| 30 | 30 |
| 31 namespace picasa { | 31 namespace picasa { |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 base::PlatformFileError FindAlbumInfo(const std::string& key, | 35 base::File::Error FindAlbumInfo(const std::string& key, |
| 36 const AlbumMap* map, | 36 const AlbumMap* map, |
| 37 AlbumInfo* album_info) { | 37 AlbumInfo* album_info) { |
| 38 if (!map) | 38 if (!map) |
| 39 return base::PLATFORM_FILE_ERROR_FAILED; | 39 return base::File::FILE_ERROR_FAILED; |
| 40 | 40 |
| 41 AlbumMap::const_iterator it = map->find(key); | 41 AlbumMap::const_iterator it = map->find(key); |
| 42 | 42 |
| 43 if (it == map->end()) | 43 if (it == map->end()) |
| 44 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 44 return base::File::FILE_ERROR_NOT_FOUND; |
| 45 | 45 |
| 46 if (album_info != NULL) | 46 if (album_info != NULL) |
| 47 *album_info = it->second; | 47 *album_info = it->second; |
| 48 | 48 |
| 49 return base::PLATFORM_FILE_OK; | 49 return base::File::FILE_OK; |
| 50 } | 50 } |
| 51 | 51 |
| 52 PicasaDataProvider::DataType GetDataTypeForURL( | 52 PicasaDataProvider::DataType GetDataTypeForURL( |
| 53 const fileapi::FileSystemURL& url) { | 53 const fileapi::FileSystemURL& url) { |
| 54 std::vector<std::string> components; | 54 std::vector<std::string> components; |
| 55 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); | 55 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); |
| 56 | 56 |
| 57 if (components.size() >= 2 && components[0] == kPicasaDirAlbums) | 57 if (components.size() >= 2 && components[0] == kPicasaDirAlbums) |
| 58 return PicasaDataProvider::ALBUMS_IMAGES_DATA; | 58 return PicasaDataProvider::ALBUMS_IMAGES_DATA; |
| 59 | 59 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 const ReadDirectoryCallback& callback) { | 91 const ReadDirectoryCallback& callback) { |
| 92 GetDataProvider()->RefreshData( | 92 GetDataProvider()->RefreshData( |
| 93 GetDataTypeForURL(url), | 93 GetDataTypeForURL(url), |
| 94 base::Bind(&PicasaFileUtil::ReadDirectoryWithFreshDataProvider, | 94 base::Bind(&PicasaFileUtil::ReadDirectoryWithFreshDataProvider, |
| 95 weak_factory_.GetWeakPtr(), | 95 weak_factory_.GetWeakPtr(), |
| 96 base::Passed(&context), | 96 base::Passed(&context), |
| 97 url, | 97 url, |
| 98 callback)); | 98 callback)); |
| 99 } | 99 } |
| 100 | 100 |
| 101 base::PlatformFileError PicasaFileUtil::GetFileInfoSync( | 101 base::File::Error PicasaFileUtil::GetFileInfoSync( |
| 102 FileSystemOperationContext* context, const FileSystemURL& url, | 102 FileSystemOperationContext* context, const FileSystemURL& url, |
| 103 base::PlatformFileInfo* file_info, base::FilePath* platform_path) { | 103 base::File::Info* file_info, base::FilePath* platform_path) { |
| 104 DCHECK(context); | 104 DCHECK(context); |
| 105 DCHECK(file_info); | 105 DCHECK(file_info); |
| 106 | 106 |
| 107 if (platform_path) | 107 if (platform_path) |
| 108 *platform_path = base::FilePath(); | 108 *platform_path = base::FilePath(); |
| 109 | 109 |
| 110 std::vector<std::string> components; | 110 std::vector<std::string> components; |
| 111 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); | 111 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); |
| 112 | 112 |
| 113 switch (components.size()) { | 113 switch (components.size()) { |
| 114 case 0: | 114 case 0: |
| 115 // Root directory. | 115 // Root directory. |
| 116 file_info->is_directory = true; | 116 file_info->is_directory = true; |
| 117 return base::PLATFORM_FILE_OK; | 117 return base::File::FILE_OK; |
| 118 case 1: | 118 case 1: |
| 119 if (components[0] == kPicasaDirAlbums || | 119 if (components[0] == kPicasaDirAlbums || |
| 120 components[0] == kPicasaDirFolders) { | 120 components[0] == kPicasaDirFolders) { |
| 121 file_info->is_directory = true; | 121 file_info->is_directory = true; |
| 122 return base::PLATFORM_FILE_OK; | 122 return base::File::FILE_OK; |
| 123 } | 123 } |
| 124 | 124 |
| 125 break; | 125 break; |
| 126 case 2: | 126 case 2: |
| 127 if (components[0] == kPicasaDirAlbums) { | 127 if (components[0] == kPicasaDirAlbums) { |
| 128 scoped_ptr<AlbumMap> album_map = GetDataProvider()->GetAlbums(); | 128 scoped_ptr<AlbumMap> album_map = GetDataProvider()->GetAlbums(); |
| 129 base::PlatformFileError error = | 129 base::File::Error error = |
| 130 FindAlbumInfo(components[1], album_map.get(), NULL); | 130 FindAlbumInfo(components[1], album_map.get(), NULL); |
| 131 if (error != base::PLATFORM_FILE_OK) | 131 if (error != base::File::FILE_OK) |
| 132 return error; | 132 return error; |
| 133 | 133 |
| 134 file_info->is_directory = true; | 134 file_info->is_directory = true; |
| 135 return base::PLATFORM_FILE_OK; | 135 return base::File::FILE_OK; |
| 136 } | 136 } |
| 137 | 137 |
| 138 if (components[0] == kPicasaDirFolders) { | 138 if (components[0] == kPicasaDirFolders) { |
| 139 return NativeMediaFileUtil::GetFileInfoSync(context, url, file_info, | 139 return NativeMediaFileUtil::GetFileInfoSync(context, url, file_info, |
| 140 platform_path); | 140 platform_path); |
| 141 } | 141 } |
| 142 break; | 142 break; |
| 143 case 3: | 143 case 3: |
| 144 // NativeMediaFileUtil::GetInfo calls into virtual function | 144 // NativeMediaFileUtil::GetInfo calls into virtual function |
| 145 // PicasaFileUtil::GetLocalFilePath, and that will handle both | 145 // PicasaFileUtil::GetLocalFilePath, and that will handle both |
| 146 // album contents and folder contents. | 146 // album contents and folder contents. |
| 147 base::PlatformFileError result = NativeMediaFileUtil::GetFileInfoSync( | 147 base::File::Error result = NativeMediaFileUtil::GetFileInfoSync( |
| 148 context, url, file_info, platform_path); | 148 context, url, file_info, platform_path); |
| 149 | 149 |
| 150 DCHECK(components[0] == kPicasaDirAlbums || | 150 DCHECK(components[0] == kPicasaDirAlbums || |
| 151 components[0] == kPicasaDirFolders || | 151 components[0] == kPicasaDirFolders || |
| 152 result == base::PLATFORM_FILE_ERROR_NOT_FOUND); | 152 result == base::File::FILE_ERROR_NOT_FOUND); |
| 153 | 153 |
| 154 return result; | 154 return result; |
| 155 } | 155 } |
| 156 | 156 |
| 157 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 157 return base::File::FILE_ERROR_NOT_FOUND; |
| 158 } | 158 } |
| 159 | 159 |
| 160 base::PlatformFileError PicasaFileUtil::ReadDirectorySync( | 160 base::File::Error PicasaFileUtil::ReadDirectorySync( |
| 161 fileapi::FileSystemOperationContext* context, | 161 fileapi::FileSystemOperationContext* context, |
| 162 const fileapi::FileSystemURL& url, | 162 const fileapi::FileSystemURL& url, |
| 163 EntryList* file_list) { | 163 EntryList* file_list) { |
| 164 DCHECK(context); | 164 DCHECK(context); |
| 165 DCHECK(file_list); | 165 DCHECK(file_list); |
| 166 DCHECK(file_list->empty()); | 166 DCHECK(file_list->empty()); |
| 167 | 167 |
| 168 base::PlatformFileInfo file_info; | 168 base::File::Info file_info; |
| 169 base::FilePath platform_directory_path; | 169 base::FilePath platform_directory_path; |
| 170 base::PlatformFileError error = GetFileInfoSync( | 170 base::File::Error error = GetFileInfoSync( |
| 171 context, url, &file_info, &platform_directory_path); | 171 context, url, &file_info, &platform_directory_path); |
| 172 | 172 |
| 173 if (error != base::PLATFORM_FILE_OK) | 173 if (error != base::File::FILE_OK) |
| 174 return error; | 174 return error; |
| 175 | 175 |
| 176 if (!file_info.is_directory) | 176 if (!file_info.is_directory) |
| 177 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; | 177 return base::File::FILE_ERROR_NOT_A_DIRECTORY; |
| 178 | 178 |
| 179 std::vector<std::string> components; | 179 std::vector<std::string> components; |
| 180 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); | 180 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); |
| 181 | 181 |
| 182 switch (components.size()) { | 182 switch (components.size()) { |
| 183 case 0: { | 183 case 0: { |
| 184 // Root directory. | 184 // Root directory. |
| 185 file_list->push_back( | 185 file_list->push_back( |
| 186 DirectoryEntry(kPicasaDirAlbums, DirectoryEntry::DIRECTORY, 0, | 186 DirectoryEntry(kPicasaDirAlbums, DirectoryEntry::DIRECTORY, 0, |
| 187 base::Time())); | 187 base::Time())); |
| 188 file_list->push_back( | 188 file_list->push_back( |
| 189 DirectoryEntry(kPicasaDirFolders, DirectoryEntry::DIRECTORY, 0, | 189 DirectoryEntry(kPicasaDirFolders, DirectoryEntry::DIRECTORY, 0, |
| 190 base::Time())); | 190 base::Time())); |
| 191 break; | 191 break; |
| 192 } | 192 } |
| 193 case 1: | 193 case 1: |
| 194 if (components[0] == kPicasaDirAlbums) { | 194 if (components[0] == kPicasaDirAlbums) { |
| 195 scoped_ptr<AlbumMap> albums = GetDataProvider()->GetAlbums(); | 195 scoped_ptr<AlbumMap> albums = GetDataProvider()->GetAlbums(); |
| 196 if (!albums) | 196 if (!albums) |
| 197 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 197 return base::File::FILE_ERROR_NOT_FOUND; |
| 198 | 198 |
| 199 for (AlbumMap::const_iterator it = albums->begin(); | 199 for (AlbumMap::const_iterator it = albums->begin(); |
| 200 it != albums->end(); ++it) { | 200 it != albums->end(); ++it) { |
| 201 file_list->push_back( | 201 file_list->push_back( |
| 202 DirectoryEntry(it->first, DirectoryEntry::DIRECTORY, 0, | 202 DirectoryEntry(it->first, DirectoryEntry::DIRECTORY, 0, |
| 203 it->second.timestamp)); | 203 it->second.timestamp)); |
| 204 } | 204 } |
| 205 } else if (components[0] == kPicasaDirFolders) { | 205 } else if (components[0] == kPicasaDirFolders) { |
| 206 scoped_ptr<AlbumMap> folders = GetDataProvider()->GetFolders(); | 206 scoped_ptr<AlbumMap> folders = GetDataProvider()->GetFolders(); |
| 207 if (!folders) | 207 if (!folders) |
| 208 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 208 return base::File::FILE_ERROR_NOT_FOUND; |
| 209 | 209 |
| 210 for (AlbumMap::const_iterator it = folders->begin(); | 210 for (AlbumMap::const_iterator it = folders->begin(); |
| 211 it != folders->end(); ++it) { | 211 it != folders->end(); ++it) { |
| 212 file_list->push_back( | 212 file_list->push_back( |
| 213 DirectoryEntry(it->first, DirectoryEntry::DIRECTORY, 0, | 213 DirectoryEntry(it->first, DirectoryEntry::DIRECTORY, 0, |
| 214 it->second.timestamp)); | 214 it->second.timestamp)); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 break; | 217 break; |
| 218 case 2: | 218 case 2: |
| 219 if (components[0] == kPicasaDirAlbums) { | 219 if (components[0] == kPicasaDirAlbums) { |
| 220 scoped_ptr<AlbumMap> album_map = GetDataProvider()->GetAlbums(); | 220 scoped_ptr<AlbumMap> album_map = GetDataProvider()->GetAlbums(); |
| 221 AlbumInfo album_info; | 221 AlbumInfo album_info; |
| 222 base::PlatformFileError error = | 222 base::File::Error error = |
| 223 FindAlbumInfo(components[1], album_map.get(), &album_info); | 223 FindAlbumInfo(components[1], album_map.get(), &album_info); |
| 224 if (error != base::PLATFORM_FILE_OK) | 224 if (error != base::File::FILE_OK) |
| 225 return error; | 225 return error; |
| 226 | 226 |
| 227 scoped_ptr<AlbumImages> album_images = | 227 scoped_ptr<AlbumImages> album_images = |
| 228 GetDataProvider()->FindAlbumImages(album_info.uid, &error); | 228 GetDataProvider()->FindAlbumImages(album_info.uid, &error); |
| 229 if (error != base::PLATFORM_FILE_OK) | 229 if (error != base::File::FILE_OK) |
| 230 return error; | 230 return error; |
| 231 | 231 |
| 232 for (AlbumImages::const_iterator it = album_images->begin(); | 232 for (AlbumImages::const_iterator it = album_images->begin(); |
| 233 it != album_images->end(); | 233 it != album_images->end(); |
| 234 ++it) { | 234 ++it) { |
| 235 fileapi::DirectoryEntry entry; | 235 fileapi::DirectoryEntry entry; |
| 236 base::PlatformFileInfo info; | 236 base::File::Info info; |
| 237 | 237 |
| 238 // Simply skip files that we can't get info on. | 238 // Simply skip files that we can't get info on. |
| 239 if (fileapi::NativeFileUtil::GetFileInfo(it->second, &info) != | 239 if (fileapi::NativeFileUtil::GetFileInfo(it->second, &info) != |
| 240 base::PLATFORM_FILE_OK) { | 240 base::File::FILE_OK) { |
| 241 continue; | 241 continue; |
| 242 } | 242 } |
| 243 | 243 |
| 244 file_list->push_back(DirectoryEntry( | 244 file_list->push_back(DirectoryEntry( |
| 245 it->first, DirectoryEntry::FILE, info.size, info.last_modified)); | 245 it->first, DirectoryEntry::FILE, info.size, info.last_modified)); |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 | 248 |
| 249 if (components[0] == kPicasaDirFolders) { | 249 if (components[0] == kPicasaDirFolders) { |
| 250 EntryList super_list; | 250 EntryList super_list; |
| 251 base::PlatformFileError error = | 251 base::File::Error error = |
| 252 NativeMediaFileUtil::ReadDirectorySync(context, url, &super_list); | 252 NativeMediaFileUtil::ReadDirectorySync(context, url, &super_list); |
| 253 if (error != base::PLATFORM_FILE_OK) | 253 if (error != base::File::FILE_OK) |
| 254 return error; | 254 return error; |
| 255 | 255 |
| 256 for (EntryList::const_iterator it = super_list.begin(); | 256 for (EntryList::const_iterator it = super_list.begin(); |
| 257 it != super_list.end(); ++it) { | 257 it != super_list.end(); ++it) { |
| 258 if (!it->is_directory) | 258 if (!it->is_directory) |
| 259 file_list->push_back(*it); | 259 file_list->push_back(*it); |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 | 262 |
| 263 break; | 263 break; |
| 264 } | 264 } |
| 265 | 265 |
| 266 return base::PLATFORM_FILE_OK; | 266 return base::File::FILE_OK; |
| 267 } | 267 } |
| 268 | 268 |
| 269 base::PlatformFileError PicasaFileUtil::DeleteDirectorySync( | 269 base::File::Error PicasaFileUtil::DeleteDirectorySync( |
| 270 fileapi::FileSystemOperationContext* context, | 270 fileapi::FileSystemOperationContext* context, |
| 271 const fileapi::FileSystemURL& url) { | 271 const fileapi::FileSystemURL& url) { |
| 272 return base::PLATFORM_FILE_ERROR_SECURITY; | 272 return base::File::FILE_ERROR_SECURITY; |
| 273 } | 273 } |
| 274 | 274 |
| 275 base::PlatformFileError PicasaFileUtil::DeleteFileSync( | 275 base::File::Error PicasaFileUtil::DeleteFileSync( |
| 276 fileapi::FileSystemOperationContext* context, | 276 fileapi::FileSystemOperationContext* context, |
| 277 const fileapi::FileSystemURL& url) { | 277 const fileapi::FileSystemURL& url) { |
| 278 return base::PLATFORM_FILE_ERROR_SECURITY; | 278 return base::File::FILE_ERROR_SECURITY; |
| 279 } | 279 } |
| 280 | 280 |
| 281 base::PlatformFileError PicasaFileUtil::GetLocalFilePath( | 281 base::File::Error PicasaFileUtil::GetLocalFilePath( |
| 282 FileSystemOperationContext* context, const FileSystemURL& url, | 282 FileSystemOperationContext* context, const FileSystemURL& url, |
| 283 base::FilePath* local_file_path) { | 283 base::FilePath* local_file_path) { |
| 284 DCHECK(local_file_path); | 284 DCHECK(local_file_path); |
| 285 DCHECK(url.is_valid()); | 285 DCHECK(url.is_valid()); |
| 286 std::vector<std::string> components; | 286 std::vector<std::string> components; |
| 287 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); | 287 fileapi::VirtualPath::GetComponentsUTF8Unsafe(url.path(), &components); |
| 288 | 288 |
| 289 switch (components.size()) { | 289 switch (components.size()) { |
| 290 case 2: | 290 case 2: |
| 291 if (components[0] == kPicasaDirFolders) { | 291 if (components[0] == kPicasaDirFolders) { |
| 292 scoped_ptr<AlbumMap> album_map = GetDataProvider()->GetFolders(); | 292 scoped_ptr<AlbumMap> album_map = GetDataProvider()->GetFolders(); |
| 293 AlbumInfo album_info; | 293 AlbumInfo album_info; |
| 294 base::PlatformFileError error = | 294 base::File::Error error = |
| 295 FindAlbumInfo(components[1], album_map.get(), &album_info); | 295 FindAlbumInfo(components[1], album_map.get(), &album_info); |
| 296 if (error != base::PLATFORM_FILE_OK) | 296 if (error != base::File::FILE_OK) |
| 297 return error; | 297 return error; |
| 298 | 298 |
| 299 *local_file_path = album_info.path; | 299 *local_file_path = album_info.path; |
| 300 return base::PLATFORM_FILE_OK; | 300 return base::File::FILE_OK; |
| 301 } | 301 } |
| 302 break; | 302 break; |
| 303 case 3: | 303 case 3: |
| 304 if (components[0] == kPicasaDirAlbums) { | 304 if (components[0] == kPicasaDirAlbums) { |
| 305 scoped_ptr<AlbumMap> album_map = GetDataProvider()->GetAlbums(); | 305 scoped_ptr<AlbumMap> album_map = GetDataProvider()->GetAlbums(); |
| 306 AlbumInfo album_info; | 306 AlbumInfo album_info; |
| 307 base::PlatformFileError error = | 307 base::File::Error error = |
| 308 FindAlbumInfo(components[1], album_map.get(), &album_info); | 308 FindAlbumInfo(components[1], album_map.get(), &album_info); |
| 309 if (error != base::PLATFORM_FILE_OK) | 309 if (error != base::File::FILE_OK) |
| 310 return error; | 310 return error; |
| 311 | 311 |
| 312 scoped_ptr<AlbumImages> album_images = | 312 scoped_ptr<AlbumImages> album_images = |
| 313 GetDataProvider()->FindAlbumImages(album_info.uid, &error); | 313 GetDataProvider()->FindAlbumImages(album_info.uid, &error); |
| 314 if (error != base::PLATFORM_FILE_OK) | 314 if (error != base::File::FILE_OK) |
| 315 return error; | 315 return error; |
| 316 | 316 |
| 317 AlbumImages::const_iterator it = album_images->find(components[2]); | 317 AlbumImages::const_iterator it = album_images->find(components[2]); |
| 318 if (it == album_images->end()) | 318 if (it == album_images->end()) |
| 319 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 319 return base::File::FILE_ERROR_NOT_FOUND; |
| 320 | 320 |
| 321 *local_file_path = it->second; | 321 *local_file_path = it->second; |
| 322 return base::PLATFORM_FILE_OK; | 322 return base::File::FILE_OK; |
| 323 } | 323 } |
| 324 | 324 |
| 325 if (components[0] == kPicasaDirFolders) { | 325 if (components[0] == kPicasaDirFolders) { |
| 326 scoped_ptr<AlbumMap> album_map = GetDataProvider()->GetFolders(); | 326 scoped_ptr<AlbumMap> album_map = GetDataProvider()->GetFolders(); |
| 327 AlbumInfo album_info; | 327 AlbumInfo album_info; |
| 328 base::PlatformFileError error = | 328 base::File::Error error = |
| 329 FindAlbumInfo(components[1], album_map.get(), &album_info); | 329 FindAlbumInfo(components[1], album_map.get(), &album_info); |
| 330 if (error != base::PLATFORM_FILE_OK) | 330 if (error != base::File::FILE_OK) |
| 331 return error; | 331 return error; |
| 332 | 332 |
| 333 // Not part of this class's mandate to check that it actually exists. | 333 // Not part of this class's mandate to check that it actually exists. |
| 334 *local_file_path = album_info.path.Append(url.path().BaseName()); | 334 *local_file_path = album_info.path.Append(url.path().BaseName()); |
| 335 return base::PLATFORM_FILE_OK; | 335 return base::File::FILE_OK; |
| 336 } | 336 } |
| 337 | 337 |
| 338 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 338 return base::File::FILE_ERROR_NOT_FOUND; |
| 339 break; | 339 break; |
| 340 } | 340 } |
| 341 | 341 |
| 342 // All other cases don't have a local path. The valid cases should be | 342 // All other cases don't have a local path. The valid cases should be |
| 343 // intercepted by GetFileInfo()/CreateFileEnumerator(). Invalid cases | 343 // intercepted by GetFileInfo()/CreateFileEnumerator(). Invalid cases |
| 344 // return a NOT_FOUND error. | 344 // return a NOT_FOUND error. |
| 345 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 345 return base::File::FILE_ERROR_NOT_FOUND; |
| 346 } | 346 } |
| 347 | 347 |
| 348 void PicasaFileUtil::GetFileInfoWithFreshDataProvider( | 348 void PicasaFileUtil::GetFileInfoWithFreshDataProvider( |
| 349 scoped_ptr<fileapi::FileSystemOperationContext> context, | 349 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 350 const fileapi::FileSystemURL& url, | 350 const fileapi::FileSystemURL& url, |
| 351 const GetFileInfoCallback& callback, | 351 const GetFileInfoCallback& callback, |
| 352 bool success) { | 352 bool success) { |
| 353 if (!success) { | 353 if (!success) { |
| 354 content::BrowserThread::PostTask( | 354 content::BrowserThread::PostTask( |
| 355 content::BrowserThread::IO, | 355 content::BrowserThread::IO, |
| 356 FROM_HERE, | 356 FROM_HERE, |
| 357 base::Bind( | 357 base::Bind(callback, base::File::FILE_ERROR_IO, base::File::Info())); |
| 358 callback, base::PLATFORM_FILE_ERROR_IO, base::PlatformFileInfo())); | |
| 359 return; | 358 return; |
| 360 } | 359 } |
| 361 NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread( | 360 NativeMediaFileUtil::GetFileInfoOnTaskRunnerThread( |
| 362 context.Pass(), url, callback); | 361 context.Pass(), url, callback); |
| 363 } | 362 } |
| 364 | 363 |
| 365 void PicasaFileUtil::ReadDirectoryWithFreshDataProvider( | 364 void PicasaFileUtil::ReadDirectoryWithFreshDataProvider( |
| 366 scoped_ptr<fileapi::FileSystemOperationContext> context, | 365 scoped_ptr<fileapi::FileSystemOperationContext> context, |
| 367 const fileapi::FileSystemURL& url, | 366 const fileapi::FileSystemURL& url, |
| 368 const ReadDirectoryCallback& callback, | 367 const ReadDirectoryCallback& callback, |
| 369 bool success) { | 368 bool success) { |
| 370 if (!success) { | 369 if (!success) { |
| 371 content::BrowserThread::PostTask( | 370 content::BrowserThread::PostTask( |
| 372 content::BrowserThread::IO, | 371 content::BrowserThread::IO, |
| 373 FROM_HERE, | 372 FROM_HERE, |
| 374 base::Bind(callback, base::PLATFORM_FILE_ERROR_IO, EntryList(), false)); | 373 base::Bind(callback, base::File::FILE_ERROR_IO, EntryList(), false)); |
| 375 return; | 374 return; |
| 376 } | 375 } |
| 377 NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread( | 376 NativeMediaFileUtil::ReadDirectoryOnTaskRunnerThread( |
| 378 context.Pass(), url, callback); | 377 context.Pass(), url, callback); |
| 379 } | 378 } |
| 380 | 379 |
| 381 PicasaDataProvider* PicasaFileUtil::GetDataProvider() { | 380 PicasaDataProvider* PicasaFileUtil::GetDataProvider() { |
| 382 return ImportedMediaGalleryRegistry::PicasaDataProvider(); | 381 return ImportedMediaGalleryRegistry::PicasaDataProvider(); |
| 383 } | 382 } |
| 384 | 383 |
| 385 } // namespace picasa | 384 } // namespace picasa |
| OLD | NEW |