| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 if (!documentOrigin->canRequest(scriptURL)) { | 117 if (!documentOrigin->canRequest(scriptURL)) { |
| 118 resolver->reject(DOMException::create(SecurityError, "The origin of the
script must match the current origin.")); | 118 resolver->reject(DOMException::create(SecurityError, "The origin of the
script must match the current origin.")); |
| 119 return promise; | 119 return promise; |
| 120 } | 120 } |
| 121 | 121 |
| 122 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise
Adapter<ServiceWorkerRegistration, ServiceWorkerError>(resolver)); | 122 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise
Adapter<ServiceWorkerRegistration, ServiceWorkerError>(resolver)); |
| 123 | 123 |
| 124 return promise; | 124 return promise; |
| 125 } | 125 } |
| 126 | 126 |
| 127 class UndefinedValue { | |
| 128 public: | |
| 129 typedef WebServiceWorkerRegistration WebType; | |
| 130 static V8UndefinedType take(ScriptPromiseResolver* resolver, WebType* regist
ration) | |
| 131 { | |
| 132 ASSERT(!registration); // Anything passed here will be leaked. | |
| 133 return V8UndefinedType(); | |
| 134 } | |
| 135 static void dispose(WebType* registration) | |
| 136 { | |
| 137 ASSERT(!registration); // Anything passed here will be leaked. | |
| 138 } | |
| 139 | |
| 140 private: | |
| 141 UndefinedValue(); | |
| 142 }; | |
| 143 | |
| 144 class BooleanValue { | 127 class BooleanValue { |
| 145 public: | 128 public: |
| 146 typedef bool WebType; | 129 typedef bool WebType; |
| 147 static bool take(ScriptPromiseResolver* resolver, WebType* boolean) | 130 static bool take(ScriptPromiseResolver* resolver, WebType* boolean) |
| 148 { | 131 { |
| 149 return *boolean; | 132 return *boolean; |
| 150 } | 133 } |
| 151 static void dispose(WebType* boolean) | 134 static void dispose(WebType* boolean) |
| 152 { | 135 { |
| 153 } | 136 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 175 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); | 158 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); |
| 176 return promise; | 159 return promise; |
| 177 } | 160 } |
| 178 | 161 |
| 179 KURL patternURL = scriptState->executionContext()->completeURL(pattern); | 162 KURL patternURL = scriptState->executionContext()->completeURL(pattern); |
| 180 patternURL.removeFragmentIdentifier(); | 163 patternURL.removeFragmentIdentifier(); |
| 181 if (!pattern.isEmpty() && !documentOrigin->canRequest(patternURL)) { | 164 if (!pattern.isEmpty() && !documentOrigin->canRequest(patternURL)) { |
| 182 resolver->reject(DOMException::create(SecurityError, "The scope must mat
ch the current origin.")); | 165 resolver->reject(DOMException::create(SecurityError, "The scope must mat
ch the current origin.")); |
| 183 return promise; | 166 return promise; |
| 184 } | 167 } |
| 185 #ifdef DISABLE_SERVICEWORKER_UNREGISTER_RESOLVE_TO_BOOLEAN | |
| 186 m_provider->unregisterServiceWorker(patternURL, new CallbackPromiseAdapter<U
ndefinedValue, ServiceWorkerError>(resolver)); | |
| 187 #else | |
| 188 m_provider->unregisterServiceWorker(patternURL, new CallbackPromiseAdapter<B
ooleanValue, ServiceWorkerError>(resolver)); | 168 m_provider->unregisterServiceWorker(patternURL, new CallbackPromiseAdapter<B
ooleanValue, ServiceWorkerError>(resolver)); |
| 189 #endif | |
| 190 return promise; | 169 return promise; |
| 191 } | 170 } |
| 192 | 171 |
| 193 ServiceWorkerContainer::ReadyProperty* ServiceWorkerContainer::createReadyProper
ty() | 172 ServiceWorkerContainer::ReadyProperty* ServiceWorkerContainer::createReadyProper
ty() |
| 194 { | 173 { |
| 195 return new ReadyProperty(executionContext(), this, ReadyProperty::Ready); | 174 return new ReadyProperty(executionContext(), this, ReadyProperty::Ready); |
| 196 } | 175 } |
| 197 | 176 |
| 198 ScriptPromise ServiceWorkerContainer::ready(ScriptState* callerState) | 177 ScriptPromise ServiceWorkerContainer::ready(ScriptState* callerState) |
| 199 { | 178 { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 m_ready = createReadyProperty(); | 274 m_ready = createReadyProperty(); |
| 296 | 275 |
| 297 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { | 276 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { |
| 298 m_provider = client->provider(); | 277 m_provider = client->provider(); |
| 299 if (m_provider) | 278 if (m_provider) |
| 300 m_provider->setClient(this); | 279 m_provider->setClient(this); |
| 301 } | 280 } |
| 302 } | 281 } |
| 303 | 282 |
| 304 } // namespace blink | 283 } // namespace blink |
| OLD | NEW |