| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/background_sync/ServiceWorkerRegistrationSync.h" | 6 #include "modules/background_sync/ServiceWorkerRegistrationSync.h" |
| 7 | 7 |
| 8 #include "modules/background_sync/PeriodicSyncManager.h" |
| 8 #include "modules/background_sync/SyncManager.h" | 9 #include "modules/background_sync/SyncManager.h" |
| 9 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 10 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 10 | 11 |
| 11 namespace blink { | 12 namespace blink { |
| 12 | 13 |
| 13 ServiceWorkerRegistrationSync::ServiceWorkerRegistrationSync(ServiceWorkerRegist
ration* registration) | 14 ServiceWorkerRegistrationSync::ServiceWorkerRegistrationSync(ServiceWorkerRegist
ration* registration) |
| 14 : m_registration(registration) | 15 : m_registration(registration) |
| 15 { | 16 { |
| 16 } | 17 } |
| 17 | 18 |
| 18 ServiceWorkerRegistrationSync::~ServiceWorkerRegistrationSync() | 19 ServiceWorkerRegistrationSync::~ServiceWorkerRegistrationSync() |
| 19 { | 20 { |
| 20 } | 21 } |
| 21 | 22 |
| 22 const char* ServiceWorkerRegistrationSync::supplementName() | 23 const char* ServiceWorkerRegistrationSync::supplementName() |
| 23 { | 24 { |
| 24 return "ServiceWorkerRegistrationSync"; | 25 return "ServiceWorkerRegistrationSync"; |
| 25 } | 26 } |
| 26 | 27 |
| 27 ServiceWorkerRegistrationSync& ServiceWorkerRegistrationSync::from(ServiceWorker
Registration& registration) | 28 ServiceWorkerRegistrationSync& ServiceWorkerRegistrationSync::from(ServiceWorker
Registration& registration) |
| 28 { | 29 { |
| 29 ServiceWorkerRegistrationSync* supplement = static_cast<ServiceWorkerRegistr
ationSync*>(HeapSupplement<ServiceWorkerRegistration>::from(registration, supple
mentName())); | 30 ServiceWorkerRegistrationSync* supplement = static_cast<ServiceWorkerRegistr
ationSync*>(HeapSupplement<ServiceWorkerRegistration>::from(registration, supple
mentName())); |
| 30 if (!supplement) { | 31 if (!supplement) { |
| 31 supplement = new ServiceWorkerRegistrationSync(®istration); | 32 supplement = new ServiceWorkerRegistrationSync(®istration); |
| 32 provideTo(registration, supplementName(), supplement); | 33 provideTo(registration, supplementName(), supplement); |
| 33 } | 34 } |
| 34 return *supplement; | 35 return *supplement; |
| 35 } | 36 } |
| 36 | 37 |
| 37 SyncManager* ServiceWorkerRegistrationSync::syncManager(ServiceWorkerRegistratio
n& registration) | 38 SyncManager* ServiceWorkerRegistrationSync::sync(ServiceWorkerRegistration& regi
stration) |
| 38 { | 39 { |
| 39 return ServiceWorkerRegistrationSync::from(registration).syncManager(); | 40 return ServiceWorkerRegistrationSync::from(registration).sync(); |
| 40 } | 41 } |
| 41 | 42 |
| 42 SyncManager* ServiceWorkerRegistrationSync::syncManager() | 43 SyncManager* ServiceWorkerRegistrationSync::sync() |
| 43 { | 44 { |
| 44 if (!m_syncManager) | 45 if (!m_syncManager) |
| 45 m_syncManager = SyncManager::create(m_registration); | 46 m_syncManager = SyncManager::create(m_registration); |
| 46 return m_syncManager.get(); | 47 return m_syncManager.get(); |
| 47 } | 48 } |
| 48 | 49 |
| 50 PeriodicSyncManager* ServiceWorkerRegistrationSync::periodicSync(ServiceWorkerRe
gistration& registration) |
| 51 { |
| 52 return ServiceWorkerRegistrationSync::from(registration).periodicSync(); |
| 53 } |
| 54 |
| 55 PeriodicSyncManager* ServiceWorkerRegistrationSync::periodicSync() |
| 56 { |
| 57 if (!m_periodicSyncManager) |
| 58 m_periodicSyncManager = PeriodicSyncManager::create(m_registration); |
| 59 return m_periodicSyncManager.get(); |
| 60 } |
| 61 |
| 49 DEFINE_TRACE(ServiceWorkerRegistrationSync) | 62 DEFINE_TRACE(ServiceWorkerRegistrationSync) |
| 50 { | 63 { |
| 51 visitor->trace(m_registration); | 64 visitor->trace(m_registration); |
| 52 visitor->trace(m_syncManager); | 65 visitor->trace(m_syncManager); |
| 66 visitor->trace(m_periodicSyncManager); |
| 53 HeapSupplement<ServiceWorkerRegistration>::trace(visitor); | 67 HeapSupplement<ServiceWorkerRegistration>::trace(visitor); |
| 54 } | 68 } |
| 55 | 69 |
| 56 } // namespace blink | 70 } // namespace blink |
| OLD | NEW |