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

Unified Diff: content/renderer/background_sync/background_sync_client_impl.cc

Issue 1763123002: [BackgroundSync] Remove BackgroundSyncRegistrationHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from PS7 Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/background_sync/background_sync_client_impl.cc
diff --git a/content/renderer/background_sync/background_sync_client_impl.cc b/content/renderer/background_sync/background_sync_client_impl.cc
index bd420c0860c7f5afb2493e27bb96354a03276d42..195451273902d0d30d0c2cc94ad8d30a0d045fe3 100644
--- a/content/renderer/background_sync/background_sync_client_impl.cc
+++ b/content/renderer/background_sync/background_sync_client_impl.cc
@@ -27,53 +27,13 @@ BackgroundSyncClientImpl::~BackgroundSyncClientImpl() {}
BackgroundSyncClientImpl::BackgroundSyncClientImpl(
mojo::InterfaceRequest<BackgroundSyncServiceClient> request)
- : binding_(this, std::move(request)), callback_seq_num_(0) {}
+ : binding_(this, std::move(request)) {}
void BackgroundSyncClientImpl::Sync(
- int64_t handle_id,
+ const mojo::String& tag,
content::BackgroundSyncEventLastChance last_chance,
const SyncCallback& callback) {
DCHECK(!blink::Platform::current()->mainThread()->isCurrentThread());
- // Get a registration for the given handle_id from the provider. This way
- // the provider knows about the handle and can delete it once Blink releases
- // it.
- // TODO(jkarlin): Change the WebSyncPlatform to support
- // DuplicateRegistrationHandle and then this cast can go.
- BackgroundSyncProvider* provider = static_cast<BackgroundSyncProvider*>(
- blink::Platform::current()->backgroundSyncProvider());
-
- if (provider == nullptr) {
- // This can happen if the renderer is shutting down when sync fires. See
- // crbug.com/543898. No need to fire the callback as the browser will
- // automatically fail all pending sync events when the mojo connection
- // closes.
- return;
- }
-
- // TODO(jkarlin): Find a way to claim the handle safely without requiring a
- // round-trip IPC.
- int64_t id = ++callback_seq_num_;
- sync_callbacks_[id] = callback;
- provider->DuplicateRegistrationHandle(
- handle_id, base::Bind(&BackgroundSyncClientImpl::SyncDidGetRegistration,
- base::Unretained(this), id, last_chance));
-}
-
-void BackgroundSyncClientImpl::SyncDidGetRegistration(
- int64_t callback_id,
- content::BackgroundSyncEventLastChance last_chance,
- BackgroundSyncError error,
- SyncRegistrationPtr registration) {
- SyncCallback callback;
- auto it = sync_callbacks_.find(callback_id);
- DCHECK(it != sync_callbacks_.end());
- callback = it->second;
- sync_callbacks_.erase(it);
-
- if (error != BackgroundSyncError::NONE) {
- callback.Run(ServiceWorkerEventStatus::ABORTED);
- return;
- }
ServiceWorkerContextClient* client =
ServiceWorkerContextClient::ThreadSpecificInstance();
@@ -82,14 +42,11 @@ void BackgroundSyncClientImpl::SyncDidGetRegistration(
return;
}
- scoped_ptr<blink::WebSyncRegistration> web_registration =
- mojo::ConvertTo<scoped_ptr<blink::WebSyncRegistration>>(registration);
-
blink::WebServiceWorkerContextProxy::LastChanceOption web_last_chance =
mojo::ConvertTo<blink::WebServiceWorkerContextProxy::LastChanceOption>(
last_chance);
- client->DispatchSyncEvent(*web_registration, web_last_chance, callback);
+ client->DispatchSyncEvent(tag, web_last_chance, callback);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698