OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 "modules/background_fetch/ServiceWorkerRegistrationBackgroundFetch.h" |
| 6 |
| 7 #include "modules/background_fetch/BackgroundFetchManager.h" |
| 8 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 9 |
| 10 namespace blink { |
| 11 |
| 12 ServiceWorkerRegistrationBackgroundFetch:: |
| 13 ServiceWorkerRegistrationBackgroundFetch( |
| 14 ServiceWorkerRegistration* registration) |
| 15 : m_registration(registration) {} |
| 16 |
| 17 ServiceWorkerRegistrationBackgroundFetch:: |
| 18 ~ServiceWorkerRegistrationBackgroundFetch() {} |
| 19 |
| 20 const char* ServiceWorkerRegistrationBackgroundFetch::supplementName() { |
| 21 return "ServiceWorkerRegistrationBackgroundFetch"; |
| 22 } |
| 23 |
| 24 ServiceWorkerRegistrationBackgroundFetch& |
| 25 ServiceWorkerRegistrationBackgroundFetch::from( |
| 26 ServiceWorkerRegistration& registration) { |
| 27 ServiceWorkerRegistrationBackgroundFetch* supplement = |
| 28 static_cast<ServiceWorkerRegistrationBackgroundFetch*>( |
| 29 Supplement<ServiceWorkerRegistration>::from(registration, |
| 30 supplementName())); |
| 31 if (!supplement) { |
| 32 supplement = new ServiceWorkerRegistrationBackgroundFetch(®istration); |
| 33 provideTo(registration, supplementName(), supplement); |
| 34 } |
| 35 return *supplement; |
| 36 } |
| 37 |
| 38 // static |
| 39 BackgroundFetchManager* |
| 40 ServiceWorkerRegistrationBackgroundFetch::backgroundFetch( |
| 41 ServiceWorkerRegistration& registration) { |
| 42 return ServiceWorkerRegistrationBackgroundFetch::from(registration) |
| 43 .backgroundFetch(); |
| 44 } |
| 45 |
| 46 BackgroundFetchManager* |
| 47 ServiceWorkerRegistrationBackgroundFetch::backgroundFetch() { |
| 48 return m_backgroundFetch; |
| 49 } |
| 50 |
| 51 DEFINE_TRACE(ServiceWorkerRegistrationBackgroundFetch) { |
| 52 visitor->trace(m_registration); |
| 53 visitor->trace(m_backgroundFetch); |
| 54 Supplement<ServiceWorkerRegistration>::trace(visitor); |
| 55 } |
| 56 |
| 57 } // namespace blink |
OLD | NEW |