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

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

Issue 515083002: ServiceWorker: Change the return value of ServiceWorkerRegistration::unregister to boolean (1/4) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Apply 3-sided patch format Created 6 years, 3 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
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 134 }
135 static void dispose(WebType* registration) 135 static void dispose(WebType* registration)
136 { 136 {
137 ASSERT(!registration); // Anything passed here will be leaked. 137 ASSERT(!registration); // Anything passed here will be leaked.
138 } 138 }
139 139
140 private: 140 private:
141 UndefinedValue(); 141 UndefinedValue();
142 }; 142 };
143 143
144 class BooleanValue {
145 public:
146 typedef bool WebType;
147 static bool take(ScriptPromiseResolver* resolver, WebType* boolean)
148 {
149 return boolean;
150 }
151 static void dispose(WebType* boolean)
152 {
153 }
154
155 private:
156 BooleanValue();
157 };
158
144 ScriptPromise ServiceWorkerContainer::unregisterServiceWorker(ScriptState* scrip tState, const String& pattern) 159 ScriptPromise ServiceWorkerContainer::unregisterServiceWorker(ScriptState* scrip tState, const String& pattern)
145 { 160 {
146 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled()); 161 ASSERT(RuntimeEnabledFeatures::serviceWorkerEnabled());
147 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); 162 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState);
148 ScriptPromise promise = resolver->promise(); 163 ScriptPromise promise = resolver->promise();
149 164
150 if (!m_provider) { 165 if (!m_provider) {
151 resolver->reject(DOMException::create(InvalidStateError, "No associated provider is available")); 166 resolver->reject(DOMException::create(InvalidStateError, "No associated provider is available"));
152 return promise; 167 return promise;
153 } 168 }
154 169
155 // FIXME: This should use the container's execution context, not 170 // FIXME: This should use the container's execution context, not
156 // the callers. 171 // the callers.
157 RefPtr<SecurityOrigin> documentOrigin = scriptState->executionContext()->sec urityOrigin(); 172 RefPtr<SecurityOrigin> documentOrigin = scriptState->executionContext()->sec urityOrigin();
158 String errorMessage; 173 String errorMessage;
159 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) { 174 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) {
160 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); 175 resolver->reject(DOMException::create(NotSupportedError, errorMessage));
161 return promise; 176 return promise;
162 } 177 }
163 178
164 KURL patternURL = scriptState->executionContext()->completeURL(pattern); 179 KURL patternURL = scriptState->executionContext()->completeURL(pattern);
165 patternURL.removeFragmentIdentifier(); 180 patternURL.removeFragmentIdentifier();
166 if (!pattern.isEmpty() && !documentOrigin->canRequest(patternURL)) { 181 if (!pattern.isEmpty() && !documentOrigin->canRequest(patternURL)) {
167 resolver->reject(DOMException::create(SecurityError, "The scope must mat ch the current origin.")); 182 resolver->reject(DOMException::create(SecurityError, "The scope must mat ch the current origin."));
168 return promise; 183 return promise;
169 } 184 }
170 185 #ifdef SERVICEWORKER_UNREGISTER_DISABLE_NEW_FEATURE
nhiroki 2014/08/28 10:13:20 "NEW_FEATURE" would be ambiguous. How about "_UNRE
shimazu 2014/08/29 07:07:07 Done.
171 m_provider->unregisterServiceWorker(patternURL, new CallbackPromiseAdapter<U ndefinedValue, ServiceWorkerError>(resolver)); 186 m_provider->unregisterServiceWorker(patternURL, new CallbackPromiseAdapter<U ndefinedValue, ServiceWorkerError>(resolver));
187 #else
188 m_provider->unregisterServiceWorker(patternURL, new CallbackPromiseAdapter<B ooleanValue, ServiceWorkerError>(resolver));
189 #endif
172 return promise; 190 return promise;
173 } 191 }
174 192
175 ServiceWorkerContainer::ReadyProperty* ServiceWorkerContainer::createReadyProper ty() 193 ServiceWorkerContainer::ReadyProperty* ServiceWorkerContainer::createReadyProper ty()
176 { 194 {
177 return new ReadyProperty(executionContext(), this, ReadyProperty::Ready); 195 return new ReadyProperty(executionContext(), this, ReadyProperty::Ready);
178 } 196 }
179 197
180 ScriptPromise ServiceWorkerContainer::ready(ScriptState* callerState) 198 ScriptPromise ServiceWorkerContainer::ready(ScriptState* callerState)
181 { 199 {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 m_ready = createReadyProperty(); 295 m_ready = createReadyProperty();
278 296
279 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 297 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
280 m_provider = client->provider(); 298 m_provider = client->provider();
281 if (m_provider) 299 if (m_provider)
282 m_provider->setClient(this); 300 m_provider->setClient(this);
283 } 301 }
284 } 302 }
285 303
286 } // namespace blink 304 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698