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 26 matching lines...) Expand all Loading... |
37 using blink::WebServiceWorkerError; | 37 using blink::WebServiceWorkerError; |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 static DOMException* createException(ExceptionCode code, const String& defaultMe
ssage, const String& message) | 41 static DOMException* createException(ExceptionCode code, const String& defaultMe
ssage, const String& message) |
42 { | 42 { |
43 return DOMException::create(code, message.isEmpty() ? defaultMessage : messa
ge); | 43 return DOMException::create(code, message.isEmpty() ? defaultMessage : messa
ge); |
44 } | 44 } |
45 | 45 |
46 // static | 46 // static |
47 DOMException* ServiceWorkerError::take(ScriptPromiseResolver*, PassOwnPtr<WebSer
viceWorkerError> webError) | 47 DOMException* ServiceWorkerError::take(ScriptPromiseResolver*, const WebServiceW
orkerError& webError) |
48 { | 48 { |
49 switch (webError->errorType) { | 49 switch (webError.errorType) { |
50 case WebServiceWorkerError::ErrorTypeAbort: | 50 case WebServiceWorkerError::ErrorTypeAbort: |
51 return createException(AbortError, "The Service Worker operation was abo
rted.", webError->message); | 51 return createException(AbortError, "The Service Worker operation was abo
rted.", webError.message); |
52 case WebServiceWorkerError::ErrorTypeActivate: | 52 case WebServiceWorkerError::ErrorTypeActivate: |
53 // Not currently returned as a promise rejection. | 53 // Not currently returned as a promise rejection. |
54 // FIXME: Introduce new ActivateError type to ExceptionCodes? | 54 // FIXME: Introduce new ActivateError type to ExceptionCodes? |
55 return createException(AbortError, "The Service Worker activation failed
.", webError->message); | 55 return createException(AbortError, "The Service Worker activation failed
.", webError.message); |
56 case WebServiceWorkerError::ErrorTypeDisabled: | 56 case WebServiceWorkerError::ErrorTypeDisabled: |
57 return createException(NotSupportedError, "Service Worker support is dis
abled.", webError->message); | 57 return createException(NotSupportedError, "Service Worker support is dis
abled.", webError.message); |
58 case WebServiceWorkerError::ErrorTypeInstall: | 58 case WebServiceWorkerError::ErrorTypeInstall: |
59 // FIXME: Introduce new InstallError type to ExceptionCodes? | 59 // FIXME: Introduce new InstallError type to ExceptionCodes? |
60 return createException(AbortError, "The Service Worker installation fail
ed.", webError->message); | 60 return createException(AbortError, "The Service Worker installation fail
ed.", webError.message); |
61 case WebServiceWorkerError::ErrorTypeNetwork: | 61 case WebServiceWorkerError::ErrorTypeNetwork: |
62 return createException(NetworkError, "The Service Worker failed by netwo
rk.", webError->message); | 62 return createException(NetworkError, "The Service Worker failed by netwo
rk.", webError.message); |
63 case WebServiceWorkerError::ErrorTypeNotFound: | 63 case WebServiceWorkerError::ErrorTypeNotFound: |
64 return createException(NotFoundError, "The specified Service Worker reso
urce was not found.", webError->message); | 64 return createException(NotFoundError, "The specified Service Worker reso
urce was not found.", webError.message); |
65 case WebServiceWorkerError::ErrorTypeSecurity: | 65 case WebServiceWorkerError::ErrorTypeSecurity: |
66 return createException(SecurityError, "The Service Worker security polic
y prevented an action.", webError->message); | 66 return createException(SecurityError, "The Service Worker security polic
y prevented an action.", webError.message); |
67 case WebServiceWorkerError::ErrorTypeState: | 67 case WebServiceWorkerError::ErrorTypeState: |
68 return createException(InvalidStateError, "The Service Worker state was
not valid.", webError->message); | 68 return createException(InvalidStateError, "The Service Worker state was
not valid.", webError.message); |
69 case WebServiceWorkerError::ErrorTypeTimeout: | 69 case WebServiceWorkerError::ErrorTypeTimeout: |
70 return createException(AbortError, "The Service Worker operation timed o
ut.", webError->message); | 70 return createException(AbortError, "The Service Worker operation timed o
ut.", webError.message); |
71 case WebServiceWorkerError::ErrorTypeUnknown: | 71 case WebServiceWorkerError::ErrorTypeUnknown: |
72 return createException(UnknownError, "An unknown error occurred within S
ervice Worker.", webError->message); | 72 return createException(UnknownError, "An unknown error occurred within S
ervice Worker.", webError.message); |
73 } | 73 } |
74 ASSERT_NOT_REACHED(); | 74 ASSERT_NOT_REACHED(); |
75 return DOMException::create(UnknownError); | 75 return DOMException::create(UnknownError); |
76 } | 76 } |
77 | 77 |
78 } // namespace blink | 78 } // namespace blink |
OLD | NEW |