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

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

Issue 2473483012: Move content/child/background_sync to Blink. (Closed)
Patch Set: Fix nits 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
« no previous file with comments | « third_party/WebKit/Source/modules/background_sync/SyncManager.h ('k') | third_party/WebKit/public/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..16b5bd8664a86d55cac9f0873bfd390fe91dce00 100644
--- a/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
+++ b/third_party/WebKit/Source/modules/background_sync/SyncManager.cpp
@@ -11,27 +11,26 @@
#include "core/dom/DOMException.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
+#include "modules/background_sync/BackgroundSyncProvider.h"
#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/PtrUtil.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>,
+ syncProvider,
+ new ThreadSpecific<BackgroundSyncProvider>);
+ return syncProvider;
}
SyncManager::SyncManager(ServiceWorkerRegistration* registration)
: m_registration(registration) {
- ASSERT(registration);
+ DCHECK(registration);
}
ScriptPromise SyncManager::registerFunction(ScriptState* scriptState,
@@ -48,13 +47,16 @@ 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::kUnregisteredSyncID;
+ syncRegistration->tag = tag;
+ syncRegistration->network_state =
+ blink::mojom::BackgroundSyncNetworkState::ONLINE;
+
backgroundSyncProvider()->registerBackgroundSync(
- webSyncRegistration, m_registration->webRegistration(),
- new SyncRegistrationCallbacks(resolver, m_registration));
+ std::move(syncRegistration), m_registration->webRegistration(),
+ makeUnique<SyncRegistrationCallbacks>(resolver, m_registration));
return promise;
}
@@ -65,7 +67,7 @@ ScriptPromise SyncManager::getTags(ScriptState* scriptState) {
backgroundSyncProvider()->getRegistrations(
m_registration->webRegistration(),
- new SyncGetRegistrationsCallbacks(resolver, m_registration));
+ makeUnique<SyncGetRegistrationsCallbacks>(resolver, m_registration));
return promise;
}
« no previous file with comments | « third_party/WebKit/Source/modules/background_sync/SyncManager.h ('k') | third_party/WebKit/public/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698