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

Side by Side Diff: Source/modules/background_sync/SyncManager.cpp

Issue 1155243007: [BackgroundSync] One-shots should fire only when online (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698