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

Unified Diff: content/child/service_worker/web_service_worker_provider_impl.cc

Issue 182863004: Wire provider_id into scriptable API provider to start listening events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit fix Created 6 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/child/service_worker/web_service_worker_provider_impl.cc
diff --git a/content/child/service_worker/web_service_worker_provider_impl.cc b/content/child/service_worker/web_service_worker_provider_impl.cc
index 8b375adf31cc63baee5d88d9a956b5a2e019c68c..af8c9c99cda43f65d40de4d77108a3fc32d20d8f 100644
--- a/content/child/service_worker/web_service_worker_provider_impl.cc
+++ b/content/child/service_worker/web_service_worker_provider_impl.cc
@@ -9,8 +9,6 @@
#include "content/child/child_thread.h"
#include "content/child/service_worker/service_worker_dispatcher.h"
#include "content/child/thread_safe_sender.h"
-#include "content/common/service_worker/service_worker_messages.h"
-#include "third_party/WebKit/public/platform/WebServiceWorkerProviderClient.h"
#include "third_party/WebKit/public/platform/WebURL.h"
using blink::WebURL;
@@ -18,34 +16,40 @@ using blink::WebURL;
namespace content {
WebServiceWorkerProviderImpl::WebServiceWorkerProviderImpl(
- ThreadSafeSender* thread_safe_sender)
+ ThreadSafeSender* thread_safe_sender,
+ int provider_id)
: thread_safe_sender_(thread_safe_sender),
- client_(NULL) {
+ provider_id_(provider_id) {
}
WebServiceWorkerProviderImpl::~WebServiceWorkerProviderImpl() {
+ // Make sure the script client is removed.
+ GetDispatcher()->RemoveScriptClient(provider_id_);
}
void WebServiceWorkerProviderImpl::setClient(
blink::WebServiceWorkerProviderClient* client) {
- // TODO(kinuko): We should register the client with provider_id
- // so that the client can start listening events for the provider.
- client_ = client;
+ if (client)
+ GetDispatcher()->AddScriptClient(provider_id_, client);
+ else
+ GetDispatcher()->RemoveScriptClient(provider_id_);
}
void WebServiceWorkerProviderImpl::registerServiceWorker(
const WebURL& pattern,
const WebURL& script_url,
WebServiceWorkerCallbacks* callbacks) {
- ServiceWorkerDispatcher::ThreadSpecificInstance(thread_safe_sender_)
- ->RegisterServiceWorker(pattern, script_url, callbacks);
+ GetDispatcher()->RegisterServiceWorker(pattern, script_url, callbacks);
}
void WebServiceWorkerProviderImpl::unregisterServiceWorker(
const WebURL& pattern,
WebServiceWorkerCallbacks* callbacks) {
- ServiceWorkerDispatcher::ThreadSpecificInstance(thread_safe_sender_)
- ->UnregisterServiceWorker(pattern, callbacks);
+ GetDispatcher()->UnregisterServiceWorker(pattern, callbacks);
+}
+
+ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() {
+ return ServiceWorkerDispatcher::ThreadSpecificInstance(thread_safe_sender_);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698