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

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

Issue 2653493009: Add two interfaces for ServiceWorkerProviderContext/ProviderHost (Closed)
Patch Set: Rebase Created 3 years, 8 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 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 if (ServiceWorkerUtils::IsBrowserAssignedProviderId(info.provider_id)) { 1033 if (ServiceWorkerUtils::IsBrowserAssignedProviderId(info.provider_id)) {
1034 bad_message::ReceivedBadMessage( 1034 bad_message::ReceivedBadMessage(
1035 this, bad_message::SWDH_PROVIDER_CREATED_NO_HOST); 1035 this, bad_message::SWDH_PROVIDER_CREATED_NO_HOST);
1036 return; 1036 return;
1037 } 1037 }
1038 GetContext()->AddProviderHost(ServiceWorkerProviderHost::Create( 1038 GetContext()->AddProviderHost(ServiceWorkerProviderHost::Create(
1039 render_process_id_, std::move(info), GetContext()->AsWeakPtr(), this)); 1039 render_process_id_, std::move(info), GetContext()->AsWeakPtr(), this));
1040 } 1040 }
1041 } 1041 }
1042 1042
1043 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) {
1044 TRACE_EVENT0("ServiceWorker",
1045 "ServiceWorkerDispatcherHost::OnProviderDestroyed");
1046 if (!GetContext())
1047 return;
1048 if (!GetContext()->GetProviderHost(render_process_id_, provider_id)) {
1049 // PlzNavigate: in some cancellation of navigation cases, it is possible
1050 // for the pre-created hoist to have been destroyed before being claimed by
1051 // the renderer. The provider is then destroyed in the renderer, and no
1052 // matching host will be found.
1053 if (!IsBrowserSideNavigationEnabled() ||
1054 !ServiceWorkerUtils::IsBrowserAssignedProviderId(provider_id)) {
1055 bad_message::ReceivedBadMessage(
1056 this, bad_message::SWDH_PROVIDER_DESTROYED_NO_HOST);
1057 }
1058 return;
1059 }
1060 GetContext()->RemoveProviderHost(render_process_id_, provider_id);
1061 }
1062
1063 void ServiceWorkerDispatcherHost::OnSetHostedVersionId(int provider_id, 1043 void ServiceWorkerDispatcherHost::OnSetHostedVersionId(int provider_id,
1064 int64_t version_id, 1044 int64_t version_id,
1065 int embedded_worker_id) { 1045 int embedded_worker_id) {
1066 TRACE_EVENT0("ServiceWorker", 1046 TRACE_EVENT0("ServiceWorker",
1067 "ServiceWorkerDispatcherHost::OnSetHostedVersionId"); 1047 "ServiceWorkerDispatcherHost::OnSetHostedVersionId");
1068 if (!GetContext()) 1048 if (!GetContext())
1069 return; 1049 return;
1070 ServiceWorkerProviderHost* provider_host = 1050 ServiceWorkerProviderHost* provider_host =
1071 GetContext()->GetProviderHost(render_process_id_, provider_id); 1051 GetContext()->GetProviderHost(render_process_id_, provider_id);
1072 if (!provider_host) { 1052 if (!provider_host) {
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 if (!handle) { 1760 if (!handle) {
1781 bad_message::ReceivedBadMessage(this, 1761 bad_message::ReceivedBadMessage(this,
1782 bad_message::SWDH_TERMINATE_BAD_HANDLE); 1762 bad_message::SWDH_TERMINATE_BAD_HANDLE);
1783 return; 1763 return;
1784 } 1764 }
1785 handle->version()->StopWorker( 1765 handle->version()->StopWorker(
1786 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1766 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1787 } 1767 }
1788 1768
1789 } // namespace content 1769 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698