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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise Adapter<ServiceWorker, ServiceWorkerError>(resolver, executionContext)); | 86 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise Adapter<ServiceWorker, ServiceWorkerError>(resolver, executionContext)); |
87 return promise; | 87 return promise; |
88 } | 88 } |
89 | 89 |
90 ScriptPromise ServiceWorkerContainer::unregisterServiceWorker(ExecutionContext* executionContext, const String& pattern) | 90 ScriptPromise ServiceWorkerContainer::unregisterServiceWorker(ExecutionContext* executionContext, const String& pattern) |
91 { | 91 { |
92 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled()); | 92 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled()); |
93 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(execu tionContext); | 93 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(execu tionContext); |
94 ScriptPromise promise = resolver->promise(); | 94 ScriptPromise promise = resolver->promise(); |
95 | 95 |
96 if (!m_provider) { | |
97 resolver->reject(DOMError::create(NotSupportedError, "No provider is ava ilable")); | |
dominicc (has gone to gerrit)
2014/03/31 04:52:09
It would be great to see a W3C-style test for this
kinuko
2014/03/31 12:33:05
Yes, but if we can have a test code that can repro
| |
98 return promise; | |
99 } | |
100 | |
96 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); | 101 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); |
97 KURL patternURL = executionContext->completeURL(pattern); | 102 KURL patternURL = executionContext->completeURL(pattern); |
98 if (!pattern.isEmpty() && !documentOrigin->canRequest(patternURL)) { | 103 if (!pattern.isEmpty() && !documentOrigin->canRequest(patternURL)) { |
99 resolver->reject(DOMError::create(SecurityError, "Can only unregister fo r patterns in the document's origin.")); | 104 resolver->reject(DOMError::create(SecurityError, "Can only unregister fo r patterns in the document's origin.")); |
100 | |
101 return promise; | 105 return promise; |
102 } | 106 } |
103 | 107 |
104 m_provider->unregisterServiceWorker(patternURL, new CallbackPromiseAdapter<S erviceWorker, ServiceWorkerError>(resolver, executionContext)); | 108 m_provider->unregisterServiceWorker(patternURL, new CallbackPromiseAdapter<S erviceWorker, ServiceWorkerError>(resolver, executionContext)); |
105 return promise; | 109 return promise; |
106 } | 110 } |
107 | 111 |
108 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t) | 112 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t) |
109 : m_provider(ServiceWorkerContainerClient::from(executionContext)->provider( )) | 113 : m_provider(0) |
dominicc (has gone to gerrit)
2014/03/31 04:52:09
Why use nullptr sometimes and 0 other times?
kinuko
2014/03/31 12:33:05
Some compilers don't accept assigning nullptr to a
| |
110 { | 114 { |
111 ScriptWrappable::init(this); | 115 ScriptWrappable::init(this); |
112 m_provider->setClient(this); | 116 |
117 if (ServiceWorkerContainerClient::from(executionContext)) { | |
dominicc (has gone to gerrit)
2014/03/31 04:52:09
More idiomatic Blink would be something like:
if
kinuko
2014/03/31 12:33:05
Done.
| |
118 m_provider = ServiceWorkerContainerClient::from(executionContext)->provi der(); | |
119 if (m_provider) | |
120 m_provider->setClient(this); | |
121 } | |
113 } | 122 } |
114 | 123 |
115 } // namespace WebCore | 124 } // namespace WebCore |
OLD | NEW |