| 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/SyncManager.h" | 6 #include "modules/background_sync/SyncManager.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(AbortError, "Registration failed - no active Service Worker")); | 46 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(AbortError, "Registration failed - no active Service Worker")); |
| 47 | 47 |
| 48 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 48 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); |
| 49 ScriptPromise promise = resolver->promise(); | 49 ScriptPromise promise = resolver->promise(); |
| 50 | 50 |
| 51 WebSyncRegistration* webSyncRegistration = new WebSyncRegistration( | 51 WebSyncRegistration* webSyncRegistration = new WebSyncRegistration( |
| 52 WebSyncRegistration::UNREGISTERED_SYNC_ID /* id */, | 52 WebSyncRegistration::UNREGISTERED_SYNC_ID /* id */, |
| 53 WebSyncRegistration::PeriodicityOneShot, | 53 WebSyncRegistration::PeriodicityOneShot, |
| 54 options.tag(), | 54 options.tag(), |
| 55 0 /* minPeriod */, | 55 0 /* minPeriod */, |
| 56 WebSyncRegistration::NetworkStateAny /* networkState */, | 56 WebSyncRegistration::NetworkStateOnline /* networkState */, |
| 57 WebSyncRegistration::PowerStateAuto /* powerState */ | 57 WebSyncRegistration::PowerStateAuto /* powerState */ |
| 58 ); | 58 ); |
| 59 backgroundSyncProvider()->registerBackgroundSync(webSyncRegistration, m_regi
stration->webRegistration(), new SyncRegistrationCallbacks(resolver, m_registrat
ion)); | 59 backgroundSyncProvider()->registerBackgroundSync(webSyncRegistration, m_regi
stration->webRegistration(), new SyncRegistrationCallbacks(resolver, m_registrat
ion)); |
| 60 | 60 |
| 61 return promise; | 61 return promise; |
| 62 } | 62 } |
| 63 | 63 |
| 64 ScriptPromise SyncManager::getRegistration(ScriptState* scriptState, const Strin
g& syncRegistrationId) | 64 ScriptPromise SyncManager::getRegistration(ScriptState* scriptState, const Strin
g& syncRegistrationId) |
| 65 { | 65 { |
| 66 if (!m_registration->active()) | 66 if (!m_registration->active()) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 97 resolver->resolve(String::fromUTF8("granted")); | 97 resolver->resolve(String::fromUTF8("granted")); |
| 98 return promise; | 98 return promise; |
| 99 } | 99 } |
| 100 | 100 |
| 101 DEFINE_TRACE(SyncManager) | 101 DEFINE_TRACE(SyncManager) |
| 102 { | 102 { |
| 103 visitor->trace(m_registration); | 103 visitor->trace(m_registration); |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace blink | 106 } // namespace blink |
| OLD | NEW |