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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 275 } |
276 | 276 |
277 base::FilePath StringToFilePath(const std::string& file_path_string) { | 277 base::FilePath StringToFilePath(const std::string& file_path_string) { |
278 #if defined(OS_WIN) | 278 #if defined(OS_WIN) |
279 return base::FilePath(UTF8ToUTF16(file_path_string)); | 279 return base::FilePath(UTF8ToUTF16(file_path_string)); |
280 #elif defined(OS_POSIX) | 280 #elif defined(OS_POSIX) |
281 return base::FilePath(file_path_string); | 281 return base::FilePath(file_path_string); |
282 #endif | 282 #endif |
283 } | 283 } |
284 | 284 |
285 WebKit::WebFileError PlatformFileErrorToWebFileError( | 285 blink::WebFileError PlatformFileErrorToWebFileError( |
286 base::PlatformFileError error_code) { | 286 base::PlatformFileError error_code) { |
287 switch (error_code) { | 287 switch (error_code) { |
288 case base::PLATFORM_FILE_ERROR_NOT_FOUND: | 288 case base::PLATFORM_FILE_ERROR_NOT_FOUND: |
289 return WebKit::WebFileErrorNotFound; | 289 return blink::WebFileErrorNotFound; |
290 case base::PLATFORM_FILE_ERROR_INVALID_OPERATION: | 290 case base::PLATFORM_FILE_ERROR_INVALID_OPERATION: |
291 case base::PLATFORM_FILE_ERROR_EXISTS: | 291 case base::PLATFORM_FILE_ERROR_EXISTS: |
292 case base::PLATFORM_FILE_ERROR_NOT_EMPTY: | 292 case base::PLATFORM_FILE_ERROR_NOT_EMPTY: |
293 return WebKit::WebFileErrorInvalidModification; | 293 return blink::WebFileErrorInvalidModification; |
294 case base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY: | 294 case base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY: |
295 case base::PLATFORM_FILE_ERROR_NOT_A_FILE: | 295 case base::PLATFORM_FILE_ERROR_NOT_A_FILE: |
296 return WebKit::WebFileErrorTypeMismatch; | 296 return blink::WebFileErrorTypeMismatch; |
297 case base::PLATFORM_FILE_ERROR_ACCESS_DENIED: | 297 case base::PLATFORM_FILE_ERROR_ACCESS_DENIED: |
298 return WebKit::WebFileErrorNoModificationAllowed; | 298 return blink::WebFileErrorNoModificationAllowed; |
299 case base::PLATFORM_FILE_ERROR_FAILED: | 299 case base::PLATFORM_FILE_ERROR_FAILED: |
300 return WebKit::WebFileErrorInvalidState; | 300 return blink::WebFileErrorInvalidState; |
301 case base::PLATFORM_FILE_ERROR_ABORT: | 301 case base::PLATFORM_FILE_ERROR_ABORT: |
302 return WebKit::WebFileErrorAbort; | 302 return blink::WebFileErrorAbort; |
303 case base::PLATFORM_FILE_ERROR_SECURITY: | 303 case base::PLATFORM_FILE_ERROR_SECURITY: |
304 return WebKit::WebFileErrorSecurity; | 304 return blink::WebFileErrorSecurity; |
305 case base::PLATFORM_FILE_ERROR_NO_SPACE: | 305 case base::PLATFORM_FILE_ERROR_NO_SPACE: |
306 return WebKit::WebFileErrorQuotaExceeded; | 306 return blink::WebFileErrorQuotaExceeded; |
307 case base::PLATFORM_FILE_ERROR_INVALID_URL: | 307 case base::PLATFORM_FILE_ERROR_INVALID_URL: |
308 return WebKit::WebFileErrorEncoding; | 308 return blink::WebFileErrorEncoding; |
309 default: | 309 default: |
310 return WebKit::WebFileErrorInvalidModification; | 310 return blink::WebFileErrorInvalidModification; |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 bool GetFileSystemPublicType( | 314 bool GetFileSystemPublicType( |
315 const std::string type_string, | 315 const std::string type_string, |
316 WebKit::WebFileSystemType* type) { | 316 blink::WebFileSystemType* type) { |
317 DCHECK(type); | 317 DCHECK(type); |
318 if (type_string == "Temporary") { | 318 if (type_string == "Temporary") { |
319 *type = WebKit::WebFileSystemTypeTemporary; | 319 *type = blink::WebFileSystemTypeTemporary; |
320 return true; | 320 return true; |
321 } | 321 } |
322 if (type_string == "Persistent") { | 322 if (type_string == "Persistent") { |
323 *type = WebKit::WebFileSystemTypePersistent; | 323 *type = blink::WebFileSystemTypePersistent; |
324 return true; | 324 return true; |
325 } | 325 } |
326 if (type_string == "Isolated") { | 326 if (type_string == "Isolated") { |
327 *type = WebKit::WebFileSystemTypeIsolated; | 327 *type = blink::WebFileSystemTypeIsolated; |
328 return true; | 328 return true; |
329 } | 329 } |
330 if (type_string == "External") { | 330 if (type_string == "External") { |
331 *type = WebKit::WebFileSystemTypeExternal; | 331 *type = blink::WebFileSystemTypeExternal; |
332 return true; | 332 return true; |
333 } | 333 } |
334 NOTREACHED(); | 334 NOTREACHED(); |
335 return false; | 335 return false; |
336 } | 336 } |
337 | 337 |
338 std::string GetIsolatedFileSystemName(const GURL& origin_url, | 338 std::string GetIsolatedFileSystemName(const GURL& origin_url, |
339 const std::string& filesystem_id) { | 339 const std::string& filesystem_id) { |
340 std::string name(fileapi::GetFileSystemName( | 340 std::string name(fileapi::GetFileSystemName( |
341 origin_url, fileapi::kFileSystemTypeIsolated)); | 341 origin_url, fileapi::kFileSystemTypeIsolated)); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 #if defined(OS_CHROMEOS) | 446 #if defined(OS_CHROMEOS) |
447 FileSystemInfo GetFileSystemInfoForChromeOS(const GURL& origin_url) { | 447 FileSystemInfo GetFileSystemInfoForChromeOS(const GURL& origin_url) { |
448 FileSystemType mount_type = fileapi::kFileSystemTypeExternal; | 448 FileSystemType mount_type = fileapi::kFileSystemTypeExternal; |
449 return FileSystemInfo(fileapi::GetFileSystemName(origin_url, mount_type), | 449 return FileSystemInfo(fileapi::GetFileSystemName(origin_url, mount_type), |
450 fileapi::GetFileSystemRootURI(origin_url, mount_type), | 450 fileapi::GetFileSystemRootURI(origin_url, mount_type), |
451 mount_type); | 451 mount_type); |
452 } | 452 } |
453 #endif | 453 #endif |
454 | 454 |
455 } // namespace fileapi | 455 } // namespace fileapi |
OLD | NEW |