diff options
author | jkarlin <jkarlin@chromium.org> | 2016-03-15 13:41:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-15 20:43:06 +0000 |
commit | 6b0615b5f2dd5744a9e606ec88a9062bca934d56 (patch) | |
tree | 31e6c57b79809879ac15758fa7692a765772be7a /content/renderer/background_sync | |
parent | 35aa85bd42c46d31c7019ce28c0471cfe7cae70f (diff) | |
download | chromium_src-6b0615b5f2dd5744a9e606ec88a9062bca934d56.zip chromium_src-6b0615b5f2dd5744a9e606ec88a9062bca934d56.tar.gz chromium_src-6b0615b5f2dd5744a9e606ec88a9062bca934d56.tar.bz2 |
[BackgroundSync] Remove BackgroundSyncRegistrationHandle
Since "registration.done" is no longer part of the spec, the BackgroundSyncManager no longer needs to refcount its registrations. This CL removes the internal reference counting and the handles that were provided to clients.
BUG=583328
Review URL: https://codereview.chromium.org/1763123002
Cr-Commit-Position: refs/heads/master@{#381303}
Diffstat (limited to 'content/renderer/background_sync')
-rw-r--r-- | content/renderer/background_sync/background_sync_client_impl.cc | 49 | ||||
-rw-r--r-- | content/renderer/background_sync/background_sync_client_impl.h | 10 |
2 files changed, 4 insertions, 55 deletions
diff --git a/content/renderer/background_sync/background_sync_client_impl.cc b/content/renderer/background_sync/background_sync_client_impl.cc index bd420c0..1954512 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 diff --git a/content/renderer/background_sync/background_sync_client_impl.h b/content/renderer/background_sync/background_sync_client_impl.h index 3b209b3..c18ccf1 100644 --- a/content/renderer/background_sync/background_sync_client_impl.h +++ b/content/renderer/background_sync/background_sync_client_impl.h @@ -31,20 +31,12 @@ class CONTENT_EXPORT BackgroundSyncClientImpl mojo::InterfaceRequest<BackgroundSyncServiceClient> request); // BackgroundSyncServiceClient methods: - void Sync(int64_t handle_id, + void Sync(const mojo::String& tag, content::BackgroundSyncEventLastChance last_chance, const SyncCallback& callback) override; - void SyncDidGetRegistration( - int64_t callback_id, - content::BackgroundSyncEventLastChance last_chance, - BackgroundSyncError error, - SyncRegistrationPtr registration); mojo::StrongBinding<BackgroundSyncServiceClient> binding_; - int64_t callback_seq_num_; - std::map<int64_t, SyncCallback> sync_callbacks_; - DISALLOW_COPY_AND_ASSIGN(BackgroundSyncClientImpl); }; |