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/PeriodicSyncRegistration.h" | 6 #include "modules/background_sync/PeriodicSyncRegistration.h" |
7 | 7 |
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 , m_minPeriod(options.minPeriod()) | 59 , m_minPeriod(options.minPeriod()) |
60 , m_networkState(options.networkState()) | 60 , m_networkState(options.networkState()) |
61 , m_powerState(options.powerState()) | 61 , m_powerState(options.powerState()) |
62 , m_tag(options.tag()) | 62 , m_tag(options.tag()) |
63 , m_serviceWorkerRegistration(serviceWorkerRegistration) | 63 , m_serviceWorkerRegistration(serviceWorkerRegistration) |
64 { | 64 { |
65 } | 65 } |
66 | 66 |
67 PeriodicSyncRegistration::~PeriodicSyncRegistration() | 67 PeriodicSyncRegistration::~PeriodicSyncRegistration() |
68 { | 68 { |
| 69 WebSyncProvider* webSyncProvider = Platform::current()->backgroundSyncProvid
er(); |
| 70 ASSERT(webSyncProvider); |
| 71 webSyncProvider->releaseRegistration(m_id); |
69 } | 72 } |
70 | 73 |
71 ScriptPromise PeriodicSyncRegistration::unregister(ScriptState* scriptState) | 74 ScriptPromise PeriodicSyncRegistration::unregister(ScriptState* scriptState) |
72 { | 75 { |
73 if (m_id == WebSyncRegistration::UNREGISTERED_SYNC_ID) | 76 if (m_id == WebSyncRegistration::UNREGISTERED_SYNC_ID) |
74 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(AbortError, "Operation failed - not a valid registration object")); | 77 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(AbortError, "Operation failed - not a valid registration object")); |
75 | 78 |
76 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 79 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
77 ScriptPromise promise = resolver->promise(); | 80 ScriptPromise promise = resolver->promise(); |
78 | 81 |
79 WebSyncProvider* webSyncProvider = Platform::current()->backgroundSyncProvid
er(); | 82 WebSyncProvider* webSyncProvider = Platform::current()->backgroundSyncProvid
er(); |
80 ASSERT(webSyncProvider); | 83 ASSERT(webSyncProvider); |
81 | 84 |
82 webSyncProvider->unregisterBackgroundSync(WebSyncRegistration::PeriodicityPe
riodic, m_id, m_tag, m_serviceWorkerRegistration->webRegistration(), new SyncUnr
egistrationCallbacks(resolver, m_serviceWorkerRegistration)); | 85 webSyncProvider->unregisterBackgroundSync(WebSyncRegistration::PeriodicityPe
riodic, m_id, m_tag, m_serviceWorkerRegistration->webRegistration(), new SyncUnr
egistrationCallbacks(resolver, m_serviceWorkerRegistration)); |
83 | 86 |
84 return promise; | 87 return promise; |
85 } | 88 } |
86 | 89 |
87 DEFINE_TRACE(PeriodicSyncRegistration) | 90 DEFINE_TRACE(PeriodicSyncRegistration) |
88 { | 91 { |
89 visitor->trace(m_serviceWorkerRegistration); | 92 visitor->trace(m_serviceWorkerRegistration); |
90 } | 93 } |
91 | 94 |
92 } // namespace blink | 95 } // namespace blink |
OLD | NEW |