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

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

Issue 313553002: Add the navigator.serviceWorker.waiting property. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Bring patch to head. Created 6 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 | Annotate | Revision Log
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // FIXME: Elaborate the implementation when the "waiting" property 153 // FIXME: Elaborate the implementation when the "waiting" property
154 // or replace() is implemented. 154 // or replace() is implemented.
155 return ScriptPromise(); 155 return ScriptPromise();
156 } 156 }
157 157
158 void ServiceWorkerContainer::setCurrentServiceWorker(blink::WebServiceWorker* se rviceWorker) 158 void ServiceWorkerContainer::setCurrentServiceWorker(blink::WebServiceWorker* se rviceWorker)
159 { 159 {
160 setController(serviceWorker); 160 setController(serviceWorker);
161 } 161 }
162 162
163 // If the WebServiceWorker is up for adoption (does not have a
164 // WebServiceWorkerProxy owner), rejects the adoption by deleting the
165 // WebServiceWorker.
166 static void deleteIfNoExistingOwner(blink::WebServiceWorker* serviceWorker)
167 {
168 if (serviceWorker && !serviceWorker->proxy())
169 delete serviceWorker;
170 }
171
172 void ServiceWorkerContainer::setWaiting(blink::WebServiceWorker* serviceWorker)
173 {
174 if (!executionContext()) {
175 deleteIfNoExistingOwner(serviceWorker);
176 return;
177 }
178 m_waiting = ServiceWorker::from(executionContext(), serviceWorker);
179 }
180
163 void ServiceWorkerContainer::setController(blink::WebServiceWorker* serviceWorke r) 181 void ServiceWorkerContainer::setController(blink::WebServiceWorker* serviceWorke r)
164 { 182 {
165 if (!executionContext()) { 183 if (!executionContext()) {
166 delete serviceWorker; 184 deleteIfNoExistingOwner(serviceWorker);
167 return; 185 return;
168 } 186 }
169 m_controller = ServiceWorker::create(executionContext(), adoptPtr(serviceWor ker)); 187 m_controller = ServiceWorker::from(executionContext(), serviceWorker);
170 } 188 }
171 189
172 void ServiceWorkerContainer::dispatchMessageEvent(const blink::WebString& messag e, const blink::WebMessagePortChannelArray& webChannels) 190 void ServiceWorkerContainer::dispatchMessageEvent(const blink::WebString& messag e, const blink::WebMessagePortChannelArray& webChannels)
173 { 191 {
174 if (!executionContext() || !window()) 192 if (!executionContext() || !window())
175 return; 193 return;
176 194
177 OwnPtr<MessagePortArray> ports = MessagePort::toMessagePortArray(executionCo ntext(), webChannels); 195 OwnPtr<MessagePortArray> ports = MessagePort::toMessagePortArray(executionCo ntext(), webChannels);
178 RefPtr<SerializedScriptValue> value = SerializedScriptValue::createFromWire( message); 196 RefPtr<SerializedScriptValue> value = SerializedScriptValue::createFromWire( message);
179 window()->dispatchEvent(MessageEvent::create(ports.release(), value)); 197 window()->dispatchEvent(MessageEvent::create(ports.release(), value));
(...skipping 10 matching lines...) Expand all
190 return; 208 return;
191 209
192 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 210 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
193 m_provider = client->provider(); 211 m_provider = client->provider();
194 if (m_provider) 212 if (m_provider)
195 m_provider->setClient(this); 213 m_provider->setClient(this);
196 } 214 }
197 } 215 }
198 216
199 } // namespace WebCore 217 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.h ('k') | Source/modules/serviceworkers/ServiceWorkerContainer.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698