summaryrefslogtreecommitdiffstats
path: root/webkit/common
diff options
context:
space:
mode:
authorhidehiko@chromium.org <hidehiko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-25 05:14:01 +0000
committerhidehiko@chromium.org <hidehiko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-25 05:14:01 +0000
commitdd809bbed0ac1499ba44500380984dd3eff72201 (patch)
tree6c931ce523783efca75493d0b877012e9c8fa29b /webkit/common
parent055f9bf9a6fad09b58700eaeb7148e8547e2cf45 (diff)
downloadchromium_src-dd809bbed0ac1499ba44500380984dd3eff72201.zip
chromium_src-dd809bbed0ac1499ba44500380984dd3eff72201.tar.gz
chromium_src-dd809bbed0ac1499ba44500380984dd3eff72201.tar.bz2
Extract NetErrorToPlatformFileError from file_writer_delegate to file_system_util.
This is the preparation to share the utility function with other modules. BUG=279278 TEST=Ran content_unittests R=kinuko@chromium.org, tzik@chromium.org Review URL: https://codereview.chromium.org/24300003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@225143 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/common')
-rw-r--r--webkit/common/fileapi/file_system_util.cc33
-rw-r--r--webkit/common/fileapi/file_system_util.h4
2 files changed, 37 insertions, 0 deletions
diff --git a/webkit/common/fileapi/file_system_util.cc b/webkit/common/fileapi/file_system_util.cc
index 6229bc2..0f0710b 100644
--- a/webkit/common/fileapi/file_system_util.cc
+++ b/webkit/common/fileapi/file_system_util.cc
@@ -11,6 +11,7 @@
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "net/base/net_errors.h"
#include "url/gurl.h"
#include "webkit/common/database/database_identifier.h"
@@ -396,4 +397,36 @@ std::string GetExternalFileSystemRootURIString(
return root;
}
+base::PlatformFileError NetErrorToPlatformFileError(int error) {
+ switch (error) {
+ case net::OK:
+ return base::PLATFORM_FILE_OK;
+ case net::ERR_ADDRESS_IN_USE:
+ return base::PLATFORM_FILE_ERROR_IN_USE;
+ case net::ERR_FILE_EXISTS:
+ return base::PLATFORM_FILE_ERROR_EXISTS;
+ case net::ERR_FILE_NOT_FOUND:
+ return base::PLATFORM_FILE_ERROR_NOT_FOUND;
+ case net::ERR_ACCESS_DENIED:
+ return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
+ case net::ERR_TOO_MANY_SOCKET_STREAMS:
+ return base::PLATFORM_FILE_ERROR_TOO_MANY_OPENED;
+ case net::ERR_OUT_OF_MEMORY:
+ return base::PLATFORM_FILE_ERROR_NO_MEMORY;
+ case net::ERR_FILE_NO_SPACE:
+ return base::PLATFORM_FILE_ERROR_NO_SPACE;
+ case net::ERR_INVALID_ARGUMENT:
+ case net::ERR_INVALID_HANDLE:
+ return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
+ case net::ERR_ABORTED:
+ case net::ERR_CONNECTION_ABORTED:
+ return base::PLATFORM_FILE_ERROR_ABORT;
+ case net::ERR_ADDRESS_INVALID:
+ case net::ERR_INVALID_URL:
+ return base::PLATFORM_FILE_ERROR_INVALID_URL;
+ default:
+ return base::PLATFORM_FILE_ERROR_FAILED;
+ }
+}
+
} // namespace fileapi
diff --git a/webkit/common/fileapi/file_system_util.h b/webkit/common/fileapi/file_system_util.h
index ffb29fa..3616dfa 100644
--- a/webkit/common/fileapi/file_system_util.h
+++ b/webkit/common/fileapi/file_system_util.h
@@ -158,6 +158,10 @@ WEBKIT_STORAGE_COMMON_EXPORT std::string GetExternalFileSystemRootURIString(
const GURL& origin_url,
const std::string& mount_name);
+// Translates the net::Error to base::PlatformFileError.
+WEBKIT_STORAGE_COMMON_EXPORT base::PlatformFileError
+NetErrorToPlatformFileError(int error);
+
} // namespace fileapi
#endif // WEBKIT_COMMON_FILEAPI_FILE_SYSTEM_UTIL_H_