Index: content/child/service_worker/service_worker_dispatcher.cc |
diff --git a/content/child/service_worker/service_worker_dispatcher.cc b/content/child/service_worker/service_worker_dispatcher.cc |
index da1f5c456472a0b76004d3a2273b906749557ab7..6b3ddfc2b17d65762ab4afd374fd554e64a3a952 100644 |
--- a/content/child/service_worker/service_worker_dispatcher.cc |
+++ b/content/child/service_worker/service_worker_dispatcher.cc |
@@ -10,6 +10,7 @@ |
#include "base/trace_event/trace_event.h" |
#include "content/child/child_thread_impl.h" |
#include "content/child/service_worker/service_worker_handle_reference.h" |
+#include "content/child/service_worker/service_worker_message_sender.h" |
#include "content/child/service_worker/service_worker_provider_context.h" |
#include "content/child/service_worker/service_worker_registration_handle_reference.h" |
#include "content/child/service_worker/web_service_worker_impl.h" |
@@ -46,7 +47,13 @@ int CurrentWorkerId() { |
ServiceWorkerDispatcher::ServiceWorkerDispatcher( |
ThreadSafeSender* thread_safe_sender) |
- : thread_safe_sender_(thread_safe_sender) { |
+ : sender_(new ServiceWorkerMessageSender(thread_safe_sender)) { |
+ g_dispatcher_tls.Pointer()->Set(this); |
+} |
+ |
+ServiceWorkerDispatcher::ServiceWorkerDispatcher( |
+ ServiceWorkerMessageSender* sender) |
+ : sender_(sender) { |
g_dispatcher_tls.Pointer()->Set(this); |
} |
@@ -91,10 +98,6 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) { |
DCHECK(handled) << "Unhandled message:" << msg.type(); |
} |
-bool ServiceWorkerDispatcher::Send(IPC::Message* msg) { |
- return thread_safe_sender_->Send(msg); |
-} |
- |
void ServiceWorkerDispatcher::RegisterServiceWorker( |
int provider_id, |
const GURL& pattern, |
@@ -121,7 +124,7 @@ void ServiceWorkerDispatcher::RegisterServiceWorker( |
request_id, |
"Scope", pattern.spec(), |
"Script URL", script_url.spec()); |
- thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( |
+ sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( |
CurrentWorkerId(), request_id, provider_id, pattern, script_url)); |
} |
@@ -148,7 +151,7 @@ void ServiceWorkerDispatcher::UnregisterServiceWorker( |
"ServiceWorkerDispatcher::UnregisterServiceWorker", |
request_id, |
"Scope", pattern.spec()); |
- thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker( |
+ sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker( |
CurrentWorkerId(), request_id, provider_id, pattern)); |
} |
@@ -175,7 +178,7 @@ void ServiceWorkerDispatcher::GetRegistration( |
"ServiceWorkerDispatcher::GetRegistration", |
request_id, |
"Document URL", document_url.spec()); |
- thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistration( |
+ sender_->Send(new ServiceWorkerHostMsg_GetRegistration( |
CurrentWorkerId(), request_id, provider_id, document_url)); |
} |
@@ -186,7 +189,7 @@ void ServiceWorkerDispatcher::GetRegistrationForReady( |
TRACE_EVENT_ASYNC_BEGIN0("ServiceWorker", |
"ServiceWorkerDispatcher::GetRegistrationForReady", |
request_id); |
- thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistrationForReady( |
+ sender_->Send(new ServiceWorkerHostMsg_GetRegistrationForReady( |
CurrentWorkerId(), request_id, provider_id)); |
} |
@@ -263,18 +266,17 @@ WebServiceWorkerImpl* ServiceWorkerDispatcher::GetServiceWorker( |
if (adopt_handle) { |
// We are instructed to adopt a handle but we already have one, so |
// adopt and destroy a handle ref. |
- ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); |
+ ServiceWorkerHandleReference::Adopt(info, sender_.get()); |
} |
return existing_worker->second; |
} |
scoped_ptr<ServiceWorkerHandleReference> handle_ref = |
adopt_handle |
- ? ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()) |
- : ServiceWorkerHandleReference::Create(info, |
- thread_safe_sender_.get()); |
+ ? ServiceWorkerHandleReference::Adopt(info, sender_.get()) |
+ : ServiceWorkerHandleReference::Create(info, sender_.get()); |
// WebServiceWorkerImpl constructor calls AddServiceWorker. |
- return new WebServiceWorkerImpl(handle_ref.Pass(), thread_safe_sender_.get()); |
+ return new WebServiceWorkerImpl(handle_ref.Pass(), sender_.get()); |
} |
WebServiceWorkerRegistrationImpl* |
@@ -288,8 +290,7 @@ ServiceWorkerDispatcher::FindServiceWorkerRegistration( |
if (adopt_handle) { |
// We are instructed to adopt a handle but we already have one, so |
// adopt and destroy a handle ref. |
- ServiceWorkerRegistrationHandleReference::Adopt( |
- info, thread_safe_sender_.get()); |
+ ServiceWorkerRegistrationHandleReference::Adopt(info, sender_.get()); |
} |
return registration->second; |
} |
@@ -304,9 +305,9 @@ ServiceWorkerDispatcher::CreateServiceWorkerRegistration( |
scoped_ptr<ServiceWorkerRegistrationHandleReference> handle_ref = |
adopt_handle ? ServiceWorkerRegistrationHandleReference::Adopt( |
- info, thread_safe_sender_.get()) |
+ info, sender_.get()) |
: ServiceWorkerRegistrationHandleReference::Create( |
- info, thread_safe_sender_.get()); |
+ info, sender_.get()); |
// WebServiceWorkerRegistrationImpl constructor calls |
// AddServiceWorkerRegistration. |
@@ -698,12 +699,9 @@ ServiceWorkerDispatcher::FindOrCreateRegistration( |
} else { |
// |registration| must already have version attributes, so adopt and destroy |
// handle refs for them. |
- ServiceWorkerHandleReference::Adopt( |
- attrs.installing, thread_safe_sender_.get()); |
- ServiceWorkerHandleReference::Adopt( |
- attrs.waiting, thread_safe_sender_.get()); |
- ServiceWorkerHandleReference::Adopt( |
- attrs.active, thread_safe_sender_.get()); |
+ ServiceWorkerHandleReference::Adopt(attrs.installing, sender_.get()); |
+ ServiceWorkerHandleReference::Adopt(attrs.waiting, sender_.get()); |
+ ServiceWorkerHandleReference::Adopt(attrs.active, sender_.get()); |
} |
return registration; |
} |