OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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_fetch/BackgroundFetchRegistration.h" | 5 #include "modules/background_fetch/BackgroundFetchRegistration.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
8 #include "modules/background_fetch/BackgroundFetchBridge.h" | 8 #include "modules/background_fetch/BackgroundFetchBridge.h" |
9 #include "modules/background_fetch/IconDefinition.h" | 9 #include "modules/background_fetch/IconDefinition.h" |
10 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 10 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 BackgroundFetchRegistration::BackgroundFetchRegistration( | 14 BackgroundFetchRegistration::BackgroundFetchRegistration( |
15 ServiceWorkerRegistration* registration, | |
16 String tag, | 15 String tag, |
17 HeapVector<IconDefinition> icons, | 16 HeapVector<IconDefinition> icons, |
18 long long totalDownloadSize, | 17 long long totalDownloadSize, |
19 String title) | 18 String title) |
20 : m_registration(registration), | 19 : m_tag(tag), |
21 m_tag(tag), | |
22 m_icons(icons), | 20 m_icons(icons), |
23 m_totalDownloadSize(totalDownloadSize), | 21 m_totalDownloadSize(totalDownloadSize), |
24 m_title(title) {} | 22 m_title(title) {} |
25 | 23 |
26 BackgroundFetchRegistration::~BackgroundFetchRegistration() = default; | 24 BackgroundFetchRegistration::~BackgroundFetchRegistration() = default; |
27 | 25 |
26 void BackgroundFetchRegistration::setServiceWorkerRegistration( | |
27 ServiceWorkerRegistration* registration) { | |
28 m_registration = registration; | |
dcheng
2017/03/24 23:12:24
Maybe DCHECK(!m_registration) first as well.
Peter Beverloo
2017/03/24 23:26:05
Sure, I'll send you a follow-up either tomorrow or
| |
29 } | |
30 | |
28 String BackgroundFetchRegistration::tag() const { | 31 String BackgroundFetchRegistration::tag() const { |
29 return m_tag; | 32 return m_tag; |
30 } | 33 } |
31 | 34 |
32 HeapVector<IconDefinition> BackgroundFetchRegistration::icons() const { | 35 HeapVector<IconDefinition> BackgroundFetchRegistration::icons() const { |
33 return m_icons; | 36 return m_icons; |
34 } | 37 } |
35 | 38 |
36 long long BackgroundFetchRegistration::totalDownloadSize() const { | 39 long long BackgroundFetchRegistration::totalDownloadSize() const { |
37 return m_totalDownloadSize; | 40 return m_totalDownloadSize; |
38 } | 41 } |
39 | 42 |
40 String BackgroundFetchRegistration::title() const { | 43 String BackgroundFetchRegistration::title() const { |
41 return m_title; | 44 return m_title; |
42 } | 45 } |
43 | 46 |
44 ScriptPromise BackgroundFetchRegistration::abort(ScriptState* scriptState) { | 47 ScriptPromise BackgroundFetchRegistration::abort(ScriptState* scriptState) { |
45 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 48 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
46 ScriptPromise promise = resolver->promise(); | 49 ScriptPromise promise = resolver->promise(); |
47 | 50 |
51 DCHECK(m_registration); | |
48 BackgroundFetchBridge::from(m_registration) | 52 BackgroundFetchBridge::from(m_registration) |
49 ->abort(m_tag, WTF::bind(&BackgroundFetchRegistration::didAbort, | 53 ->abort(m_tag, WTF::bind(&BackgroundFetchRegistration::didAbort, |
50 wrapPersistent(this), wrapPersistent(resolver))); | 54 wrapPersistent(this), wrapPersistent(resolver))); |
51 | 55 |
52 return promise; | 56 return promise; |
53 } | 57 } |
54 | 58 |
55 void BackgroundFetchRegistration::didAbort( | 59 void BackgroundFetchRegistration::didAbort( |
56 ScriptPromiseResolver* resolver, | 60 ScriptPromiseResolver* resolver, |
57 mojom::blink::BackgroundFetchError error) { | 61 mojom::blink::BackgroundFetchError error) { |
(...skipping 11 matching lines...) Expand all Loading... | |
69 | 73 |
70 NOTREACHED(); | 74 NOTREACHED(); |
71 } | 75 } |
72 | 76 |
73 DEFINE_TRACE(BackgroundFetchRegistration) { | 77 DEFINE_TRACE(BackgroundFetchRegistration) { |
74 visitor->trace(m_registration); | 78 visitor->trace(m_registration); |
75 visitor->trace(m_icons); | 79 visitor->trace(m_icons); |
76 } | 80 } |
77 | 81 |
78 } // namespace blink | 82 } // namespace blink |
OLD | NEW |