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

Side by Side Diff: content/child/service_worker/web_service_worker_provider_impl.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: add header comment 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/service_worker/web_service_worker_provider_impl.h" 5 #include "content/child/service_worker/web_service_worker_provider_impl.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "content/child/service_worker/service_worker_dispatcher.h" 9 #include "content/child/service_worker/service_worker_dispatcher.h"
10 #include "content/child/service_worker/service_worker_handle_reference.h" 10 #include "content/child/service_worker/service_worker_handle_reference.h"
11 #include "content/child/service_worker/service_worker_message_sender.h"
11 #include "content/child/service_worker/service_worker_provider_context.h" 12 #include "content/child/service_worker/service_worker_provider_context.h"
12 #include "content/child/service_worker/service_worker_registration_handle_refere nce.h" 13 #include "content/child/service_worker/service_worker_registration_handle_refere nce.h"
13 #include "content/child/service_worker/web_service_worker_impl.h" 14 #include "content/child/service_worker/web_service_worker_impl.h"
14 #include "content/child/service_worker/web_service_worker_registration_impl.h" 15 #include "content/child/service_worker/web_service_worker_registration_impl.h"
15 #include "content/child/thread_safe_sender.h" 16 #include "content/child/thread_safe_sender.h"
16 #include "content/common/service_worker/service_worker_messages.h" 17 #include "content/common/service_worker/service_worker_messages.h"
17 #include "third_party/WebKit/public/platform/WebServiceWorkerProviderClient.h" 18 #include "third_party/WebKit/public/platform/WebServiceWorkerProviderClient.h"
18 #include "third_party/WebKit/public/platform/WebURL.h" 19 #include "third_party/WebKit/public/platform/WebURL.h"
19 20
20 using blink::WebURL; 21 using blink::WebURL;
21 22
22 namespace content { 23 namespace content {
23 24
24 WebServiceWorkerProviderImpl::WebServiceWorkerProviderImpl( 25 WebServiceWorkerProviderImpl::WebServiceWorkerProviderImpl(
25 ThreadSafeSender* thread_safe_sender, 26 ThreadSafeSender* thread_safe_sender,
26 ServiceWorkerProviderContext* context) 27 ServiceWorkerProviderContext* context)
27 : thread_safe_sender_(thread_safe_sender), 28 : sender_(new ServiceWorkerMessageSender(thread_safe_sender)),
28 context_(context), 29 context_(context),
29 provider_id_(context->provider_id()) { 30 provider_id_(context->provider_id()) {
30 } 31 }
31 32
32 WebServiceWorkerProviderImpl::~WebServiceWorkerProviderImpl() { 33 WebServiceWorkerProviderImpl::~WebServiceWorkerProviderImpl() {
33 // Make sure the provider client is removed. 34 // Make sure the provider client is removed.
34 RemoveProviderClient(); 35 RemoveProviderClient();
35 } 36 }
36 37
37 void WebServiceWorkerProviderImpl::setClient( 38 void WebServiceWorkerProviderImpl::setClient(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // Remove the provider client, but only if the dispatcher is still there. 92 // Remove the provider client, but only if the dispatcher is still there.
92 // (For cleanup path we don't need to bother creating a new dispatcher) 93 // (For cleanup path we don't need to bother creating a new dispatcher)
93 ServiceWorkerDispatcher* dispatcher = 94 ServiceWorkerDispatcher* dispatcher =
94 ServiceWorkerDispatcher::GetThreadSpecificInstance(); 95 ServiceWorkerDispatcher::GetThreadSpecificInstance();
95 if (dispatcher) 96 if (dispatcher)
96 dispatcher->RemoveProviderClient(provider_id_); 97 dispatcher->RemoveProviderClient(provider_id_);
97 } 98 }
98 99
99 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() { 100 ServiceWorkerDispatcher* WebServiceWorkerProviderImpl::GetDispatcher() {
100 return ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( 101 return ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance(
101 thread_safe_sender_.get()); 102 sender_.get());
102 } 103 }
103 104
104 } // namespace content 105 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698