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

Side by Side Diff: Source/modules/push_messaging/ServiceWorkerRegistrationPush.cpp

Issue 783983003: Push API: move PushManager from Navigator to ServiceWorkerRegistration [switchover 6/6] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address review comments. Created 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "modules/push_messaging/ServiceWorkerRegistrationPush.h"
7
8 #include "modules/push_messaging/PushManager.h"
9 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
10
11 namespace blink {
12
13 ServiceWorkerRegistrationPush::ServiceWorkerRegistrationPush(ServiceWorkerRegist ration* registration)
14 : m_registration(registration)
15 {
16 }
17
18 ServiceWorkerRegistrationPush::~ServiceWorkerRegistrationPush()
19 {
20 }
21
22 const char* ServiceWorkerRegistrationPush::supplementName()
23 {
24 return "ServiceWorkerRegistrationPush";
25 }
26
27 ServiceWorkerRegistrationPush& ServiceWorkerRegistrationPush::from(ServiceWorker Registration& registration)
28 {
29 ServiceWorkerRegistrationPush* supplement = static_cast<ServiceWorkerRegistr ationPush*>(HeapSupplement<ServiceWorkerRegistration>::from(registration, supple mentName()));
30 if (!supplement) {
31 supplement = new ServiceWorkerRegistrationPush(&registration);
32 provideTo(registration, supplementName(), supplement);
33 }
34 return *supplement;
35 }
36
37 PushManager* ServiceWorkerRegistrationPush::pushManager(ServiceWorkerRegistratio n& registration)
38 {
39 return ServiceWorkerRegistrationPush::from(registration).pushManager();
40 }
41
42 PushManager* ServiceWorkerRegistrationPush::pushManager()
43 {
44 if (!m_pushManager)
45 m_pushManager = PushManager::create(m_registration);
46 return m_pushManager.get();
47 }
48
49 void ServiceWorkerRegistrationPush::trace(Visitor* visitor)
50 {
51 visitor->trace(m_registration);
52 visitor->trace(m_pushManager);
53 HeapSupplement<ServiceWorkerRegistration>::trace(visitor);
54 }
55
56 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698