Commit b73427e7 authored by mtomasz@chromium.org's avatar mtomasz@chromium.org

[fsp] Convert base::File::Error to string.

This patch adds a utility function which converts a base::File::Error code
to a human readable form. It will be used for logging request errors in the
File System Provider API.

TEST=Not used yet.
BUG=376095

Review URL: https://codereview.chromium.org/308613002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273779 0039d316-1c4b-4281-b951-d872f2087c98
parent de42c005
......@@ -85,4 +85,48 @@ void File::Initialize(const FilePath& name, uint32 flags) {
}
#endif
std::string File::ErrorToString(Error error) {
switch (error) {
case FILE_OK:
return "FILE_OK";
case FILE_ERROR_FAILED:
return "FILE_ERROR_FAILED";
case FILE_ERROR_IN_USE:
return "FILE_ERROR_IN_USE";
case FILE_ERROR_EXISTS:
return "FILE_ERROR_EXISTS";
case FILE_ERROR_NOT_FOUND:
return "FILE_ERROR_NOT_FOUND";
case FILE_ERROR_ACCESS_DENIED:
return "FILE_ERROR_ACCESS_DENIED";
case FILE_ERROR_TOO_MANY_OPENED:
return "FILE_ERROR_TOO_MANY_OPENED";
case FILE_ERROR_NO_MEMORY:
return "FILE_ERROR_NO_MEMORY";
case FILE_ERROR_NO_SPACE:
return "FILE_ERROR_NO_SPACE";
case FILE_ERROR_NOT_A_DIRECTORY:
return "FILE_ERROR_NOT_A_DIRECTORY";
case FILE_ERROR_INVALID_OPERATION:
return "FILE_ERROR_INVALID_OPERATION";
case FILE_ERROR_SECURITY:
return "FILE_ERROR_SECURITY";
case FILE_ERROR_ABORT:
return "FILE_ERROR_ABORT";
case FILE_ERROR_NOT_A_FILE:
return "FILE_ERROR_NOT_A_FILE";
case FILE_ERROR_NOT_EMPTY:
return "FILE_ERROR_NOT_EMPTY";
case FILE_ERROR_INVALID_URL:
return "FILE_ERROR_INVALID_URL";
case FILE_ERROR_IO:
return "FILE_ERROR_IO";
case FILE_ERROR_MAX:
break;
}
NOTREACHED();
return "";
}
} // namespace base
......@@ -14,6 +14,8 @@
#include <sys/stat.h>
#endif
#include <string>
#include "base/base_export.h"
#include "base/basictypes.h"
#include "base/files/scoped_file.h"
......@@ -289,6 +291,9 @@ class BASE_EXPORT File {
static Error OSErrorToFileError(int saved_errno);
#endif
// Converts an error value to a human-readable form. Used for logging.
static std::string ErrorToString(Error error);
private:
void SetPlatformFile(PlatformFile file);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment