Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Unified Diff: Source/core/fileapi/FileError.cpp

Issue 22831019: Deprecate FileError in FileAPI (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: win test expectation fix (temporary) Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/fileapi/FileError.h ('k') | Source/core/fileapi/FileError.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fileapi/FileError.cpp
diff --git a/Source/core/fileapi/FileError.cpp b/Source/core/fileapi/FileError.cpp
index 9f5033679f1036db3a18757ad871b6fef650e917..2fa857639e797558711dc01f21cbe81c5dfa5ea7 100644
--- a/Source/core/fileapi/FileError.cpp
+++ b/Source/core/fileapi/FileError.cpp
@@ -48,68 +48,100 @@ const char FileError::securityErrorMessage[] = "It was determined that certain f
const char FileError::syntaxErrorMessage[] = "An invalid or unsupported argument was given, like an invalid line ending specifier.";
const char FileError::typeMismatchErrorMessage[] = "The path supplied exists, but was not an entry of requested type.";
-void FileError::throwDOMException(ExceptionState& es, ErrorCode code)
-{
- if (code == FileError::OK)
- return;
+namespace {
- ExceptionCode ec;
- const char* message = 0;
+ExceptionCode errorCodeToExceptionCode(FileError::ErrorCode code)
+{
+ switch (code) {
+ case FileError::OK:
+ return 0;
+ case FileError::NOT_FOUND_ERR:
+ return NotFoundError;
+ case FileError::SECURITY_ERR:
+ return SecurityError;
+ case FileError::ABORT_ERR:
+ return AbortError;
+ case FileError::NOT_READABLE_ERR:
+ return NotReadableError;
+ case FileError::ENCODING_ERR:
+ return EncodingError;
+ case FileError::NO_MODIFICATION_ALLOWED_ERR:
+ return NoModificationAllowedError;
+ case FileError::INVALID_STATE_ERR:
+ return InvalidStateError;
+ case FileError::SYNTAX_ERR:
+ return SyntaxError;
+ case FileError::INVALID_MODIFICATION_ERR:
+ return InvalidModificationError;
+ case FileError::QUOTA_EXCEEDED_ERR:
+ return QuotaExceededError;
+ case FileError::TYPE_MISMATCH_ERR:
+ return TypeMismatchError;
+ case FileError::PATH_EXISTS_ERR:
+ return PathExistsError;
+ default:
+ ASSERT_NOT_REACHED();
+ return code;
+ }
+}
+const char* errorCodeToMessage(FileError::ErrorCode code)
+{
// Note that some of these do not set message. If message is 0 then the default message is used.
switch (code) {
+ case FileError::OK:
+ return 0;
+ case FileError::SECURITY_ERR:
+ return FileError::securityErrorMessage;
case FileError::NOT_FOUND_ERR:
- ec = NotFoundError;
- message = FileError::notFoundErrorMessage;
- break;
+ return FileError::notFoundErrorMessage;
case FileError::ABORT_ERR:
- ec = AbortError;
- message = FileError::abortErrorMessage;
- break;
+ return FileError::abortErrorMessage;
case FileError::NOT_READABLE_ERR:
- ec = NotReadableError;
- message = FileError::notReadableErrorMessage;
- break;
+ return FileError::notReadableErrorMessage;
case FileError::ENCODING_ERR:
- ec = EncodingError;
- message = FileError::encodingErrorMessage;
- break;
+ return FileError::encodingErrorMessage;
case FileError::NO_MODIFICATION_ALLOWED_ERR:
- ec = NoModificationAllowedError;
- message = FileError::noModificationAllowedErrorMessage;
- break;
+ return FileError::noModificationAllowedErrorMessage;
case FileError::INVALID_STATE_ERR:
- ec = InvalidStateError;
- message = FileError::invalidStateErrorMessage;
- break;
+ return FileError::invalidStateErrorMessage;
case FileError::SYNTAX_ERR:
- ec = SyntaxError;
- message = FileError::syntaxErrorMessage;
- break;
+ return FileError::syntaxErrorMessage;
case FileError::INVALID_MODIFICATION_ERR:
- ec = InvalidModificationError;
- break;
+ return 0;
case FileError::QUOTA_EXCEEDED_ERR:
- ec = QuotaExceededError;
- message = FileError::quotaExceededErrorMessage;
- break;
+ return FileError::quotaExceededErrorMessage;
case FileError::TYPE_MISMATCH_ERR:
- ec = TypeMismatchError;
- break;
+ return 0;
case FileError::PATH_EXISTS_ERR:
- ec = PathExistsError;
- message = FileError::pathExistsErrorMessage;
- break;
- // SecurityError is special-cased, as we want to route those exceptions through ExceptionState::throwSecurityError.
- case FileError::SECURITY_ERR:
- es.throwSecurityError(FileError::securityErrorMessage);
- return;
+ return FileError::pathExistsErrorMessage;
default:
ASSERT_NOT_REACHED();
+ return 0;
+ }
+}
+
+} // namespace
+
+void FileError::throwDOMException(ExceptionState& es, ErrorCode code)
+{
+ if (code == FileError::OK)
+ return;
+
+ // SecurityError is special-cased, as we want to route those exceptions through ExceptionState::throwSecurityError.
+ if (code == FileError::SECURITY_ERR) {
+ es.throwSecurityError(FileError::securityErrorMessage);
return;
}
- es.throwDOMException(ec, message);
+ es.throwDOMException(errorCodeToExceptionCode(code), errorCodeToMessage(code));
+}
+
+FileError::FileError(ErrorCode code)
+ : DOMError(DOMException::getErrorName(errorCodeToExceptionCode(code)), errorCodeToMessage(code))
+ , m_code(code)
+{
+ ScriptWrappable::init(this);
}
} // namespace WebCore
« no previous file with comments | « Source/core/fileapi/FileError.h ('k') | Source/core/fileapi/FileError.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698