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

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

Issue 2653493009: Add two interfaces for ServiceWorkerProviderContext/ProviderHost (Closed)
Patch Set: Skip unittest for CrossSiteTransfer when PlzNavigate Created 3 years, 6 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 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 if (provider_host == nullptr) { 960 if (provider_host == nullptr) {
961 GetContext()->AddProviderHost( 961 GetContext()->AddProviderHost(
962 ServiceWorkerProviderHost::Create(render_process_id_, std::move(info), 962 ServiceWorkerProviderHost::Create(render_process_id_, std::move(info),
963 GetContext()->AsWeakPtr(), this)); 963 GetContext()->AsWeakPtr(), this));
964 return; 964 return;
965 } 965 }
966 966
967 // Otherwise, completed the initialization of the pre-created host. 967 // Otherwise, completed the initialization of the pre-created host.
968 DCHECK_EQ(SERVICE_WORKER_PROVIDER_FOR_WINDOW, info.type); 968 DCHECK_EQ(SERVICE_WORKER_PROVIDER_FOR_WINDOW, info.type);
969 provider_host->CompleteNavigationInitialized(render_process_id_, 969 provider_host->CompleteNavigationInitialized(render_process_id_,
970 info.route_id, this); 970 std::move(info), this);
971 GetContext()->AddProviderHost(std::move(provider_host)); 971 GetContext()->AddProviderHost(std::move(provider_host));
972 } else { 972 } else {
973 if (ServiceWorkerUtils::IsBrowserAssignedProviderId(info.provider_id)) { 973 if (ServiceWorkerUtils::IsBrowserAssignedProviderId(info.provider_id)) {
974 bad_message::ReceivedBadMessage( 974 bad_message::ReceivedBadMessage(
975 this, bad_message::SWDH_PROVIDER_CREATED_NO_HOST); 975 this, bad_message::SWDH_PROVIDER_CREATED_NO_HOST);
976 return; 976 return;
977 } 977 }
978 GetContext()->AddProviderHost(ServiceWorkerProviderHost::Create( 978 GetContext()->AddProviderHost(ServiceWorkerProviderHost::Create(
979 render_process_id_, std::move(info), GetContext()->AsWeakPtr(), this)); 979 render_process_id_, std::move(info), GetContext()->AsWeakPtr(), this));
980 } 980 }
981 } 981 }
982 982
983 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) {
984 TRACE_EVENT0("ServiceWorker",
985 "ServiceWorkerDispatcherHost::OnProviderDestroyed");
986 if (!GetContext())
987 return;
988 if (!GetContext()->GetProviderHost(render_process_id_, provider_id)) {
989 // PlzNavigate: in some cancellation of navigation cases, it is possible
990 // for the pre-created hoist to have been destroyed before being claimed by
991 // the renderer. The provider is then destroyed in the renderer, and no
992 // matching host will be found.
993 if (!IsBrowserSideNavigationEnabled() ||
994 !ServiceWorkerUtils::IsBrowserAssignedProviderId(provider_id)) {
995 bad_message::ReceivedBadMessage(
996 this, bad_message::SWDH_PROVIDER_DESTROYED_NO_HOST);
997 }
998 return;
999 }
1000 GetContext()->RemoveProviderHost(render_process_id_, provider_id);
1001 }
1002
1003 void ServiceWorkerDispatcherHost::OnSetHostedVersionId(int provider_id, 983 void ServiceWorkerDispatcherHost::OnSetHostedVersionId(int provider_id,
1004 int64_t version_id, 984 int64_t version_id,
1005 int embedded_worker_id) { 985 int embedded_worker_id) {
1006 TRACE_EVENT0("ServiceWorker", 986 TRACE_EVENT0("ServiceWorker",
1007 "ServiceWorkerDispatcherHost::OnSetHostedVersionId"); 987 "ServiceWorkerDispatcherHost::OnSetHostedVersionId");
1008 if (!GetContext()) 988 if (!GetContext())
1009 return; 989 return;
1010 ServiceWorkerProviderHost* provider_host = 990 ServiceWorkerProviderHost* provider_host =
1011 GetContext()->GetProviderHost(render_process_id_, provider_id); 991 GetContext()->GetProviderHost(render_process_id_, provider_id);
1012 if (!provider_host) { 992 if (!provider_host) {
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 if (!handle) { 1569 if (!handle) {
1590 bad_message::ReceivedBadMessage(this, 1570 bad_message::ReceivedBadMessage(this,
1591 bad_message::SWDH_TERMINATE_BAD_HANDLE); 1571 bad_message::SWDH_TERMINATE_BAD_HANDLE);
1592 return; 1572 return;
1593 } 1573 }
1594 handle->version()->StopWorker( 1574 handle->version()->StopWorker(
1595 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1575 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1596 } 1576 }
1597 1577
1598 } // namespace content 1578 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698