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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 visitor->trace(m_ready); | 148 visitor->trace(m_ready); |
149 visitor->trace(m_navigator); | 149 visitor->trace(m_navigator); |
150 EventTargetWithInlineData::trace(visitor); | 150 EventTargetWithInlineData::trace(visitor); |
151 ContextLifecycleObserver::trace(visitor); | 151 ContextLifecycleObserver::trace(visitor); |
152 } | 152 } |
153 | 153 |
154 void ServiceWorkerContainer::registerServiceWorkerImpl( | 154 void ServiceWorkerContainer::registerServiceWorkerImpl( |
155 ExecutionContext* executionContext, | 155 ExecutionContext* executionContext, |
156 const KURL& rawScriptURL, | 156 const KURL& rawScriptURL, |
157 const KURL& scope, | 157 const KURL& scope, |
| 158 bool useCache, |
158 std::unique_ptr<RegistrationCallbacks> callbacks) { | 159 std::unique_ptr<RegistrationCallbacks> callbacks) { |
159 if (!m_provider) { | 160 if (!m_provider) { |
160 callbacks->onError( | 161 callbacks->onError( |
161 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeState, | 162 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeState, |
162 "Failed to register a ServiceWorker: The " | 163 "Failed to register a ServiceWorker: The " |
163 "document is in an invalid state.")); | 164 "document is in an invalid state.")); |
164 return; | 165 return; |
165 } | 166 } |
166 | 167 |
167 RefPtr<SecurityOrigin> documentOrigin = executionContext->getSecurityOrigin(); | 168 RefPtr<SecurityOrigin> documentOrigin = executionContext->getSecurityOrigin(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 callbacks->onError(WebServiceWorkerError( | 253 callbacks->onError(WebServiceWorkerError( |
253 WebServiceWorkerError::ErrorTypeSecurity, | 254 WebServiceWorkerError::ErrorTypeSecurity, |
254 String( | 255 String( |
255 "Failed to register a ServiceWorker: The provided scriptURL ('" + | 256 "Failed to register a ServiceWorker: The provided scriptURL ('" + |
256 scriptURL.getString() + | 257 scriptURL.getString() + |
257 "') violates the Content Security Policy."))); | 258 "') violates the Content Security Policy."))); |
258 return; | 259 return; |
259 } | 260 } |
260 } | 261 } |
261 | 262 |
262 m_provider->registerServiceWorker(patternURL, scriptURL, | 263 m_provider->registerServiceWorker(patternURL, scriptURL, useCache, |
263 std::move(callbacks)); | 264 std::move(callbacks)); |
264 } | 265 } |
265 | 266 |
266 ScriptPromise ServiceWorkerContainer::registerServiceWorker( | 267 ScriptPromise ServiceWorkerContainer::registerServiceWorker( |
267 ScriptState* scriptState, | 268 ScriptState* scriptState, |
268 const String& url, | 269 const String& url, |
269 const RegistrationOptions& options) { | 270 const RegistrationOptions& options) { |
270 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 271 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
271 ScriptPromise promise = resolver->promise(); | 272 ScriptPromise promise = resolver->promise(); |
272 | 273 |
(...skipping 12 matching lines...) Expand all Loading... |
285 | 286 |
286 KURL scriptURL = executionContext->completeURL(url); | 287 KURL scriptURL = executionContext->completeURL(url); |
287 scriptURL.removeFragmentIdentifier(); | 288 scriptURL.removeFragmentIdentifier(); |
288 | 289 |
289 KURL patternURL; | 290 KURL patternURL; |
290 if (options.scope().isNull()) | 291 if (options.scope().isNull()) |
291 patternURL = KURL(scriptURL, "./"); | 292 patternURL = KURL(scriptURL, "./"); |
292 else | 293 else |
293 patternURL = executionContext->completeURL(options.scope()); | 294 patternURL = executionContext->completeURL(options.scope()); |
294 | 295 |
| 296 bool useCache = options.useCache(); |
| 297 |
295 registerServiceWorkerImpl( | 298 registerServiceWorkerImpl( |
296 executionContext, scriptURL, patternURL, | 299 executionContext, scriptURL, patternURL, useCache, |
297 WTF::makeUnique<CallbackPromiseAdapter<ServiceWorkerRegistration, | 300 WTF::makeUnique<CallbackPromiseAdapter<ServiceWorkerRegistration, |
298 ServiceWorkerErrorForUpdate>>( | 301 ServiceWorkerErrorForUpdate>>( |
299 resolver)); | 302 resolver)); |
300 | 303 |
301 return promise; | 304 return promise; |
302 } | 305 } |
303 | 306 |
304 ScriptPromise ServiceWorkerContainer::getRegistration( | 307 ScriptPromise ServiceWorkerContainer::getRegistration( |
305 ScriptState* scriptState, | 308 ScriptState* scriptState, |
306 const String& documentURL) { | 309 const String& documentURL) { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 486 |
484 if (ServiceWorkerContainerClient* client = | 487 if (ServiceWorkerContainerClient* client = |
485 ServiceWorkerContainerClient::from(executionContext)) { | 488 ServiceWorkerContainerClient::from(executionContext)) { |
486 m_provider = client->provider(); | 489 m_provider = client->provider(); |
487 if (m_provider) | 490 if (m_provider) |
488 m_provider->setClient(this); | 491 m_provider->setClient(this); |
489 } | 492 } |
490 } | 493 } |
491 | 494 |
492 } // namespace blink | 495 } // namespace blink |
OLD | NEW |