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

Side by Side Diff: third_party/WebKit/Source/core/fileapi/FileError.cpp

Issue 2040563002: Remove FileError interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fe-dep
Patch Set: handleEvent -> invoke and other review nits Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/fileapi/FileError.h" 31 #include "core/fileapi/FileError.h"
32 32
33 #include "bindings/core/v8/ExceptionState.h" 33 #include "bindings/core/v8/ExceptionState.h"
34 #include "core/dom/DOMException.h"
34 #include "core/dom/ExceptionCode.h" 35 #include "core/dom/ExceptionCode.h"
35 36
36 namespace blink { 37 namespace blink {
37 38
38 const char FileError::abortErrorMessage[] = "An ongoing operation was aborted, t ypically with a call to abort()."; 39 namespace FileError {
39 const char FileError::encodingErrorMessage[] = "A URI supplied to the API was ma lformed, or the resulting Data URL has exceeded the URL length limitations for D ata URLs."; 40
40 const char FileError::invalidStateErrorMessage[] = "An operation that depends on state cached in an interface object was made but the state had changed since it was read from disk."; 41 const char abortErrorMessage[] = "An ongoing operation was aborted, typically wi th a call to abort().";
41 const char FileError::noModificationAllowedErrorMessage[] = "An attempt was made to write to a file or directory which could not be modified due to the state of the underlying filesystem."; 42 const char encodingErrorMessage[] = "A URI supplied to the API was malformed, or the resulting Data URL has exceeded the URL length limitations for Data URLs.";
42 const char FileError::notFoundErrorMessage[] = "A requested file or directory co uld not be found at the time an operation was processed."; 43 const char invalidStateErrorMessage[] = "An operation that depends on state cach ed in an interface object was made but the state had changed since it was read f rom disk.";
43 const char FileError::notReadableErrorMessage[] = "The requested file could not be read, typically due to permission problems that have occurred after a referen ce to a file was acquired."; 44 const char noModificationAllowedErrorMessage[] = "An attempt was made to write t o a file or directory which could not be modified due to the state of the underl ying filesystem.";
44 const char FileError::pathExistsErrorMessage[] = "An attempt was made to create a file or directory where an element already exists."; 45 const char notFoundErrorMessage[] = "A requested file or directory could not be found at the time an operation was processed.";
45 const char FileError::quotaExceededErrorMessage[] = "The operation failed becaus e it would cause the application to exceed its storage quota."; 46 const char notReadableErrorMessage[] = "The requested file could not be read, ty pically due to permission problems that have occurred after a reference to a fil e was acquired.";
46 const char FileError::securityErrorMessage[] = "It was determined that certain f iles are unsafe for access within a Web application, or that too many calls are being made on file resources."; 47 const char pathExistsErrorMessage[] = "An attempt was made to create a file or d irectory where an element already exists.";
47 const char FileError::syntaxErrorMessage[] = "An invalid or unsupported argument was given, like an invalid line ending specifier."; 48 const char quotaExceededErrorMessage[] = "The operation failed because it would cause the application to exceed its storage quota.";
48 const char FileError::typeMismatchErrorMessage[] = "The path supplied exists, bu t was not an entry of requested type."; 49 const char securityErrorMessage[] = "It was determined that certain files are un safe for access within a Web application, or that too many calls are being made on file resources.";
50 const char syntaxErrorMessage[] = "An invalid or unsupported argument was given, like an invalid line ending specifier.";
51 const char typeMismatchErrorMessage[] = "The path supplied exists, but was not a n entry of requested type.";
49 52
50 namespace { 53 namespace {
51 54
52 ExceptionCode errorCodeToExceptionCode(FileError::ErrorCode code) 55 ExceptionCode errorCodeToExceptionCode(ErrorCode code)
53 { 56 {
54 switch (code) { 57 switch (code) {
55 case FileError::OK: 58 case OK:
56 return 0; 59 return 0;
57 case FileError::NOT_FOUND_ERR: 60 case NOT_FOUND_ERR:
58 return NotFoundError; 61 return NotFoundError;
59 case FileError::SECURITY_ERR: 62 case SECURITY_ERR:
60 return SecurityError; 63 return SecurityError;
61 case FileError::ABORT_ERR: 64 case ABORT_ERR:
62 return AbortError; 65 return AbortError;
63 case FileError::NOT_READABLE_ERR: 66 case NOT_READABLE_ERR:
64 return NotReadableError; 67 return NotReadableError;
65 case FileError::ENCODING_ERR: 68 case ENCODING_ERR:
66 return EncodingError; 69 return EncodingError;
67 case FileError::NO_MODIFICATION_ALLOWED_ERR: 70 case NO_MODIFICATION_ALLOWED_ERR:
68 return NoModificationAllowedError; 71 return NoModificationAllowedError;
69 case FileError::INVALID_STATE_ERR: 72 case INVALID_STATE_ERR:
70 return InvalidStateError; 73 return InvalidStateError;
71 case FileError::SYNTAX_ERR: 74 case SYNTAX_ERR:
72 return SyntaxError; 75 return SyntaxError;
73 case FileError::INVALID_MODIFICATION_ERR: 76 case INVALID_MODIFICATION_ERR:
74 return InvalidModificationError; 77 return InvalidModificationError;
75 case FileError::QUOTA_EXCEEDED_ERR: 78 case QUOTA_EXCEEDED_ERR:
76 return QuotaExceededError; 79 return QuotaExceededError;
77 case FileError::TYPE_MISMATCH_ERR: 80 case TYPE_MISMATCH_ERR:
78 return TypeMismatchError; 81 return TypeMismatchError;
79 case FileError::PATH_EXISTS_ERR: 82 case PATH_EXISTS_ERR:
80 return PathExistsError; 83 return PathExistsError;
81 default: 84 default:
82 ASSERT_NOT_REACHED(); 85 ASSERT_NOT_REACHED();
83 return code; 86 return code;
84 } 87 }
85 } 88 }
86 89
87 const char* errorCodeToMessage(FileError::ErrorCode code) 90 const char* errorCodeToMessage(ErrorCode code)
88 { 91 {
89 // Note that some of these do not set message. If message is 0 then the defa ult message is used. 92 // Note that some of these do not set message. If message is 0 then the defa ult message is used.
90 switch (code) { 93 switch (code) {
91 case FileError::OK: 94 case OK:
92 return 0; 95 return 0;
93 case FileError::SECURITY_ERR: 96 case SECURITY_ERR:
94 return FileError::securityErrorMessage; 97 return securityErrorMessage;
95 case FileError::NOT_FOUND_ERR: 98 case NOT_FOUND_ERR:
96 return FileError::notFoundErrorMessage; 99 return notFoundErrorMessage;
97 case FileError::ABORT_ERR: 100 case ABORT_ERR:
98 return FileError::abortErrorMessage; 101 return abortErrorMessage;
99 case FileError::NOT_READABLE_ERR: 102 case NOT_READABLE_ERR:
100 return FileError::notReadableErrorMessage; 103 return notReadableErrorMessage;
101 case FileError::ENCODING_ERR: 104 case ENCODING_ERR:
102 return FileError::encodingErrorMessage; 105 return encodingErrorMessage;
103 case FileError::NO_MODIFICATION_ALLOWED_ERR: 106 case NO_MODIFICATION_ALLOWED_ERR:
104 return FileError::noModificationAllowedErrorMessage; 107 return noModificationAllowedErrorMessage;
105 case FileError::INVALID_STATE_ERR: 108 case INVALID_STATE_ERR:
106 return FileError::invalidStateErrorMessage; 109 return invalidStateErrorMessage;
107 case FileError::SYNTAX_ERR: 110 case SYNTAX_ERR:
108 return FileError::syntaxErrorMessage; 111 return syntaxErrorMessage;
109 case FileError::INVALID_MODIFICATION_ERR: 112 case INVALID_MODIFICATION_ERR:
110 return 0; 113 return 0;
111 case FileError::QUOTA_EXCEEDED_ERR: 114 case QUOTA_EXCEEDED_ERR:
112 return FileError::quotaExceededErrorMessage; 115 return quotaExceededErrorMessage;
113 case FileError::TYPE_MISMATCH_ERR: 116 case TYPE_MISMATCH_ERR:
114 return 0; 117 return 0;
115 case FileError::PATH_EXISTS_ERR: 118 case PATH_EXISTS_ERR:
116 return FileError::pathExistsErrorMessage; 119 return pathExistsErrorMessage;
117 default: 120 default:
118 ASSERT_NOT_REACHED(); 121 ASSERT_NOT_REACHED();
119 return 0; 122 return 0;
120 } 123 }
121 } 124 }
122 125
123 } // namespace 126 } // namespace
124 127
125 void FileError::throwDOMException(ExceptionState& exceptionState, ErrorCode code ) 128 void throwDOMException(ExceptionState& exceptionState, ErrorCode code)
126 { 129 {
127 if (code == FileError::OK) 130 if (code == OK)
128 return; 131 return;
129 132
130 // SecurityError is special-cased, as we want to route those exceptions thro ugh ExceptionState::throwSecurityError. 133 // SecurityError is special-cased, as we want to route those exceptions thro ugh ExceptionState::throwSecurityError.
131 if (code == FileError::SECURITY_ERR) { 134 if (code == SECURITY_ERR) {
132 exceptionState.throwSecurityError(FileError::securityErrorMessage); 135 exceptionState.throwSecurityError(securityErrorMessage);
133 return; 136 return;
134 } 137 }
135 138
136 exceptionState.throwDOMException(errorCodeToExceptionCode(code), errorCodeTo Message(code)); 139 exceptionState.throwDOMException(errorCodeToExceptionCode(code), errorCodeTo Message(code));
137 } 140 }
138 141
139 FileError::FileError(ErrorCode code) 142 DOMException* createDOMException(ErrorCode code)
140 : DOMError(DOMException::getErrorName(errorCodeToExceptionCode(code)), error CodeToMessage(code))
141 , m_code(code)
142 { 143 {
144 DCHECK_NE(code, OK);
145 return DOMException::create(errorCodeToExceptionCode(code), errorCodeToMessa ge(code));
143 } 146 }
144 147
148 } // namespace FileError
149
145 } // namespace blink 150 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698