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 27 matching lines...) Expand all Loading... | |
38 #include "bindings/core/v8/V8ThrowException.h" | 38 #include "bindings/core/v8/V8ThrowException.h" |
39 #include "core/dom/DOMException.h" | 39 #include "core/dom/DOMException.h" |
40 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
41 #include "core/dom/ExceptionCode.h" | 41 #include "core/dom/ExceptionCode.h" |
42 #include "core/dom/ExecutionContext.h" | 42 #include "core/dom/ExecutionContext.h" |
43 #include "core/dom/MessagePort.h" | 43 #include "core/dom/MessagePort.h" |
44 #include "core/frame/LocalDOMWindow.h" | 44 #include "core/frame/LocalDOMWindow.h" |
45 #include "core/frame/UseCounter.h" | 45 #include "core/frame/UseCounter.h" |
46 #include "core/frame/csp/ContentSecurityPolicy.h" | 46 #include "core/frame/csp/ContentSecurityPolicy.h" |
47 #include "modules/EventTargetModules.h" | 47 #include "modules/EventTargetModules.h" |
48 #include "modules/serviceworkers/NavigatorServiceWorker.h" | |
48 #include "modules/serviceworkers/ServiceWorker.h" | 49 #include "modules/serviceworkers/ServiceWorker.h" |
49 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" | 50 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" |
50 #include "modules/serviceworkers/ServiceWorkerError.h" | 51 #include "modules/serviceworkers/ServiceWorkerError.h" |
51 #include "modules/serviceworkers/ServiceWorkerMessageEvent.h" | 52 #include "modules/serviceworkers/ServiceWorkerMessageEvent.h" |
52 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 53 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
53 #include "platform/RuntimeEnabledFeatures.h" | 54 #include "platform/RuntimeEnabledFeatures.h" |
54 #include "platform/weborigin/SchemeRegistry.h" | 55 #include "platform/weborigin/SchemeRegistry.h" |
55 #include "public/platform/WebString.h" | 56 #include "public/platform/WebString.h" |
56 #include "public/platform/WebURL.h" | 57 #include "public/platform/WebURL.h" |
57 #include "public/platform/modules/serviceworker/WebServiceWorker.h" | 58 #include "public/platform/modules/serviceworker/WebServiceWorker.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 m_ready->getExecutionContext(), WTF::wrapUnique(handle.release()))); | 117 m_ready->getExecutionContext(), WTF::wrapUnique(handle.release()))); |
117 } | 118 } |
118 } | 119 } |
119 | 120 |
120 private: | 121 private: |
121 Persistent<ReadyProperty> m_ready; | 122 Persistent<ReadyProperty> m_ready; |
122 WTF_MAKE_NONCOPYABLE(GetRegistrationForReadyCallback); | 123 WTF_MAKE_NONCOPYABLE(GetRegistrationForReadyCallback); |
123 }; | 124 }; |
124 | 125 |
125 ServiceWorkerContainer* ServiceWorkerContainer::create( | 126 ServiceWorkerContainer* ServiceWorkerContainer::create( |
126 ExecutionContext* executionContext) { | 127 ExecutionContext* executionContext, |
127 return new ServiceWorkerContainer(executionContext); | 128 NavigatorServiceWorker* navigator) { |
129 return new ServiceWorkerContainer(executionContext, navigator); | |
128 } | 130 } |
129 | 131 |
130 ServiceWorkerContainer::~ServiceWorkerContainer() { | 132 ServiceWorkerContainer::~ServiceWorkerContainer() { |
131 ASSERT(!m_provider); | 133 ASSERT(!m_provider); |
132 } | 134 } |
133 | 135 |
134 void ServiceWorkerContainer::contextDestroyed() { | 136 void ServiceWorkerContainer::contextDestroyed() { |
135 if (m_provider) { | 137 if (m_provider) { |
136 m_provider->setClient(0); | 138 m_provider->setClient(0); |
137 m_provider = nullptr; | 139 m_provider = nullptr; |
138 } | 140 } |
141 if (m_navigator) | |
Wez
2016/12/15 17:57:43
Why check m_navigator here? It doesn't look like i
haraken
2016/12/16 01:08:31
It happens only in testing. I can pass in a dummy
Wez
2016/12/16 01:28:35
That would be my suggestion, since it leads to a s
| |
142 m_navigator->clearServiceWorker(); | |
139 } | 143 } |
140 | 144 |
141 DEFINE_TRACE(ServiceWorkerContainer) { | 145 DEFINE_TRACE(ServiceWorkerContainer) { |
142 visitor->trace(m_controller); | 146 visitor->trace(m_controller); |
143 visitor->trace(m_ready); | 147 visitor->trace(m_ready); |
148 visitor->trace(m_navigator); | |
144 EventTargetWithInlineData::trace(visitor); | 149 EventTargetWithInlineData::trace(visitor); |
145 ContextLifecycleObserver::trace(visitor); | 150 ContextLifecycleObserver::trace(visitor); |
146 } | 151 } |
147 | 152 |
148 void ServiceWorkerContainer::registerServiceWorkerImpl( | 153 void ServiceWorkerContainer::registerServiceWorkerImpl( |
149 ExecutionContext* executionContext, | 154 ExecutionContext* executionContext, |
150 const KURL& rawScriptURL, | 155 const KURL& rawScriptURL, |
151 const KURL& scope, | 156 const KURL& scope, |
152 std::unique_ptr<RegistrationCallbacks> callbacks) { | 157 std::unique_ptr<RegistrationCallbacks> callbacks) { |
153 if (!m_provider) { | 158 if (!m_provider) { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 dispatchEvent(ServiceWorkerMessageEvent::create( | 457 dispatchEvent(ServiceWorkerMessageEvent::create( |
453 ports, value, source, | 458 ports, value, source, |
454 getExecutionContext()->getSecurityOrigin()->toString())); | 459 getExecutionContext()->getSecurityOrigin()->toString())); |
455 } | 460 } |
456 | 461 |
457 const AtomicString& ServiceWorkerContainer::interfaceName() const { | 462 const AtomicString& ServiceWorkerContainer::interfaceName() const { |
458 return EventTargetNames::ServiceWorkerContainer; | 463 return EventTargetNames::ServiceWorkerContainer; |
459 } | 464 } |
460 | 465 |
461 ServiceWorkerContainer::ServiceWorkerContainer( | 466 ServiceWorkerContainer::ServiceWorkerContainer( |
462 ExecutionContext* executionContext) | 467 ExecutionContext* executionContext, |
463 : ContextLifecycleObserver(executionContext), m_provider(0) { | 468 NavigatorServiceWorker* navigator) |
469 : ContextLifecycleObserver(executionContext), | |
470 m_provider(0), | |
471 m_navigator(navigator) { | |
464 if (!executionContext) | 472 if (!executionContext) |
465 return; | 473 return; |
466 | 474 |
467 if (ServiceWorkerContainerClient* client = | 475 if (ServiceWorkerContainerClient* client = |
468 ServiceWorkerContainerClient::from(executionContext)) { | 476 ServiceWorkerContainerClient::from(executionContext)) { |
469 m_provider = client->provider(); | 477 m_provider = client->provider(); |
470 if (m_provider) | 478 if (m_provider) |
471 m_provider->setClient(this); | 479 m_provider->setClient(this); |
472 } | 480 } |
473 } | 481 } |
474 | 482 |
475 } // namespace blink | 483 } // namespace blink |
OLD | NEW |