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

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

Issue 2473483012: Move content/child/background_sync to Blink. (Closed)
Patch Set: Code review changes 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..9958384f90397090e35d18ca33149540808a36e9 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>,
haraken 2016/11/08 07:11:36 nhiroki@: We might want to consider introducing a
nhiroki 2016/11/09 05:26:55 Filed an issue: https://bugs.chromium.org/p/chromi
+ syncProvider,
+ new ThreadSpecific<BackgroundSyncProvider>);
+ DCHECK(syncProvider);
+ return syncProvider;
}
SyncManager::SyncManager(ServiceWorkerRegistration* registration)
: m_registration(registration) {
- ASSERT(registration);
+ DCHECK(registration);
}
ScriptPromise SyncManager::registerFunction(ScriptState* scriptState,
@@ -48,13 +46,17 @@ 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(),
+ std::unique_ptr<SyncRegistrationCallbacks>(
jbroman 2016/11/07 19:48:10 super-nit: You might consider using makeUnique (fr
adithyas 2016/11/08 16:47:47 Done! I like makeUnique better in this case :)
+ new SyncRegistrationCallbacks(resolver, m_registration)));
return promise;
}
@@ -65,7 +67,8 @@ ScriptPromise SyncManager::getTags(ScriptState* scriptState) {
backgroundSyncProvider()->getRegistrations(
m_registration->webRegistration(),
- new SyncGetRegistrationsCallbacks(resolver, m_registration));
+ std::unique_ptr<SyncGetRegistrationsCallbacks>(
+ new SyncGetRegistrationsCallbacks(resolver, m_registration)));
return promise;
}

Powered by Google App Engine
This is Rietveld 408576698