| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 NOTREACHED(); | 115 NOTREACHED(); |
| 116 return ExceptionParams(kUnknownError); | 116 return ExceptionParams(kUnknownError); |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace | 119 } // namespace |
| 120 | 120 |
| 121 // static | 121 // static |
| 122 DOMException* ServiceWorkerError::Take(ScriptPromiseResolver*, | 122 DOMException* ServiceWorkerError::Take(ScriptPromiseResolver*, |
| 123 const WebServiceWorkerError& web_error) { | 123 const WebServiceWorkerError& web_error) { |
| 124 ExceptionParams params = GetExceptionParams(web_error); | 124 ExceptionParams params = GetExceptionParams(web_error); |
| 125 ASSERT(params.code != kUnknownError); | 125 DCHECK_NE(params.code, kUnknownError); |
| 126 return DOMException::Create(params.code, params.message); | 126 return DOMException::Create(params.code, params.message); |
| 127 } | 127 } |
| 128 | 128 |
| 129 // static | 129 // static |
| 130 v8::Local<v8::Value> ServiceWorkerErrorForUpdate::Take( | 130 v8::Local<v8::Value> ServiceWorkerErrorForUpdate::Take( |
| 131 ScriptPromiseResolver* resolver, | 131 ScriptPromiseResolver* resolver, |
| 132 const WebServiceWorkerError& web_error) { | 132 const WebServiceWorkerError& web_error) { |
| 133 ScriptState* script_state = resolver->GetScriptState(); | 133 ScriptState* script_state = resolver->GetScriptState(); |
| 134 switch (web_error.error_type) { | 134 switch (web_error.error_type) { |
| 135 case WebServiceWorkerError::kErrorTypeNetwork: | 135 case WebServiceWorkerError::kErrorTypeNetwork: |
| 136 case WebServiceWorkerError::kErrorTypeNotFound: | 136 case WebServiceWorkerError::kErrorTypeNotFound: |
| 137 case WebServiceWorkerError::kErrorTypeScriptEvaluateFailed: | 137 case WebServiceWorkerError::kErrorTypeScriptEvaluateFailed: |
| 138 // According to the spec, these errors during update should result in | 138 // According to the spec, these errors during update should result in |
| 139 // a TypeError. | 139 // a TypeError. |
| 140 return V8ThrowException::CreateTypeError( | 140 return V8ThrowException::CreateTypeError( |
| 141 script_state->GetIsolate(), GetExceptionParams(web_error).message); | 141 script_state->GetIsolate(), GetExceptionParams(web_error).message); |
| 142 case WebServiceWorkerError::kErrorTypeType: | 142 case WebServiceWorkerError::kErrorTypeType: |
| 143 return V8ThrowException::CreateTypeError(script_state->GetIsolate(), | 143 return V8ThrowException::CreateTypeError(script_state->GetIsolate(), |
| 144 web_error.message); | 144 web_error.message); |
| 145 default: | 145 default: |
| 146 return ToV8(ServiceWorkerError::Take(resolver, web_error), | 146 return ToV8(ServiceWorkerError::Take(resolver, web_error), |
| 147 script_state->GetContext()->Global(), | 147 script_state->GetContext()->Global(), |
| 148 script_state->GetIsolate()); | 148 script_state->GetIsolate()); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace blink | 152 } // namespace blink |
| OLD | NEW |