OLD | NEW |
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 namespace WebCore { | 58 namespace WebCore { |
59 | 59 |
60 PassRefPtr<ServiceWorkerContainer> ServiceWorkerContainer::create(ExecutionConte
xt* executionContext) | 60 PassRefPtr<ServiceWorkerContainer> ServiceWorkerContainer::create(ExecutionConte
xt* executionContext) |
61 { | 61 { |
62 return adoptRef(new ServiceWorkerContainer(executionContext)); | 62 return adoptRef(new ServiceWorkerContainer(executionContext)); |
63 } | 63 } |
64 | 64 |
65 ServiceWorkerContainer::~ServiceWorkerContainer() | 65 ServiceWorkerContainer::~ServiceWorkerContainer() |
66 { | 66 { |
| 67 ASSERT(!m_provider); |
67 } | 68 } |
68 | 69 |
69 void ServiceWorkerContainer::detachClient() | 70 void ServiceWorkerContainer::detachClient() |
70 { | 71 { |
71 if (m_provider) { | 72 if (m_provider) { |
72 m_provider->setClient(0); | 73 m_provider->setClient(0); |
73 m_provider = 0; | 74 m_provider = 0; |
74 } | 75 } |
75 } | 76 } |
76 | 77 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 { | 183 { |
183 if (!executionContext()) { | 184 if (!executionContext()) { |
184 deleteIfNoExistingOwner(serviceWorker); | 185 deleteIfNoExistingOwner(serviceWorker); |
185 return; | 186 return; |
186 } | 187 } |
187 m_controller = ServiceWorker::from(executionContext(), serviceWorker); | 188 m_controller = ServiceWorker::from(executionContext(), serviceWorker); |
188 } | 189 } |
189 | 190 |
190 void ServiceWorkerContainer::dispatchMessageEvent(const blink::WebString& messag
e, const blink::WebMessagePortChannelArray& webChannels) | 191 void ServiceWorkerContainer::dispatchMessageEvent(const blink::WebString& messag
e, const blink::WebMessagePortChannelArray& webChannels) |
191 { | 192 { |
192 if (!executionContext() || !window()) | 193 if (!executionContext() || !executionContext()->executingWindow()) |
193 return; | 194 return; |
194 | 195 |
195 OwnPtr<MessagePortArray> ports = MessagePort::toMessagePortArray(executionCo
ntext(), webChannels); | 196 OwnPtr<MessagePortArray> ports = MessagePort::toMessagePortArray(executionCo
ntext(), webChannels); |
196 RefPtr<SerializedScriptValue> value = SerializedScriptValue::createFromWire(
message); | 197 RefPtr<SerializedScriptValue> value = SerializedScriptValue::createFromWire(
message); |
197 window()->dispatchEvent(MessageEvent::create(ports.release(), value)); | 198 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po
rts.release(), value)); |
198 } | 199 } |
199 | 200 |
200 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex
t) | 201 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex
t) |
201 : ContextLifecycleObserver(executionContext) | 202 : ContextLifecycleObserver(executionContext) |
202 , DOMWindowLifecycleObserver(executionContext->isDocument() ? toDocument(exe
cutionContext)->domWindow() : 0) | |
203 , m_provider(0) | 203 , m_provider(0) |
204 { | 204 { |
205 ScriptWrappable::init(this); | 205 ScriptWrappable::init(this); |
206 | 206 |
207 if (!executionContext) | 207 if (!executionContext) |
208 return; | 208 return; |
209 | 209 |
210 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { | 210 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { |
211 m_provider = client->provider(); | 211 m_provider = client->provider(); |
212 if (m_provider) | 212 if (m_provider) |
213 m_provider->setClient(this); | 213 m_provider->setClient(this); |
214 } | 214 } |
215 } | 215 } |
216 | 216 |
217 } // namespace WebCore | 217 } // namespace WebCore |
OLD | NEW |