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

Side by Side Diff: content/browser/service_worker/embedded_worker_registry.cc

Issue 2149273003: service worker: Tweak some documentation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 5 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/browser/service_worker/embedded_worker_registry.h" 5 #include "content/browser/service_worker/embedded_worker_registry.h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "content/browser/renderer_host/render_widget_helper.h" 10 #include "content/browser/renderer_host/render_widget_helper.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 129
130 void EmbeddedWorkerRegistry::OnWorkerStarted( 130 void EmbeddedWorkerRegistry::OnWorkerStarted(
131 int process_id, int embedded_worker_id) { 131 int process_id, int embedded_worker_id) {
132 EmbeddedWorkerInstance* worker = 132 EmbeddedWorkerInstance* worker =
133 GetWorkerForMessage(process_id, embedded_worker_id); 133 GetWorkerForMessage(process_id, embedded_worker_id);
134 if (!worker) 134 if (!worker)
135 return; 135 return;
136 136
137 if (!ContainsKey(worker_process_map_, process_id) || 137 if (!ContainsKey(worker_process_map_, process_id) ||
138 worker_process_map_[process_id].count(embedded_worker_id) == 0) { 138 !ContainsKey(worker_process_map_[process_id], embedded_worker_id)) {
139 return; 139 return;
140 } 140 }
141 141
142 worker->OnStarted(); 142 worker->OnStarted();
143 } 143 }
144 144
145 void EmbeddedWorkerRegistry::OnWorkerStopped( 145 void EmbeddedWorkerRegistry::OnWorkerStopped(
146 int process_id, int embedded_worker_id) { 146 int process_id, int embedded_worker_id) {
147 EmbeddedWorkerInstance* worker = 147 EmbeddedWorkerInstance* worker =
148 GetWorkerForMessage(process_id, embedded_worker_id); 148 GetWorkerForMessage(process_id, embedded_worker_id);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 int process_id) { 249 int process_id) {
250 if (!context_) 250 if (!context_)
251 return SERVICE_WORKER_ERROR_ABORT; 251 return SERVICE_WORKER_ERROR_ABORT;
252 252
253 // The ServiceWorkerDispatcherHost is supposed to be created when the process 253 // The ServiceWorkerDispatcherHost is supposed to be created when the process
254 // is created, and keep an entry in process_sender_map_ for its whole 254 // is created, and keep an entry in process_sender_map_ for its whole
255 // lifetime. 255 // lifetime.
256 DCHECK(ContainsKey(process_sender_map_, process_id)); 256 DCHECK(ContainsKey(process_sender_map_, process_id));
257 257
258 int embedded_worker_id = params->embedded_worker_id; 258 int embedded_worker_id = params->embedded_worker_id;
259 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); 259 DCHECK(GetWorker(embedded_worker_id));
260 DCHECK(found != worker_map_.end()); 260 DCHECK_EQ(GetWorker(embedded_worker_id)->process_id(), process_id);
261 DCHECK_EQ(found->second->process_id(), process_id);
262
263 DCHECK(!ContainsKey(worker_process_map_, process_id) || 261 DCHECK(!ContainsKey(worker_process_map_, process_id) ||
264 worker_process_map_[process_id].count(embedded_worker_id) == 0); 262 !ContainsKey(worker_process_map_[process_id], embedded_worker_id));
265 263
266 ServiceWorkerStatusCode status = 264 ServiceWorkerStatusCode status =
267 Send(process_id, new EmbeddedWorkerMsg_StartWorker(*params)); 265 Send(process_id, new EmbeddedWorkerMsg_StartWorker(*params));
268 if (status == SERVICE_WORKER_OK) 266 if (status == SERVICE_WORKER_OK)
269 worker_process_map_[process_id].insert(embedded_worker_id); 267 worker_process_map_[process_id].insert(embedded_worker_id);
270 return status; 268 return status;
271 } 269 }
272 270
273 ServiceWorkerStatusCode EmbeddedWorkerRegistry::Send( 271 ServiceWorkerStatusCode EmbeddedWorkerRegistry::Send(
274 int process_id, IPC::Message* message_ptr) { 272 int process_id, IPC::Message* message_ptr) {
(...skipping 25 matching lines...) Expand all
300 EmbeddedWorkerInstance* worker = GetWorker(embedded_worker_id); 298 EmbeddedWorkerInstance* worker = GetWorker(embedded_worker_id);
301 if (!worker || worker->process_id() != process_id) { 299 if (!worker || worker->process_id() != process_id) {
302 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", false); 300 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", false);
303 return nullptr; 301 return nullptr;
304 } 302 }
305 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", true); 303 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", true);
306 return worker; 304 return worker;
307 } 305 }
308 306
309 } // namespace content 307 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698