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

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

Issue 2154663002: service worker: Relax the BadMessageReceived call in OnSetHostedVersionId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: newl 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/service_worker_dispatcher_host.h" 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/debug/crash_logging.h" 9 #include "base/debug/crash_logging.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 !ServiceWorkerUtils::IsBrowserAssignedProviderId(provider_id)) { 845 !ServiceWorkerUtils::IsBrowserAssignedProviderId(provider_id)) {
846 bad_message::ReceivedBadMessage( 846 bad_message::ReceivedBadMessage(
847 this, bad_message::SWDH_PROVIDER_DESTROYED_NO_HOST); 847 this, bad_message::SWDH_PROVIDER_DESTROYED_NO_HOST);
848 } 848 }
849 return; 849 return;
850 } 850 }
851 GetContext()->RemoveProviderHost(render_process_id_, provider_id); 851 GetContext()->RemoveProviderHost(render_process_id_, provider_id);
852 } 852 }
853 853
854 void ServiceWorkerDispatcherHost::OnSetHostedVersionId(int provider_id, 854 void ServiceWorkerDispatcherHost::OnSetHostedVersionId(int provider_id,
855 int64_t version_id) { 855 int64_t version_id,
856 int embedded_worker_id) {
856 TRACE_EVENT0("ServiceWorker", 857 TRACE_EVENT0("ServiceWorker",
857 "ServiceWorkerDispatcherHost::OnSetHostedVersionId"); 858 "ServiceWorkerDispatcherHost::OnSetHostedVersionId");
858 if (!GetContext()) 859 if (!GetContext())
859 return; 860 return;
860 ServiceWorkerProviderHost* provider_host = 861 ServiceWorkerProviderHost* provider_host =
861 GetContext()->GetProviderHost(render_process_id_, provider_id); 862 GetContext()->GetProviderHost(render_process_id_, provider_id);
862 if (!provider_host) { 863 if (!provider_host) {
863 bad_message::ReceivedBadMessage( 864 bad_message::ReceivedBadMessage(
864 this, bad_message::SWDH_SET_HOSTED_VERSION_NO_HOST); 865 this, bad_message::SWDH_SET_HOSTED_VERSION_NO_HOST);
865 return; 866 return;
(...skipping 10 matching lines...) Expand all
876 // due to restarting the service worker system etc. 877 // due to restarting the service worker system etc.
877 if (!provider_host->IsContextAlive()) 878 if (!provider_host->IsContextAlive())
878 return; 879 return;
879 880
880 // We might not be STARTING if the stop sequence was entered (STOPPING) or 881 // We might not be STARTING if the stop sequence was entered (STOPPING) or
881 // ended up being detached (STOPPED). 882 // ended up being detached (STOPPED).
882 ServiceWorkerVersion* version = GetContext()->GetLiveVersion(version_id); 883 ServiceWorkerVersion* version = GetContext()->GetLiveVersion(version_id);
883 if (!version || version->running_status() != EmbeddedWorkerStatus::STARTING) 884 if (!version || version->running_status() != EmbeddedWorkerStatus::STARTING)
884 return; 885 return;
885 886
887 // If the version has a different embedded worker, assume the message is about
888 // a detached worker and ignore.
889 if (version->embedded_worker()->embedded_worker_id() != embedded_worker_id)
890 return;
891
886 // A process for the worker must be equal to a process for the provider host. 892 // A process for the worker must be equal to a process for the provider host.
887 if (version->embedded_worker()->process_id() != provider_host->process_id()) { 893 if (version->embedded_worker()->process_id() != provider_host->process_id()) {
888 bad_message::ReceivedBadMessage( 894 bad_message::ReceivedBadMessage(
889 this, bad_message::SWDH_SET_HOSTED_VERSION_PROCESS_MISMATCH); 895 this, bad_message::SWDH_SET_HOSTED_VERSION_PROCESS_MISMATCH);
890 return; 896 return;
891 } 897 }
892 898
893 provider_host->SetHostedVersion(version); 899 provider_host->SetHostedVersion(version);
894 900
895 // Retrieve the registration associated with |version|. The registration 901 // Retrieve the registration associated with |version|. The registration
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 if (!handle) { 1465 if (!handle) {
1460 bad_message::ReceivedBadMessage(this, 1466 bad_message::ReceivedBadMessage(this,
1461 bad_message::SWDH_TERMINATE_BAD_HANDLE); 1467 bad_message::SWDH_TERMINATE_BAD_HANDLE);
1462 return; 1468 return;
1463 } 1469 }
1464 handle->version()->StopWorker( 1470 handle->version()->StopWorker(
1465 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1471 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1466 } 1472 }
1467 1473
1468 } // namespace content 1474 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698