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

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

Issue 1011643002: ServiceWorker: Introduce SWMessageSender in order to mock IPC messaging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/service_worker_provider_context.cc
diff --git a/content/child/service_worker/service_worker_provider_context.cc b/content/child/service_worker/service_worker_provider_context.cc
index d8273aaef4607725d961b6f3a48340f38e9825d5..01c0cbf15504af23a7175b9b0dd1d434f5642a07 100644
--- a/content/child/service_worker/service_worker_provider_context.cc
+++ b/content/child/service_worker/service_worker_provider_context.cc
@@ -10,6 +10,7 @@
#include "content/child/child_thread_impl.h"
#include "content/child/service_worker/service_worker_dispatcher.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_registration_handle_reference.h"
#include "content/child/thread_safe_sender.h"
#include "content/child/worker_task_runner.h"
@@ -22,10 +23,12 @@ ServiceWorkerProviderContext::ServiceWorkerProviderContext(int provider_id)
main_thread_loop_proxy_(base::MessageLoopProxy::current()) {
if (!ChildThreadImpl::current())
return; // May be null in some tests.
- thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender();
+ ThreadSafeSender* thread_safe_sender =
+ ChildThreadImpl::current()->thread_safe_sender();
+ sender_ = new ServiceWorkerMessageSender(thread_safe_sender);
ServiceWorkerDispatcher* dispatcher =
ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance(
Kunihiko Sakamoto 2015/03/17 03:40:38 Why not make this take a ServiceWorkerMessageSende
nhiroki 2015/03/17 07:36:53 Done.
- thread_safe_sender_.get());
+ thread_safe_sender);
DCHECK(dispatcher);
dispatcher->AddProviderContext(this);
}
@@ -69,15 +72,15 @@ void ServiceWorkerProviderContext::SetVersionAttributes(
if (mask.installing_changed()) {
installing_ = ServiceWorkerHandleReference::Adopt(
- attrs.installing, thread_safe_sender_.get());
+ attrs.installing, sender_.get());
}
if (mask.waiting_changed()) {
waiting_ = ServiceWorkerHandleReference::Adopt(
- attrs.waiting, thread_safe_sender_.get());
+ attrs.waiting, sender_.get());
}
if (mask.active_changed()) {
active_ = ServiceWorkerHandleReference::Adopt(
- attrs.active, thread_safe_sender_.get());
+ attrs.active, sender_.get());
}
}
@@ -90,14 +93,12 @@ void ServiceWorkerProviderContext::OnAssociateRegistration(
DCHECK_NE(kInvalidServiceWorkerRegistrationId, info.registration_id);
DCHECK_NE(kInvalidServiceWorkerRegistrationHandleId, info.handle_id);
- registration_ = ServiceWorkerRegistrationHandleReference::Adopt(
- info, thread_safe_sender_.get());
- installing_ = ServiceWorkerHandleReference::Adopt(
- attrs.installing, thread_safe_sender_.get());
- waiting_ = ServiceWorkerHandleReference::Adopt(
- attrs.waiting, thread_safe_sender_.get());
- active_ = ServiceWorkerHandleReference::Adopt(
- attrs.active, thread_safe_sender_.get());
+ registration_ =
+ ServiceWorkerRegistrationHandleReference::Adopt(info, sender_.get());
+ installing_ =
+ ServiceWorkerHandleReference::Adopt(attrs.installing, sender_.get());
+ waiting_ = ServiceWorkerHandleReference::Adopt(attrs.waiting, sender_.get());
+ active_ = ServiceWorkerHandleReference::Adopt(attrs.active, sender_.get());
}
void ServiceWorkerProviderContext::OnDisassociateRegistration() {
@@ -144,8 +145,7 @@ void ServiceWorkerProviderContext::OnSetControllerServiceWorker(
// This context is is the primary owner of this handle, keeps the
// initial reference until it goes away.
- controller_ =
- ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get());
+ controller_ = ServiceWorkerHandleReference::Adopt(info, sender_.get());
// TODO(kinuko): We can forward the message to other threads here
// when we support navigator.serviceWorker in dedicated workers.

Powered by Google App Engine
This is Rietveld 408576698