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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/NavigatorServiceWorker.cpp

Issue 2556893003: Remove ContextLifecycleObserver from NavigatorServiceWorker (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « third_party/WebKit/Source/modules/serviceworkers/NavigatorServiceWorker.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "modules/serviceworkers/NavigatorServiceWorker.h" 5 #include "modules/serviceworkers/NavigatorServiceWorker.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/LocalDOMWindow.h" 8 #include "core/frame/LocalDOMWindow.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/frame/Navigator.h" 10 #include "core/frame/Navigator.h"
11 #include "modules/serviceworkers/ServiceWorkerContainer.h" 11 #include "modules/serviceworkers/ServiceWorkerContainer.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 NavigatorServiceWorker::NavigatorServiceWorker(Navigator& navigator) 15 NavigatorServiceWorker::NavigatorServiceWorker(Navigator& navigator) {}
16 : ContextLifecycleObserver(navigator.frame() ? navigator.frame()->document()
17 : nullptr) {}
18 16
19 NavigatorServiceWorker* NavigatorServiceWorker::from(Document& document) { 17 NavigatorServiceWorker* NavigatorServiceWorker::from(Document& document) {
20 if (!document.frame() || !document.frame()->domWindow()) 18 if (!document.frame() || !document.frame()->domWindow())
21 return nullptr; 19 return nullptr;
22 Navigator& navigator = *document.frame()->domWindow()->navigator(); 20 Navigator& navigator = *document.frame()->domWindow()->navigator();
23 return &from(navigator); 21 return &from(navigator);
24 } 22 }
25 23
26 NavigatorServiceWorker& NavigatorServiceWorker::from(Navigator& navigator) { 24 NavigatorServiceWorker& NavigatorServiceWorker::from(Navigator& navigator) {
27 NavigatorServiceWorker* supplement = toNavigatorServiceWorker(navigator); 25 NavigatorServiceWorker* supplement = toNavigatorServiceWorker(navigator);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 "lacks the 'allow-same-origin' flag."; 95 "lacks the 'allow-same-origin' flag.";
98 } else if (frame->securityContext()->getSecurityOrigin()->hasSuborigin()) { 96 } else if (frame->securityContext()->getSecurityOrigin()->hasSuborigin()) {
99 errorMessage = 97 errorMessage =
100 "Service worker is disabled because the context is in a suborigin."; 98 "Service worker is disabled because the context is in a suborigin.";
101 } else { 99 } else {
102 errorMessage = 100 errorMessage =
103 "Access to service workers is denied in this document origin."; 101 "Access to service workers is denied in this document origin.";
104 } 102 }
105 return nullptr; 103 return nullptr;
106 } 104 }
107 if (!m_serviceWorker && frame) { 105 if (!m_serviceWorker && frame) {
haraken 2016/12/12 02:47:51 nhiroki@: Would you help me understand what this i
108 DCHECK(frame->domWindow()); 106 DCHECK(frame->domWindow());
109 m_serviceWorker = ServiceWorkerContainer::create( 107 m_serviceWorker = ServiceWorkerContainer::create(
110 frame->domWindow()->getExecutionContext()); 108 frame->domWindow()->getExecutionContext());
111 } 109 }
112 return m_serviceWorker.get(); 110 return m_serviceWorker.get();
113 } 111 }
114 112
115 void NavigatorServiceWorker::contextDestroyed() {
116 m_serviceWorker = nullptr;
117 }
118
119 DEFINE_TRACE(NavigatorServiceWorker) { 113 DEFINE_TRACE(NavigatorServiceWorker) {
120 visitor->trace(m_serviceWorker); 114 visitor->trace(m_serviceWorker);
121 Supplement<Navigator>::trace(visitor); 115 Supplement<Navigator>::trace(visitor);
122 ContextLifecycleObserver::trace(visitor);
123 } 116 }
124 117
125 } // namespace blink 118 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/serviceworkers/NavigatorServiceWorker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698