| OLD | NEW |
| 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 "modules/serviceworkers/NavigatorServiceWorker.h" | 6 #include "modules/serviceworkers/NavigatorServiceWorker.h" |
| 7 | 7 |
| 8 #include "core/frame/DOMWindow.h" |
| 9 #include "core/frame/LocalFrame.h" |
| 8 #include "core/frame/Navigator.h" | 10 #include "core/frame/Navigator.h" |
| 9 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 11 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
| 10 | 12 |
| 11 namespace WebCore { | 13 namespace WebCore { |
| 12 | 14 |
| 13 NavigatorServiceWorker::NavigatorServiceWorker(Navigator& navigator) | 15 NavigatorServiceWorker::NavigatorServiceWorker(Navigator& navigator) |
| 14 : DOMWindowProperty(navigator.frame()) | 16 : DOMWindowProperty(navigator.frame()) |
| 15 { | 17 { |
| 16 } | 18 } |
| 17 | 19 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 32 NavigatorServiceWorker* NavigatorServiceWorker::toNavigatorServiceWorker(Navigat
or& navigator) | 34 NavigatorServiceWorker* NavigatorServiceWorker::toNavigatorServiceWorker(Navigat
or& navigator) |
| 33 { | 35 { |
| 34 return static_cast<NavigatorServiceWorker*>(WillBeHeapSupplement<Navigator>:
:from(navigator, supplementName())); | 36 return static_cast<NavigatorServiceWorker*>(WillBeHeapSupplement<Navigator>:
:from(navigator, supplementName())); |
| 35 } | 37 } |
| 36 | 38 |
| 37 const char* NavigatorServiceWorker::supplementName() | 39 const char* NavigatorServiceWorker::supplementName() |
| 38 { | 40 { |
| 39 return "NavigatorServiceWorker"; | 41 return "NavigatorServiceWorker"; |
| 40 } | 42 } |
| 41 | 43 |
| 42 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(ExecutionContext*
executionContext, Navigator& navigator) | 44 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(Navigator& navigat
or) |
| 43 { | 45 { |
| 44 return NavigatorServiceWorker::from(navigator).serviceWorker(executionContex
t); | 46 return NavigatorServiceWorker::from(navigator).serviceWorker(); |
| 45 } | 47 } |
| 46 | 48 |
| 47 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(ExecutionContext*
executionContext) | 49 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker() |
| 48 { | 50 { |
| 49 if (!m_serviceWorker && frame()) | 51 if (!m_serviceWorker && frame()) { |
| 50 m_serviceWorker = ServiceWorkerContainer::create(executionContext); | 52 ASSERT(frame()->domWindow()); |
| 53 m_serviceWorker = ServiceWorkerContainer::create(frame()->domWindow()->e
xecutionContext()); |
| 54 } |
| 51 return m_serviceWorker.get(); | 55 return m_serviceWorker.get(); |
| 52 } | 56 } |
| 53 | 57 |
| 54 void NavigatorServiceWorker::willDetachGlobalObjectFromFrame() | 58 void NavigatorServiceWorker::willDetachGlobalObjectFromFrame() |
| 55 { | 59 { |
| 56 if (m_serviceWorker) { | 60 if (m_serviceWorker) { |
| 57 m_serviceWorker->detachClient(); | 61 m_serviceWorker->detachClient(); |
| 58 m_serviceWorker = nullptr; | 62 m_serviceWorker = nullptr; |
| 59 } | 63 } |
| 60 } | 64 } |
| 61 | 65 |
| 62 } // namespace WebCore | 66 } // namespace WebCore |
| OLD | NEW |