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/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/frame/LocalDOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
11 #include "core/frame/Navigator.h" | 11 #include "core/frame/Navigator.h" |
12 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 12 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 NavigatorServiceWorker::NavigatorServiceWorker(Navigator& navigator) | 16 NavigatorServiceWorker::NavigatorServiceWorker(Navigator& navigator) |
17 : DOMWindowProperty(navigator.frame()) | 17 : DOMWindowProperty(navigator.frame()) |
| 18 , m_domWindow(navigator.frame()->domWindow()) |
18 { | 19 { |
19 } | 20 } |
20 | 21 |
21 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(NavigatorServiceWorker); | 22 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(NavigatorServiceWorker); |
22 | 23 |
23 NavigatorServiceWorker* NavigatorServiceWorker::from(Document& document) | 24 NavigatorServiceWorker* NavigatorServiceWorker::from(Document& document) |
24 { | 25 { |
25 if (!document.frame() || !document.frame()->domWindow()) | 26 if (!document.frame() || !document.frame()->domWindow()) |
26 return 0; | 27 return 0; |
27 Navigator& navigator = *document.frame()->domWindow()->navigator(); | 28 Navigator& navigator = *document.frame()->domWindow()->navigator(); |
(...skipping 22 matching lines...) Expand all Loading... |
50 return "NavigatorServiceWorker"; | 51 return "NavigatorServiceWorker"; |
51 } | 52 } |
52 | 53 |
53 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(Navigator& navigat
or) | 54 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(Navigator& navigat
or) |
54 { | 55 { |
55 return NavigatorServiceWorker::from(navigator).serviceWorker(); | 56 return NavigatorServiceWorker::from(navigator).serviceWorker(); |
56 } | 57 } |
57 | 58 |
58 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker() | 59 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker() |
59 { | 60 { |
60 if (!m_serviceWorker && frame()) { | 61 if (!m_serviceWorker && m_domWindow) { |
61 ASSERT(frame()->domWindow()); | 62 ASSERT(m_domWindow->executionContext()); |
62 m_serviceWorker = ServiceWorkerContainer::create(frame()->domWindow()->e
xecutionContext()); | 63 m_serviceWorker = ServiceWorkerContainer::create(m_domWindow->executionC
ontext()); |
63 } | 64 } |
64 return m_serviceWorker.get(); | 65 return m_serviceWorker.get(); |
65 } | 66 } |
66 | 67 |
67 void NavigatorServiceWorker::willDetachGlobalObjectFromFrame() | 68 void NavigatorServiceWorker::willDetachGlobalObjectFromFrame() |
68 { | 69 { |
69 if (m_serviceWorker) { | 70 if (m_serviceWorker) { |
70 m_serviceWorker->willBeDetachedFromFrame(); | 71 m_serviceWorker->willBeDetachedFromFrame(); |
71 m_serviceWorker = nullptr; | 72 m_serviceWorker = nullptr; |
72 } | 73 } |
73 } | 74 } |
74 | 75 |
75 void NavigatorServiceWorker::trace(Visitor* visitor) | 76 void NavigatorServiceWorker::trace(Visitor* visitor) |
76 { | 77 { |
77 visitor->trace(m_serviceWorker); | 78 visitor->trace(m_serviceWorker); |
78 WillBeHeapSupplement<Navigator>::trace(visitor); | 79 WillBeHeapSupplement<Navigator>::trace(visitor); |
79 DOMWindowProperty::trace(visitor); | 80 DOMWindowProperty::trace(visitor); |
80 } | 81 } |
81 | 82 |
82 } // namespace blink | 83 } // namespace blink |
OLD | NEW |