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

Unified Diff: third_party/WebKit/Source/modules/background_sync/SyncManager.cpp

Issue 2473483012: Move content/child/background_sync to Blink. (Closed)
Patch Set: Update OWNERS to make presubmit happy Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
diff --git a/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp b/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
index 9711c0060e47bbbb47379e5e0856d9fe47721a01..e9340f006d8b0f3f5080fb5be439fda865752f01 100644
--- a/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
+++ b/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
@@ -14,24 +14,22 @@
#include "modules/background_sync/SyncCallbacks.h"
#include "modules/serviceworkers/ServiceWorkerRegistration.h"
#include "public/platform/Platform.h"
-#include "public/platform/modules/background_sync/WebSyncProvider.h"
-#include "public/platform/modules/background_sync/WebSyncRegistration.h"
-#include "wtf/RefPtr.h"
+#include "wtf/ThreadSpecific.h"
namespace blink {
-namespace {
-WebSyncProvider* backgroundSyncProvider() {
- WebSyncProvider* webSyncProvider =
- Platform::current()->backgroundSyncProvider();
- ASSERT(webSyncProvider);
- return webSyncProvider;
-}
+// static
+BackgroundSyncProvider* SyncManager::backgroundSyncProvider() {
+ DEFINE_THREAD_SAFE_STATIC_LOCAL(ThreadSpecific<BackgroundSyncProvider>,
+ sync_provider,
jbroman 2016/11/05 22:51:09 nit: no underscores in variable names in Blink (fo
adithyas 2016/11/07 19:22:55 Done.
+ new ThreadSpecific<BackgroundSyncProvider>);
haraken 2016/11/05 13:00:19 Is there any per-worker object with which Backgrou
jbroman 2016/11/05 22:51:09 My two cents: a thread-specific object is how this
+ DCHECK(sync_provider);
+ return sync_provider;
}
SyncManager::SyncManager(ServiceWorkerRegistration* registration)
: m_registration(registration) {
- ASSERT(registration);
+ DCHECK(registration);
}
ScriptPromise SyncManager::registerFunction(ScriptState* scriptState,
@@ -48,12 +46,15 @@ ScriptPromise SyncManager::registerFunction(ScriptState* scriptState,
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = resolver->promise();
- WebSyncRegistration* webSyncRegistration = new WebSyncRegistration(
- WebSyncRegistration::UNREGISTERED_SYNC_ID /* id */, tag,
- WebSyncRegistration::NetworkStateOnline /* networkState */
- );
+ mojom::blink::SyncRegistrationPtr syncRegistration =
+ mojom::blink::SyncRegistration::New();
+ syncRegistration->id = SyncManager::UNREGISTERED_SYNC_ID;
+ syncRegistration->tag = tag;
+ syncRegistration->network_state =
+ blink::mojom::BackgroundSyncNetworkState::ONLINE;
+
backgroundSyncProvider()->registerBackgroundSync(
- webSyncRegistration, m_registration->webRegistration(),
+ syncRegistration, m_registration->webRegistration(),
new SyncRegistrationCallbacks(resolver, m_registration));
return promise;

Powered by Google App Engine
This is Rietveld 408576698