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

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

Issue 1185483003: ServiceWorker: Route unregister() through WebServiceWorkerRegistration for refactoring (1) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | public/platform/WebServiceWorkerProvider.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 // 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 ScriptPromise ServiceWorkerRegistration::unregister(ScriptState* scriptState) 98 ScriptPromise ServiceWorkerRegistration::unregister(ScriptState* scriptState)
99 { 99 {
100 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 100 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
101 ScriptPromise promise = resolver->promise(); 101 ScriptPromise promise = resolver->promise();
102 102
103 if (!m_provider) { 103 if (!m_provider) {
104 resolver->reject(DOMException::create(InvalidStateError, "Failed to unre gister a ServiceWorkerRegistration: No associated provider is available.")); 104 resolver->reject(DOMException::create(InvalidStateError, "Failed to unre gister a ServiceWorkerRegistration: No associated provider is available."));
105 return promise; 105 return promise;
106 } 106 }
107 107
108 #ifdef CRBUG_500404
kinuko 2015/06/16 00:37:54 Why do we have these ifdef's in the same patch whe
nhiroki 2015/06/16 01:03:49 Right, this should be moved to the third CL. Done.
108 RefPtr<SecurityOrigin> documentOrigin = scriptState->executionContext()->sec urityOrigin(); 109 RefPtr<SecurityOrigin> documentOrigin = scriptState->executionContext()->sec urityOrigin();
109 KURL scopeURL = scriptState->executionContext()->completeURL(scope()); 110 KURL scopeURL = scriptState->executionContext()->completeURL(scope());
110 scopeURL.removeFragmentIdentifier(); 111 scopeURL.removeFragmentIdentifier();
111 if (!scope().isEmpty() && !documentOrigin->canRequest(scopeURL)) { 112 if (!scope().isEmpty() && !documentOrigin->canRequest(scopeURL)) {
112 RefPtr<SecurityOrigin> scopeOrigin = SecurityOrigin::create(scopeURL); 113 RefPtr<SecurityOrigin> scopeOrigin = SecurityOrigin::create(scopeURL);
113 resolver->reject(DOMException::create(SecurityError, "Failed to unregist er a ServiceWorkerRegistration: The origin of the registration's scope ('" + sco peOrigin->toString() + "') does not match the current origin ('" + documentOrigi n->toString() + "').")); 114 resolver->reject(DOMException::create(SecurityError, "Failed to unregist er a ServiceWorkerRegistration: The origin of the registration's scope ('" + sco peOrigin->toString() + "') does not match the current origin ('" + documentOrigi n->toString() + "')."));
114 return promise; 115 return promise;
115 } 116 }
116 117
117 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<boo l, ServiceWorkerError>(resolver)); 118 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<boo l, ServiceWorkerError>(resolver));
119 #else
120 m_outerRegistration->unregister(m_provider, new CallbackPromiseAdapter<bool, ServiceWorkerError>(resolver));
121 #endif
118 return promise; 122 return promise;
119 } 123 }
120 124
121 ServiceWorkerRegistration* ServiceWorkerRegistration::getOrCreate(ExecutionConte xt* executionContext, WebServiceWorkerRegistration* outerRegistration) 125 ServiceWorkerRegistration* ServiceWorkerRegistration::getOrCreate(ExecutionConte xt* executionContext, WebServiceWorkerRegistration* outerRegistration)
122 { 126 {
123 if (!outerRegistration) 127 if (!outerRegistration)
124 return 0; 128 return 0;
125 129
126 ServiceWorkerRegistration* existingRegistration = static_cast<ServiceWorkerR egistration*>(outerRegistration->proxy()); 130 ServiceWorkerRegistration* existingRegistration = static_cast<ServiceWorkerR egistration*>(outerRegistration->proxy());
127 if (existingRegistration) { 131 if (existingRegistration) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 174
171 void ServiceWorkerRegistration::stop() 175 void ServiceWorkerRegistration::stop()
172 { 176 {
173 if (m_stopped) 177 if (m_stopped)
174 return; 178 return;
175 m_stopped = true; 179 m_stopped = true;
176 m_outerRegistration->proxyStopped(); 180 m_outerRegistration->proxyStopped();
177 } 181 }
178 182
179 } // namespace blink 183 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | public/platform/WebServiceWorkerProvider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698