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

Side by Side Diff: third_party/WebKit/Source/modules/background_fetch/ServiceWorkerRegistrationBackgroundFetch.cpp

Issue 2736143003: Introduce the Background Fetch module. (Closed)
Patch Set: more webexposed tests Created 3 years, 9 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
OLDNEW
(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
9 namespace blink {
10
11 ServiceWorkerRegistrationBackgroundFetch::
12 ServiceWorkerRegistrationBackgroundFetch(
13 ServiceWorkerRegistration* registration)
14 : m_registration(registration) {}
15
16 ServiceWorkerRegistrationBackgroundFetch::
17 ~ServiceWorkerRegistrationBackgroundFetch() = default;
18
19 const char* ServiceWorkerRegistrationBackgroundFetch::supplementName() {
20 return "ServiceWorkerRegistrationBackgroundFetch";
21 }
22
23 ServiceWorkerRegistrationBackgroundFetch&
24 ServiceWorkerRegistrationBackgroundFetch::from(
25 ServiceWorkerRegistration& registration) {
26 ServiceWorkerRegistrationBackgroundFetch* supplement =
27 static_cast<ServiceWorkerRegistrationBackgroundFetch*>(
28 Supplement<ServiceWorkerRegistration>::from(registration,
29 supplementName()));
30
31 if (!supplement) {
32 supplement = new ServiceWorkerRegistrationBackgroundFetch(&registration);
33 provideTo(registration, supplementName(), supplement);
34 }
35
36 return *supplement;
37 }
38
39 BackgroundFetchManager*
40 ServiceWorkerRegistrationBackgroundFetch::backgroundFetch(
41 ServiceWorkerRegistration& registration) {
42 return ServiceWorkerRegistrationBackgroundFetch::from(registration)
43 .backgroundFetch();
44 }
45
46 BackgroundFetchManager*
47 ServiceWorkerRegistrationBackgroundFetch::backgroundFetch() {
48 if (!m_backgroundFetchManager)
49 m_backgroundFetchManager = BackgroundFetchManager::create(m_registration);
50
51 return m_backgroundFetchManager.get();
52 }
53
54 DEFINE_TRACE(ServiceWorkerRegistrationBackgroundFetch) {
55 visitor->trace(m_registration);
56 visitor->trace(m_backgroundFetchManager);
57 Supplement<ServiceWorkerRegistration>::trace(visitor);
58 }
59
60 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698