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

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerRegistration.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: Incorporate the reviews 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 // 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"
11 #include "bindings/core/v8/ScriptState.h" 11 #include "bindings/core/v8/ScriptState.h"
12 #include "core/dom/DOMException.h" 12 #include "core/dom/DOMException.h"
13 #include "core/dom/ExceptionCode.h" 13 #include "core/dom/ExceptionCode.h"
14 #include "core/dom/ExecutionContext.h" 14 #include "core/dom/ExecutionContext.h"
15 #include "core/events/Event.h" 15 #include "core/events/Event.h"
16 #include "modules/EventTargetModules.h" 16 #include "modules/EventTargetModules.h"
17 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 17 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
18 #include "modules/serviceworkers/ServiceWorkerError.h" 18 #include "modules/serviceworkers/ServiceWorkerError.h"
19 #include "public/platform/WebServiceWorkerProvider.h" 19 #include "public/platform/WebServiceWorkerProvider.h"
20 20
21 namespace blink { 21 namespace blink {
22 22
23 class UndefinedValue { 23 class UndefinedValue {
horo 2014/08/29 07:18:35 I think the class definition of UndefinedValue and
shimazu 2014/09/01 05:13:47 Done.
24 public: 24 public:
25 typedef WebServiceWorkerRegistration WebType; 25 typedef WebServiceWorkerRegistration WebType;
26 static V8UndefinedType take(ScriptPromiseResolver* resolver, WebType* regist ration) 26 static V8UndefinedType take(ScriptPromiseResolver* resolver, WebType* regist ration)
27 { 27 {
28 ASSERT(!registration); // Anything passed here will be leaked. 28 ASSERT(!registration); // Anything passed here will be leaked.
29 return V8UndefinedType(); 29 return V8UndefinedType();
30 } 30 }
31 static void dispose(WebType* registration) 31 static void dispose(WebType* registration)
32 { 32 {
33 ASSERT(!registration); // Anything passed here will be leaked. 33 ASSERT(!registration); // Anything passed here will be leaked.
34 } 34 }
35 35
36 private: 36 private:
37 UndefinedValue(); 37 UndefinedValue();
38 }; 38 };
39 39
40 class BooleanValue {
41 public:
42 typedef bool WebType;
43 static bool take(ScriptPromiseResolver* resolver, WebType* boolean)
44 {
45 return *boolean;
46 }
47 static void dispose(WebType* boolean)
48 {
49 }
nhiroki 2014/08/29 07:17:53 ditto.
shimazu 2014/09/01 05:13:47 Done.
50
51 private:
52 BooleanValue();
53 };
54
40 static void deleteIfNoExistingOwner(WebServiceWorker* serviceWorker) 55 static void deleteIfNoExistingOwner(WebServiceWorker* serviceWorker)
41 { 56 {
42 if (serviceWorker && !serviceWorker->proxy()) 57 if (serviceWorker && !serviceWorker->proxy())
43 delete serviceWorker; 58 delete serviceWorker;
44 } 59 }
45 60
46 const AtomicString& ServiceWorkerRegistration::interfaceName() const 61 const AtomicString& ServiceWorkerRegistration::interfaceName() const
47 { 62 {
48 return EventTargetNames::ServiceWorkerRegistration; 63 return EventTargetNames::ServiceWorkerRegistration;
49 } 64 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 123 }
109 124
110 RefPtr<SecurityOrigin> documentOrigin = scriptState->executionContext()->sec urityOrigin(); 125 RefPtr<SecurityOrigin> documentOrigin = scriptState->executionContext()->sec urityOrigin();
111 KURL scopeURL = scriptState->executionContext()->completeURL(scope()); 126 KURL scopeURL = scriptState->executionContext()->completeURL(scope());
112 scopeURL.removeFragmentIdentifier(); 127 scopeURL.removeFragmentIdentifier();
113 if (!scope().isEmpty() && !documentOrigin->canRequest(scopeURL)) { 128 if (!scope().isEmpty() && !documentOrigin->canRequest(scopeURL)) {
114 resolver->reject(DOMException::create(SecurityError, "Can only unregiste r for scopes in the document's origin.")); 129 resolver->reject(DOMException::create(SecurityError, "Can only unregiste r for scopes in the document's origin."));
115 return promise; 130 return promise;
116 } 131 }
117 132
133 #ifdef DISABLE_SERVICEWORKER_UNREGISTER_RESOLVE_TO_BOOLEAN
118 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<Und efinedValue, ServiceWorkerError>(resolver)); 134 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<Und efinedValue, ServiceWorkerError>(resolver));
135 #else
136 m_provider->unregisterServiceWorker(scopeURL, new CallbackPromiseAdapter<Boo leanValue, ServiceWorkerError>(resolver));
137 #endif
119 return promise; 138 return promise;
120 } 139 }
121 140
122 PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::get OrCreate(ExecutionContext* executionContext, WebServiceWorkerRegistration* outer Registration) 141 PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::get OrCreate(ExecutionContext* executionContext, WebServiceWorkerRegistration* outer Registration)
123 { 142 {
124 if (!outerRegistration) 143 if (!outerRegistration)
125 return nullptr; 144 return nullptr;
126 145
127 WebServiceWorkerRegistrationProxy* proxy = outerRegistration->proxy(); 146 WebServiceWorkerRegistrationProxy* proxy = outerRegistration->proxy();
128 if (proxy) { 147 if (proxy) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 189
171 void ServiceWorkerRegistration::stop() 190 void ServiceWorkerRegistration::stop()
172 { 191 {
173 if (m_stopped) 192 if (m_stopped)
174 return; 193 return;
175 m_stopped = true; 194 m_stopped = true;
176 m_outerRegistration->proxyStopped(); 195 m_outerRegistration->proxyStopped();
177 } 196 }
178 197
179 } // namespace blink 198 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698