OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "ServiceWorkerRegistration.h" | 6 #include "ServiceWorkerRegistration.h" |
7 | 7 |
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 } | 30 } |
31 static void dispose(WebType* registration) | 31 static void dispose(WebType* registration) |
32 { | 32 { |
33 ASSERT(!registration); // Anything passed here will be leaked. | 33 ASSERT(!registration); // Anything passed here will be leaked. |
34 } | 34 } |
35 | 35 |
36 private: | 36 private: |
37 UndefinedValue(); | 37 UndefinedValue(); |
38 }; | 38 }; |
39 | 39 |
40 class BooleanValue { | |
41 public: | |
42 typedef bool WebType; | |
43 static bool take(ScriptPromiseResolver* resolver, WebType* boolean) | |
44 { | |
45 return boolean; | |
nhiroki
2014/08/28 10:13:21
*boolean ?
shimazu
2014/08/29 07:07:07
Done.
| |
46 } | |
47 static void dispose(WebType* boolean) | |
48 { | |
49 } | |
50 | |
51 private: | |
52 BooleanValue(); | |
53 }; | |
54 | |
40 static void deleteIfNoExistingOwner(WebServiceWorker* serviceWorker) | 55 static void deleteIfNoExistingOwner(WebServiceWorker* serviceWorker) |
41 { | 56 { |
42 if (serviceWorker && !serviceWorker->proxy()) | 57 if (serviceWorker && !serviceWorker->proxy()) |
43 delete serviceWorker; | 58 delete serviceWorker; |
44 } | 59 } |
45 | 60 |
46 const AtomicString& ServiceWorkerRegistration::interfaceName() const | 61 const AtomicString& ServiceWorkerRegistration::interfaceName() const |
47 { | 62 { |
48 return EventTargetNames::ServiceWorkerRegistration; | 63 return EventTargetNames::ServiceWorkerRegistration; |
49 } | 64 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 } | 123 } |
109 | 124 |
110 RefPtr<SecurityOrigin> documentOrigin = scriptState->executionContext()->sec urityOrigin(); | 125 RefPtr<SecurityOrigin> documentOrigin = scriptState->executionContext()->sec urityOrigin(); |
111 KURL scopeURL = scriptState->executionContext()->completeURL(scope()); | 126 KURL scopeURL = scriptState->executionContext()->completeURL(scope()); |
112 scopeURL.removeFragmentIdentifier(); | 127 scopeURL.removeFragmentIdentifier(); |
113 if (!scope().isEmpty() && !documentOrigin->canRequest(scopeURL)) { | 128 if (!scope().isEmpty() && !documentOrigin->canRequest(scopeURL)) { |
114 resolver->reject(DOMException::create(SecurityError, "Can only unregiste r for scopes in the document's origin.")); | 129 resolver->reject(DOMException::create(SecurityError, "Can only unregiste r for scopes in the document's origin.")); |
115 return promise; | 130 return promise; |
116 } | 131 } |
117 | 132 |
133 #ifdef SERVICEWORKER_UNREGISTER_DISABLE_NEW_FEATURE | |
118 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<Und efinedValue, ServiceWorkerError>(resolver)); | 134 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<Und efinedValue, ServiceWorkerError>(resolver)); |
135 #else | |
136 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<Boo leanValue, ServiceWorkerError>(resolver)); | |
137 #endif | |
119 return promise; | 138 return promise; |
120 } | 139 } |
121 | 140 |
122 PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::get OrCreate(ExecutionContext* executionContext, WebServiceWorkerRegistration* outer Registration) | 141 PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::get OrCreate(ExecutionContext* executionContext, WebServiceWorkerRegistration* outer Registration) |
123 { | 142 { |
124 if (!outerRegistration) | 143 if (!outerRegistration) |
125 return nullptr; | 144 return nullptr; |
126 | 145 |
127 WebServiceWorkerRegistrationProxy* proxy = outerRegistration->proxy(); | 146 WebServiceWorkerRegistrationProxy* proxy = outerRegistration->proxy(); |
128 if (proxy) { | 147 if (proxy) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 | 189 |
171 void ServiceWorkerRegistration::stop() | 190 void ServiceWorkerRegistration::stop() |
172 { | 191 { |
173 if (m_stopped) | 192 if (m_stopped) |
174 return; | 193 return; |
175 m_stopped = true; | 194 m_stopped = true; |
176 m_outerRegistration->proxyStopped(); | 195 m_outerRegistration->proxyStopped(); |
177 } | 196 } |
178 | 197 |
179 } // namespace blink | 198 } // namespace blink |
OLD | NEW |