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

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

Issue 476043002: ServiceWorker: Make '.ready' return a promise to be resolved with ServiceWorkerRegistration (1/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix win build 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"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 void ServiceWorkerRegistration::setActive(WebServiceWorker* serviceWorker) 89 void ServiceWorkerRegistration::setActive(WebServiceWorker* serviceWorker)
90 { 90 {
91 if (!executionContext()) { 91 if (!executionContext()) {
92 deleteIfNoExistingOwner(serviceWorker); 92 deleteIfNoExistingOwner(serviceWorker);
93 return; 93 return;
94 } 94 }
95 m_active = ServiceWorker::from(executionContext(), serviceWorker); 95 m_active = ServiceWorker::from(executionContext(), serviceWorker);
96 } 96 }
97 97
98 PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::fro m(ExecutionContext* executionContext, WebType* registration)
99 {
100 if (!registration)
101 return nullptr;
102 return getOrCreate(executionContext, registration);
103 }
104
98 PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::tak e(ScriptPromiseResolver* resolver, WebType* registration) 105 PassRefPtrWillBeRawPtr<ServiceWorkerRegistration> ServiceWorkerRegistration::tak e(ScriptPromiseResolver* resolver, WebType* registration)
99 { 106 {
100 if (!registration) 107 return from(resolver->scriptState()->executionContext(), registration);
101 return nullptr;
102 return getOrCreate(resolver->scriptState()->executionContext(), registration );
103 } 108 }
104 109
105 void ServiceWorkerRegistration::dispose(WebType* registration) 110 void ServiceWorkerRegistration::dispose(WebType* registration)
106 { 111 {
107 delete registration; 112 delete registration;
108 } 113 }
109 114
110 String ServiceWorkerRegistration::scope() const 115 String ServiceWorkerRegistration::scope() const
111 { 116 {
112 return m_outerRegistration->scope().string(); 117 return m_outerRegistration->scope().string();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 194
190 void ServiceWorkerRegistration::stop() 195 void ServiceWorkerRegistration::stop()
191 { 196 {
192 if (m_stopped) 197 if (m_stopped)
193 return; 198 return;
194 m_stopped = true; 199 m_stopped = true;
195 m_outerRegistration->proxyStopped(); 200 m_outerRegistration->proxyStopped();
196 } 201 }
197 202
198 } // namespace blink 203 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698