OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/background_sync/ServiceWorkerRegistrationSync.h" | 5 #include "modules/background_sync/ServiceWorkerRegistrationSync.h" |
6 | 6 |
7 #include "modules/background_sync/SyncManager.h" | 7 #include "modules/background_sync/SyncManager.h" |
8 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 8 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 ServiceWorkerRegistrationSync::ServiceWorkerRegistrationSync(ServiceWorkerRegist
ration* registration) | 12 ServiceWorkerRegistrationSync::ServiceWorkerRegistrationSync(ServiceWorkerRegist
ration* registration) |
13 : m_registration(registration) | 13 : m_registration(registration) |
14 { | 14 { |
15 } | 15 } |
16 | 16 |
17 ServiceWorkerRegistrationSync::~ServiceWorkerRegistrationSync() | 17 ServiceWorkerRegistrationSync::~ServiceWorkerRegistrationSync() |
18 { | 18 { |
19 } | 19 } |
20 | 20 |
21 const char* ServiceWorkerRegistrationSync::supplementName() | 21 const char* ServiceWorkerRegistrationSync::supplementName() |
22 { | 22 { |
23 return "ServiceWorkerRegistrationSync"; | 23 return "ServiceWorkerRegistrationSync"; |
24 } | 24 } |
25 | 25 |
26 ServiceWorkerRegistrationSync& ServiceWorkerRegistrationSync::from(ServiceWorker
Registration& registration) | 26 ServiceWorkerRegistrationSync& ServiceWorkerRegistrationSync::from(ServiceWorker
Registration& registration) |
27 { | 27 { |
28 ServiceWorkerRegistrationSync* supplement = static_cast<ServiceWorkerRegistr
ationSync*>(HeapSupplement<ServiceWorkerRegistration>::from(registration, supple
mentName())); | 28 ServiceWorkerRegistrationSync* supplement = static_cast<ServiceWorkerRegistr
ationSync*>(Supplement<ServiceWorkerRegistration>::from(registration, supplement
Name())); |
29 if (!supplement) { | 29 if (!supplement) { |
30 supplement = new ServiceWorkerRegistrationSync(®istration); | 30 supplement = new ServiceWorkerRegistrationSync(®istration); |
31 provideTo(registration, supplementName(), supplement); | 31 provideTo(registration, supplementName(), supplement); |
32 } | 32 } |
33 return *supplement; | 33 return *supplement; |
34 } | 34 } |
35 | 35 |
36 SyncManager* ServiceWorkerRegistrationSync::sync(ServiceWorkerRegistration& regi
stration) | 36 SyncManager* ServiceWorkerRegistrationSync::sync(ServiceWorkerRegistration& regi
stration) |
37 { | 37 { |
38 return ServiceWorkerRegistrationSync::from(registration).sync(); | 38 return ServiceWorkerRegistrationSync::from(registration).sync(); |
39 } | 39 } |
40 | 40 |
41 SyncManager* ServiceWorkerRegistrationSync::sync() | 41 SyncManager* ServiceWorkerRegistrationSync::sync() |
42 { | 42 { |
43 if (!m_syncManager) | 43 if (!m_syncManager) |
44 m_syncManager = SyncManager::create(m_registration); | 44 m_syncManager = SyncManager::create(m_registration); |
45 return m_syncManager.get(); | 45 return m_syncManager.get(); |
46 } | 46 } |
47 | 47 |
48 DEFINE_TRACE(ServiceWorkerRegistrationSync) | 48 DEFINE_TRACE(ServiceWorkerRegistrationSync) |
49 { | 49 { |
50 visitor->trace(m_registration); | 50 visitor->trace(m_registration); |
51 visitor->trace(m_syncManager); | 51 visitor->trace(m_syncManager); |
52 HeapSupplement<ServiceWorkerRegistration>::trace(visitor); | 52 Supplement<ServiceWorkerRegistration>::trace(visitor); |
53 } | 53 } |
54 | 54 |
55 } // namespace blink | 55 } // namespace blink |
OLD | NEW |