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

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

Issue 1101263003: Oilpan: have Navigator and its supplements be on the heap by default. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 5 years, 8 months 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 | Annotate | Revision Log
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 "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 { 18 {
19 } 19 }
20 20
21 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(NavigatorServiceWorker); 21 NavigatorServiceWorker::~NavigatorServiceWorker()
22 {
23 }
22 24
23 NavigatorServiceWorker* NavigatorServiceWorker::from(Document& document) 25 NavigatorServiceWorker* NavigatorServiceWorker::from(Document& document)
24 { 26 {
25 if (!document.frame() || !document.frame()->domWindow()) 27 if (!document.frame() || !document.frame()->domWindow())
26 return 0; 28 return nullptr;
27 Navigator& navigator = *document.frame()->domWindow()->navigator(); 29 Navigator& navigator = *document.frame()->domWindow()->navigator();
28 return &from(navigator); 30 return &from(navigator);
29 } 31 }
30 32
31 NavigatorServiceWorker& NavigatorServiceWorker::from(Navigator& navigator) 33 NavigatorServiceWorker& NavigatorServiceWorker::from(Navigator& navigator)
32 { 34 {
33 NavigatorServiceWorker* supplement = toNavigatorServiceWorker(navigator); 35 NavigatorServiceWorker* supplement = toNavigatorServiceWorker(navigator);
34 if (!supplement) { 36 if (!supplement) {
35 supplement = new NavigatorServiceWorker(navigator); 37 supplement = new NavigatorServiceWorker(navigator);
36 provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement)); 38 provideTo(navigator, supplementName(), supplement);
37 // Initialize ServiceWorkerContainer too. 39 // Initialize ServiceWorkerContainer too.
38 supplement->serviceWorker(); 40 supplement->serviceWorker();
39 } 41 }
40 return *supplement; 42 return *supplement;
41 } 43 }
42 44
43 NavigatorServiceWorker* NavigatorServiceWorker::toNavigatorServiceWorker(Navigat or& navigator) 45 NavigatorServiceWorker* NavigatorServiceWorker::toNavigatorServiceWorker(Navigat or& navigator)
44 { 46 {
45 return static_cast<NavigatorServiceWorker*>(WillBeHeapSupplement<Navigator>: :from(navigator, supplementName())); 47 return static_cast<NavigatorServiceWorker*>(HeapSupplement<Navigator>::from( navigator, supplementName()));
46 } 48 }
47 49
48 const char* NavigatorServiceWorker::supplementName() 50 const char* NavigatorServiceWorker::supplementName()
49 { 51 {
50 return "NavigatorServiceWorker"; 52 return "NavigatorServiceWorker";
51 } 53 }
52 54
53 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(Navigator& navigat or) 55 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(Navigator& navigat or)
54 { 56 {
55 return NavigatorServiceWorker::from(navigator).serviceWorker(); 57 return NavigatorServiceWorker::from(navigator).serviceWorker();
(...skipping 12 matching lines...) Expand all
68 { 70 {
69 if (m_serviceWorker) { 71 if (m_serviceWorker) {
70 m_serviceWorker->willBeDetachedFromFrame(); 72 m_serviceWorker->willBeDetachedFromFrame();
71 m_serviceWorker = nullptr; 73 m_serviceWorker = nullptr;
72 } 74 }
73 } 75 }
74 76
75 DEFINE_TRACE(NavigatorServiceWorker) 77 DEFINE_TRACE(NavigatorServiceWorker)
76 { 78 {
77 visitor->trace(m_serviceWorker); 79 visitor->trace(m_serviceWorker);
78 WillBeHeapSupplement<Navigator>::trace(visitor); 80 HeapSupplement<Navigator>::trace(visitor);
79 DOMWindowProperty::trace(visitor); 81 DOMWindowProperty::trace(visitor);
80 } 82 }
81 83
82 } // namespace blink 84 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/NavigatorServiceWorker.h ('k') | Source/modules/vr/NavigatorVRDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698