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

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

Issue 2150863002: service worker: Don't BadMessageReceived when a response for a timed out request arrives (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment and move expect 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
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_dispatcher_host_unittest.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/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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // TODO(kinuko): Move all EmbeddedWorker message handling from 54 // TODO(kinuko): Move all EmbeddedWorker message handling from
55 // ServiceWorkerDispatcherHost. 55 // ServiceWorkerDispatcherHost.
56 56
57 EmbeddedWorkerInstance* worker = 57 EmbeddedWorkerInstance* worker =
58 GetWorkerForMessage(process_id, message.routing_id()); 58 GetWorkerForMessage(process_id, message.routing_id());
59 if (!worker) { 59 if (!worker) {
60 // Assume this is from a detached worker, return true to indicate we're 60 // Assume this is from a detached worker, return true to indicate we're
61 // purposely handling the message as no-op. 61 // purposely handling the message as no-op.
62 return true; 62 return true;
63 } 63 }
64 return worker->OnMessageReceived(message); 64 bool handled = worker->OnMessageReceived(message);
65
66 // Assume an unhandled message for a stopping worker is because the message
67 // was timed out and its handler removed prior to stopping.
68 // We might be more precise and record timed out request ids, but some
69 // cumbersome bookkeeping is needed and the IPC messaging will soon migrate
70 // to Mojo anyway.
71 return handled || worker->status() == EmbeddedWorkerStatus::STOPPING;
65 } 72 }
66 73
67 void EmbeddedWorkerRegistry::Shutdown() { 74 void EmbeddedWorkerRegistry::Shutdown() {
68 for (WorkerInstanceMap::iterator it = worker_map_.begin(); 75 for (WorkerInstanceMap::iterator it = worker_map_.begin();
69 it != worker_map_.end(); 76 it != worker_map_.end();
70 ++it) { 77 ++it) {
71 it->second->Stop(); 78 it->second->Stop();
72 } 79 }
73 } 80 }
74 81
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 EmbeddedWorkerInstance* worker = GetWorker(embedded_worker_id); 300 EmbeddedWorkerInstance* worker = GetWorker(embedded_worker_id);
294 if (!worker || worker->process_id() != process_id) { 301 if (!worker || worker->process_id() != process_id) {
295 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", false); 302 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", false);
296 return nullptr; 303 return nullptr;
297 } 304 }
298 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", true); 305 UMA_HISTOGRAM_BOOLEAN("ServiceWorker.WorkerForMessageFound", true);
299 return worker; 306 return worker;
300 } 307 }
301 308
302 } // namespace content 309 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698