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

Side by Side Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 2228403003: content: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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
« no previous file with comments | « content/child/resource_dispatcher_unittest.cc ('k') | content/child/worker_thread_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/service_worker_dispatcher.h" 5 #include "content/child/service_worker/service_worker_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 "ServiceWorkerDispatcher::GetRegistrationForReady", 203 "ServiceWorkerDispatcher::GetRegistrationForReady",
204 request_id); 204 request_id);
205 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistrationForReady( 205 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistrationForReady(
206 CurrentWorkerId(), request_id, provider_id)); 206 CurrentWorkerId(), request_id, provider_id));
207 } 207 }
208 208
209 void ServiceWorkerDispatcher::AddProviderContext( 209 void ServiceWorkerDispatcher::AddProviderContext(
210 ServiceWorkerProviderContext* provider_context) { 210 ServiceWorkerProviderContext* provider_context) {
211 DCHECK(provider_context); 211 DCHECK(provider_context);
212 int provider_id = provider_context->provider_id(); 212 int provider_id = provider_context->provider_id();
213 DCHECK(!ContainsKey(provider_contexts_, provider_id)); 213 DCHECK(!base::ContainsKey(provider_contexts_, provider_id));
214 provider_contexts_[provider_id] = provider_context; 214 provider_contexts_[provider_id] = provider_context;
215 } 215 }
216 216
217 void ServiceWorkerDispatcher::RemoveProviderContext( 217 void ServiceWorkerDispatcher::RemoveProviderContext(
218 ServiceWorkerProviderContext* provider_context) { 218 ServiceWorkerProviderContext* provider_context) {
219 DCHECK(provider_context); 219 DCHECK(provider_context);
220 DCHECK(ContainsKey(provider_contexts_, provider_context->provider_id())); 220 DCHECK(
221 base::ContainsKey(provider_contexts_, provider_context->provider_id()));
221 provider_contexts_.erase(provider_context->provider_id()); 222 provider_contexts_.erase(provider_context->provider_id());
222 } 223 }
223 224
224 void ServiceWorkerDispatcher::AddProviderClient( 225 void ServiceWorkerDispatcher::AddProviderClient(
225 int provider_id, 226 int provider_id,
226 blink::WebServiceWorkerProviderClient* client) { 227 blink::WebServiceWorkerProviderClient* client) {
227 DCHECK(client); 228 DCHECK(client);
228 DCHECK(!ContainsKey(provider_clients_, provider_id)); 229 DCHECK(!base::ContainsKey(provider_clients_, provider_id));
229 provider_clients_[provider_id] = client; 230 provider_clients_[provider_id] = client;
230 } 231 }
231 232
232 void ServiceWorkerDispatcher::RemoveProviderClient(int provider_id) { 233 void ServiceWorkerDispatcher::RemoveProviderClient(int provider_id) {
233 // This could be possibly called multiple times to ensure termination. 234 // This could be possibly called multiple times to ensure termination.
234 if (ContainsKey(provider_clients_, provider_id)) 235 if (base::ContainsKey(provider_clients_, provider_id))
235 provider_clients_.erase(provider_id); 236 provider_clients_.erase(provider_id);
236 } 237 }
237 238
238 ServiceWorkerDispatcher* 239 ServiceWorkerDispatcher*
239 ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( 240 ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance(
240 ThreadSafeSender* thread_safe_sender, 241 ThreadSafeSender* thread_safe_sender,
241 base::SingleThreadTaskRunner* main_thread_task_runner) { 242 base::SingleThreadTaskRunner* main_thread_task_runner) {
242 if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) { 243 if (g_dispatcher_tls.Pointer()->Get() == kHasBeenDeleted) {
243 NOTREACHED() << "Re-instantiating TLS ServiceWorkerDispatcher."; 244 NOTREACHED() << "Re-instantiating TLS ServiceWorkerDispatcher.";
244 g_dispatcher_tls.Pointer()->Set(NULL); 245 g_dispatcher_tls.Pointer()->Set(NULL);
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 WebMessagePortChannelImpl::CreatePorts( 740 WebMessagePortChannelImpl::CreatePorts(
740 params.message_ports, params.new_routing_ids, 741 params.message_ports, params.new_routing_ids,
741 base::ThreadTaskRunnerHandle::Get()); 742 base::ThreadTaskRunnerHandle::Get());
742 743
743 found->second->dispatchMessageEvent( 744 found->second->dispatchMessageEvent(
744 WebServiceWorkerImpl::CreateHandle(worker), params.message, ports); 745 WebServiceWorkerImpl::CreateHandle(worker), params.message, ports);
745 } 746 }
746 747
747 void ServiceWorkerDispatcher::AddServiceWorker( 748 void ServiceWorkerDispatcher::AddServiceWorker(
748 int handle_id, WebServiceWorkerImpl* worker) { 749 int handle_id, WebServiceWorkerImpl* worker) {
749 DCHECK(!ContainsKey(service_workers_, handle_id)); 750 DCHECK(!base::ContainsKey(service_workers_, handle_id));
750 service_workers_[handle_id] = worker; 751 service_workers_[handle_id] = worker;
751 } 752 }
752 753
753 void ServiceWorkerDispatcher::RemoveServiceWorker(int handle_id) { 754 void ServiceWorkerDispatcher::RemoveServiceWorker(int handle_id) {
754 DCHECK(ContainsKey(service_workers_, handle_id)); 755 DCHECK(base::ContainsKey(service_workers_, handle_id));
755 service_workers_.erase(handle_id); 756 service_workers_.erase(handle_id);
756 } 757 }
757 758
758 void ServiceWorkerDispatcher::AddServiceWorkerRegistration( 759 void ServiceWorkerDispatcher::AddServiceWorkerRegistration(
759 int registration_handle_id, 760 int registration_handle_id,
760 WebServiceWorkerRegistrationImpl* registration) { 761 WebServiceWorkerRegistrationImpl* registration) {
761 DCHECK(!ContainsKey(registrations_, registration_handle_id)); 762 DCHECK(!base::ContainsKey(registrations_, registration_handle_id));
762 registrations_[registration_handle_id] = registration; 763 registrations_[registration_handle_id] = registration;
763 } 764 }
764 765
765 void ServiceWorkerDispatcher::RemoveServiceWorkerRegistration( 766 void ServiceWorkerDispatcher::RemoveServiceWorkerRegistration(
766 int registration_handle_id) { 767 int registration_handle_id) {
767 DCHECK(ContainsKey(registrations_, registration_handle_id)); 768 DCHECK(base::ContainsKey(registrations_, registration_handle_id));
768 registrations_.erase(registration_handle_id); 769 registrations_.erase(registration_handle_id);
769 } 770 }
770 771
771 std::unique_ptr<ServiceWorkerRegistrationHandleReference> 772 std::unique_ptr<ServiceWorkerRegistrationHandleReference>
772 ServiceWorkerDispatcher::Adopt( 773 ServiceWorkerDispatcher::Adopt(
773 const ServiceWorkerRegistrationObjectInfo& info) { 774 const ServiceWorkerRegistrationObjectInfo& info) {
774 return ServiceWorkerRegistrationHandleReference::Adopt( 775 return ServiceWorkerRegistrationHandleReference::Adopt(
775 info, thread_safe_sender_.get()); 776 info, thread_safe_sender_.get());
776 } 777 }
777 778
778 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( 779 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt(
779 const ServiceWorkerObjectInfo& info) { 780 const ServiceWorkerObjectInfo& info) {
780 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); 781 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get());
781 } 782 }
782 783
783 } // namespace content 784 } // namespace content
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher_unittest.cc ('k') | content/child/worker_thread_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698