Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 413123002: ServiceWorker: Implement ServiceWorkerRegistration [1/3] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix for tkent's comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/modules/modules.gypi ('k') | Source/modules/serviceworkers/ServiceWorkerRegistration.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
37 #include "bindings/core/v8/SerializedScriptValue.h" 37 #include "bindings/core/v8/SerializedScriptValue.h"
38 #include "core/dom/DOMException.h" 38 #include "core/dom/DOMException.h"
39 #include "core/dom/ExceptionCode.h" 39 #include "core/dom/ExceptionCode.h"
40 #include "core/dom/ExecutionContext.h" 40 #include "core/dom/ExecutionContext.h"
41 #include "core/dom/MessagePort.h" 41 #include "core/dom/MessagePort.h"
42 #include "core/events/MessageEvent.h" 42 #include "core/events/MessageEvent.h"
43 #include "modules/serviceworkers/RegistrationOptionList.h" 43 #include "modules/serviceworkers/RegistrationOptionList.h"
44 #include "modules/serviceworkers/ServiceWorker.h" 44 #include "modules/serviceworkers/ServiceWorker.h"
45 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 45 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
46 #include "modules/serviceworkers/ServiceWorkerError.h" 46 #include "modules/serviceworkers/ServiceWorkerError.h"
47 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
47 #include "platform/RuntimeEnabledFeatures.h" 48 #include "platform/RuntimeEnabledFeatures.h"
48 #include "public/platform/WebServiceWorker.h" 49 #include "public/platform/WebServiceWorker.h"
49 #include "public/platform/WebServiceWorkerProvider.h" 50 #include "public/platform/WebServiceWorkerProvider.h"
50 #include "public/platform/WebString.h" 51 #include "public/platform/WebString.h"
51 #include "public/platform/WebURL.h" 52 #include "public/platform/WebURL.h"
52 53
53 using blink::WebServiceWorker; 54 using blink::WebServiceWorker;
54 using blink::WebServiceWorkerProvider; 55 using blink::WebServiceWorkerProvider;
55 56
56 namespace blink { 57 namespace blink {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 return promise; 104 return promise;
104 } 105 }
105 106
106 KURL scriptURL = executionContext->completeURL(url); 107 KURL scriptURL = executionContext->completeURL(url);
107 scriptURL.removeFragmentIdentifier(); 108 scriptURL.removeFragmentIdentifier();
108 if (!documentOrigin->canRequest(scriptURL)) { 109 if (!documentOrigin->canRequest(scriptURL)) {
109 resolver->reject(DOMException::create(SecurityError, "Script must be in document's origin.")); 110 resolver->reject(DOMException::create(SecurityError, "Script must be in document's origin."));
110 return promise; 111 return promise;
111 } 112 }
112 113
114 #ifdef DISABLE_SERVICE_WORKER_REGISTRATION
113 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise Adapter<ServiceWorker, ServiceWorkerError>(resolver)); 115 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise Adapter<ServiceWorker, ServiceWorkerError>(resolver));
116 #else
117 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise Adapter<ServiceWorkerRegistration, ServiceWorkerError>(resolver));
118 #endif
119
114 return promise; 120 return promise;
115 } 121 }
116 122
117 class UndefinedValue { 123 class UndefinedValue {
118 public: 124 public:
125
126 #ifdef DISABLE_SERVICE_WORKER_REGISTRATION
119 typedef WebServiceWorker WebType; 127 typedef WebServiceWorker WebType;
120 static V8UndefinedType from(ScriptPromiseResolver* resolver, WebServiceWorke r* worker) 128 #else
129 typedef WebServiceWorkerRegistration WebType;
130 #endif
131 static V8UndefinedType from(ScriptPromiseResolver* resolver, WebType* regist ration)
121 { 132 {
122 ASSERT(!worker); // Anything passed here will be leaked. 133 ASSERT(!registration); // Anything passed here will be leaked.
123 return V8UndefinedType(); 134 return V8UndefinedType();
124 } 135 }
125 136
126 private: 137 private:
127 UndefinedValue(); 138 UndefinedValue();
128 }; 139 };
129 140
130 ScriptPromise ServiceWorkerContainer::unregisterServiceWorker(ScriptState* scrip tState, const String& pattern) 141 ScriptPromise ServiceWorkerContainer::unregisterServiceWorker(ScriptState* scrip tState, const String& pattern)
131 { 142 {
132 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled()); 143 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 m_ready = createReadyProperty(); 266 m_ready = createReadyProperty();
256 267
257 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 268 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
258 m_provider = client->provider(); 269 m_provider = client->provider();
259 if (m_provider) 270 if (m_provider)
260 m_provider->setClient(this); 271 m_provider->setClient(this);
261 } 272 }
262 } 273 }
263 274
264 } // namespace blink 275 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/modules.gypi ('k') | Source/modules/serviceworkers/ServiceWorkerRegistration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698