OLD | NEW |
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 return TypeMismatchError; | 100 return TypeMismatchError; |
101 case kPathExistsErr: | 101 case kPathExistsErr: |
102 return PathExistsError; | 102 return PathExistsError; |
103 default: | 103 default: |
104 ASSERT_NOT_REACHED(); | 104 ASSERT_NOT_REACHED(); |
105 return code; | 105 return code; |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 const char* errorCodeToMessage(ErrorCode code) { | 109 const char* errorCodeToMessage(ErrorCode code) { |
110 // Note that some of these do not set message. If message is 0 then the defaul
t message is used. | 110 // Note that some of these do not set message. If message is 0 then the |
| 111 // default message is used. |
111 switch (code) { | 112 switch (code) { |
112 case kOK: | 113 case kOK: |
113 return 0; | 114 return 0; |
114 case kSecurityErr: | 115 case kSecurityErr: |
115 return securityErrorMessage; | 116 return securityErrorMessage; |
116 case kNotFoundErr: | 117 case kNotFoundErr: |
117 return notFoundErrorMessage; | 118 return notFoundErrorMessage; |
118 case kAbortErr: | 119 case kAbortErr: |
119 return abortErrorMessage; | 120 return abortErrorMessage; |
120 case kNotReadableErr: | 121 case kNotReadableErr: |
(...skipping 19 matching lines...) Expand all Loading... |
140 return 0; | 141 return 0; |
141 } | 142 } |
142 } | 143 } |
143 | 144 |
144 } // namespace | 145 } // namespace |
145 | 146 |
146 void throwDOMException(ExceptionState& exceptionState, ErrorCode code) { | 147 void throwDOMException(ExceptionState& exceptionState, ErrorCode code) { |
147 if (code == kOK) | 148 if (code == kOK) |
148 return; | 149 return; |
149 | 150 |
150 // SecurityError is special-cased, as we want to route those exceptions throug
h ExceptionState::throwSecurityError. | 151 // SecurityError is special-cased, as we want to route those exceptions |
| 152 // through ExceptionState::throwSecurityError. |
151 if (code == kSecurityErr) { | 153 if (code == kSecurityErr) { |
152 exceptionState.throwSecurityError(securityErrorMessage); | 154 exceptionState.throwSecurityError(securityErrorMessage); |
153 return; | 155 return; |
154 } | 156 } |
155 | 157 |
156 exceptionState.throwDOMException(errorCodeToExceptionCode(code), | 158 exceptionState.throwDOMException(errorCodeToExceptionCode(code), |
157 errorCodeToMessage(code)); | 159 errorCodeToMessage(code)); |
158 } | 160 } |
159 | 161 |
160 DOMException* createDOMException(ErrorCode code) { | 162 DOMException* createDOMException(ErrorCode code) { |
161 DCHECK_NE(code, kOK); | 163 DCHECK_NE(code, kOK); |
162 return DOMException::create(errorCodeToExceptionCode(code), | 164 return DOMException::create(errorCodeToExceptionCode(code), |
163 errorCodeToMessage(code)); | 165 errorCodeToMessage(code)); |
164 } | 166 } |
165 | 167 |
166 } // namespace FileError | 168 } // namespace FileError |
167 | 169 |
168 } // namespace blink | 170 } // namespace blink |
OLD | NEW |