OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/common/fileapi/file_system_util.h" | 5 #include "webkit/common/fileapi/file_system_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 } | 277 } |
278 | 278 |
279 base::FilePath StringToFilePath(const std::string& file_path_string) { | 279 base::FilePath StringToFilePath(const std::string& file_path_string) { |
280 #if defined(OS_WIN) | 280 #if defined(OS_WIN) |
281 return base::FilePath(base::UTF8ToUTF16(file_path_string)); | 281 return base::FilePath(base::UTF8ToUTF16(file_path_string)); |
282 #elif defined(OS_POSIX) | 282 #elif defined(OS_POSIX) |
283 return base::FilePath(file_path_string); | 283 return base::FilePath(file_path_string); |
284 #endif | 284 #endif |
285 } | 285 } |
286 | 286 |
287 blink::WebFileError PlatformFileErrorToWebFileError( | 287 blink::WebFileError FileErrorToWebFileError( |
288 base::PlatformFileError error_code) { | 288 base::File::Error error_code) { |
289 switch (error_code) { | 289 switch (error_code) { |
290 case base::PLATFORM_FILE_ERROR_NOT_FOUND: | 290 case base::File::FILE_ERROR_NOT_FOUND: |
291 return blink::WebFileErrorNotFound; | 291 return blink::WebFileErrorNotFound; |
292 case base::PLATFORM_FILE_ERROR_INVALID_OPERATION: | 292 case base::File::FILE_ERROR_INVALID_OPERATION: |
293 case base::PLATFORM_FILE_ERROR_EXISTS: | 293 case base::File::FILE_ERROR_EXISTS: |
294 case base::PLATFORM_FILE_ERROR_NOT_EMPTY: | 294 case base::File::FILE_ERROR_NOT_EMPTY: |
295 return blink::WebFileErrorInvalidModification; | 295 return blink::WebFileErrorInvalidModification; |
296 case base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY: | 296 case base::File::FILE_ERROR_NOT_A_DIRECTORY: |
297 case base::PLATFORM_FILE_ERROR_NOT_A_FILE: | 297 case base::File::FILE_ERROR_NOT_A_FILE: |
298 return blink::WebFileErrorTypeMismatch; | 298 return blink::WebFileErrorTypeMismatch; |
299 case base::PLATFORM_FILE_ERROR_ACCESS_DENIED: | 299 case base::File::FILE_ERROR_ACCESS_DENIED: |
300 return blink::WebFileErrorNoModificationAllowed; | 300 return blink::WebFileErrorNoModificationAllowed; |
301 case base::PLATFORM_FILE_ERROR_FAILED: | 301 case base::File::FILE_ERROR_FAILED: |
302 return blink::WebFileErrorInvalidState; | 302 return blink::WebFileErrorInvalidState; |
303 case base::PLATFORM_FILE_ERROR_ABORT: | 303 case base::File::FILE_ERROR_ABORT: |
304 return blink::WebFileErrorAbort; | 304 return blink::WebFileErrorAbort; |
305 case base::PLATFORM_FILE_ERROR_SECURITY: | 305 case base::File::FILE_ERROR_SECURITY: |
306 return blink::WebFileErrorSecurity; | 306 return blink::WebFileErrorSecurity; |
307 case base::PLATFORM_FILE_ERROR_NO_SPACE: | 307 case base::File::FILE_ERROR_NO_SPACE: |
308 return blink::WebFileErrorQuotaExceeded; | 308 return blink::WebFileErrorQuotaExceeded; |
309 case base::PLATFORM_FILE_ERROR_INVALID_URL: | 309 case base::File::FILE_ERROR_INVALID_URL: |
310 return blink::WebFileErrorEncoding; | 310 return blink::WebFileErrorEncoding; |
311 default: | 311 default: |
312 return blink::WebFileErrorInvalidModification; | 312 return blink::WebFileErrorInvalidModification; |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 bool GetFileSystemPublicType( | 316 bool GetFileSystemPublicType( |
317 const std::string type_string, | 317 const std::string type_string, |
318 blink::WebFileSystemType* type) { | 318 blink::WebFileSystemType* type) { |
319 DCHECK(type); | 319 DCHECK(type); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 const std::string& mount_name) { | 406 const std::string& mount_name) { |
407 std::string root = GetFileSystemRootURI(origin_url, | 407 std::string root = GetFileSystemRootURI(origin_url, |
408 kFileSystemTypeExternal).spec(); | 408 kFileSystemTypeExternal).spec(); |
409 if (base::FilePath::FromUTF8Unsafe(mount_name).ReferencesParent()) | 409 if (base::FilePath::FromUTF8Unsafe(mount_name).ReferencesParent()) |
410 return std::string(); | 410 return std::string(); |
411 root.append(mount_name); | 411 root.append(mount_name); |
412 root.append("/"); | 412 root.append("/"); |
413 return root; | 413 return root; |
414 } | 414 } |
415 | 415 |
416 base::PlatformFileError NetErrorToPlatformFileError(int error) { | 416 base::File::Error NetErrorToFileError(int error) { |
417 switch (error) { | 417 switch (error) { |
418 case net::OK: | 418 case net::OK: |
419 return base::PLATFORM_FILE_OK; | 419 return base::File::FILE_OK; |
420 case net::ERR_ADDRESS_IN_USE: | 420 case net::ERR_ADDRESS_IN_USE: |
421 return base::PLATFORM_FILE_ERROR_IN_USE; | 421 return base::File::FILE_ERROR_IN_USE; |
422 case net::ERR_FILE_EXISTS: | 422 case net::ERR_FILE_EXISTS: |
423 return base::PLATFORM_FILE_ERROR_EXISTS; | 423 return base::File::FILE_ERROR_EXISTS; |
424 case net::ERR_FILE_NOT_FOUND: | 424 case net::ERR_FILE_NOT_FOUND: |
425 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 425 return base::File::FILE_ERROR_NOT_FOUND; |
426 case net::ERR_ACCESS_DENIED: | 426 case net::ERR_ACCESS_DENIED: |
427 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; | 427 return base::File::FILE_ERROR_ACCESS_DENIED; |
428 case net::ERR_TOO_MANY_SOCKET_STREAMS: | 428 case net::ERR_TOO_MANY_SOCKET_STREAMS: |
429 return base::PLATFORM_FILE_ERROR_TOO_MANY_OPENED; | 429 return base::File::FILE_ERROR_TOO_MANY_OPENED; |
430 case net::ERR_OUT_OF_MEMORY: | 430 case net::ERR_OUT_OF_MEMORY: |
431 return base::PLATFORM_FILE_ERROR_NO_MEMORY; | 431 return base::File::FILE_ERROR_NO_MEMORY; |
432 case net::ERR_FILE_NO_SPACE: | 432 case net::ERR_FILE_NO_SPACE: |
433 return base::PLATFORM_FILE_ERROR_NO_SPACE; | 433 return base::File::FILE_ERROR_NO_SPACE; |
434 case net::ERR_INVALID_ARGUMENT: | 434 case net::ERR_INVALID_ARGUMENT: |
435 case net::ERR_INVALID_HANDLE: | 435 case net::ERR_INVALID_HANDLE: |
436 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; | 436 return base::File::FILE_ERROR_INVALID_OPERATION; |
437 case net::ERR_ABORTED: | 437 case net::ERR_ABORTED: |
438 case net::ERR_CONNECTION_ABORTED: | 438 case net::ERR_CONNECTION_ABORTED: |
439 return base::PLATFORM_FILE_ERROR_ABORT; | 439 return base::File::FILE_ERROR_ABORT; |
440 case net::ERR_ADDRESS_INVALID: | 440 case net::ERR_ADDRESS_INVALID: |
441 case net::ERR_INVALID_URL: | 441 case net::ERR_INVALID_URL: |
442 return base::PLATFORM_FILE_ERROR_INVALID_URL; | 442 return base::File::FILE_ERROR_INVALID_URL; |
443 default: | 443 default: |
444 return base::PLATFORM_FILE_ERROR_FAILED; | 444 return base::File::FILE_ERROR_FAILED; |
445 } | 445 } |
446 } | 446 } |
447 | 447 |
448 #if defined(OS_CHROMEOS) | 448 #if defined(OS_CHROMEOS) |
449 FileSystemInfo GetFileSystemInfoForChromeOS(const GURL& origin_url) { | 449 FileSystemInfo GetFileSystemInfoForChromeOS(const GURL& origin_url) { |
450 FileSystemType mount_type = fileapi::kFileSystemTypeExternal; | 450 FileSystemType mount_type = fileapi::kFileSystemTypeExternal; |
451 return FileSystemInfo(fileapi::GetFileSystemName(origin_url, mount_type), | 451 return FileSystemInfo(fileapi::GetFileSystemName(origin_url, mount_type), |
452 fileapi::GetFileSystemRootURI(origin_url, mount_type), | 452 fileapi::GetFileSystemRootURI(origin_url, mount_type), |
453 mount_type); | 453 mount_type); |
454 } | 454 } |
455 #endif | 455 #endif |
456 | 456 |
457 } // namespace fileapi | 457 } // namespace fileapi |
OLD | NEW |