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

Unified Diff: content/browser/service_worker/service_worker_provider_host.cc

Issue 1294243004: PlzNavigate: Make ServiceWorker work with PlzNavigate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_provider_host.cc
diff --git a/content/browser/service_worker/service_worker_provider_host.cc b/content/browser/service_worker/service_worker_provider_host.cc
index d27ceb40602b71fea60092d55c96cb3e9b71b7dc..dce2d0080f4f9cb6c5a4cfb88e8bfffeaec7052a 100644
--- a/content/browser/service_worker/service_worker_provider_host.cc
+++ b/content/browser/service_worker/service_worker_provider_host.cc
@@ -4,6 +4,7 @@
#include "content/browser/service_worker/service_worker_provider_host.h"
+#include "base/command_line.h"
#include "base/guid.h"
#include "base/stl_util.h"
#include "base/time/time.h"
@@ -27,6 +28,7 @@
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/child_process_host.h"
+#include "content/public/common/content_switches.h"
namespace content {
@@ -59,6 +61,21 @@ ServiceWorkerClientInfo FocusOnUIThread(int render_process_id,
} // anonymous namespace
+// PlzNavigate
+int ServiceWorkerProviderHost::kVirtualProcessIDForBrowserRequest = -2;
+
+// PlzNavigate
+int ServiceWorkerProviderHost::next_navigation_provider_id_ = -2;
+
+// PlzNavigate
+int ServiceWorkerProviderHost::GetNextNavigationProviderId() {
michaeln 2015/10/01 01:42:16 please DCHECK_CURRENTLY_ON(BrowserThread::UI), sin
Fabrice (no longer in Chrome) 2015/10/01 18:29:55 I moved it so there should no longer be any confus
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
michaeln 2015/10/01 01:42:16 Does this need to be a runtime check? I don't thin
Fabrice (no longer in Chrome) 2015/10/01 18:29:55 It's called in both cases actually, when initializ
+ switches::kEnableBrowserSideNavigation)) {
+ return next_navigation_provider_id_--;
+ }
+ return kInvalidServiceWorkerProviderId;
+}
+
ServiceWorkerProviderHost::OneShotGetReadyCallback::OneShotGetReadyCallback(
const GetRegistrationForReadyCallback& callback)
: callback(callback),
@@ -87,6 +104,12 @@ ServiceWorkerProviderHost::ServiceWorkerProviderHost(
DCHECK_NE(ChildProcessHost::kInvalidUniqueID, render_process_id_);
DCHECK_NE(SERVICE_WORKER_PROVIDER_UNKNOWN, provider_type_);
DCHECK_NE(SERVICE_WORKER_PROVIDER_FOR_SANDBOXED_FRAME, provider_type_);
+
+ // PlzNavigate
+ CHECK_IMPLIES(render_process_id == kVirtualProcessIDForBrowserRequest,
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableBrowserSideNavigation));
+
if (provider_type_ == SERVICE_WORKER_PROVIDER_FOR_CONTROLLER) {
// Actual thread id is set when the service worker context gets started.
render_thread_id_ = kInvalidEmbeddedWorkerThreadId;
@@ -512,6 +535,8 @@ void ServiceWorkerProviderHost::CompleteCrossSiteTransfer(
int new_provider_id,
ServiceWorkerProviderType new_provider_type,
ServiceWorkerDispatcherHost* new_dispatcher_host) {
+ CHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableBrowserSideNavigation));
michaeln 2015/10/01 01:42:16 ah, i didn't notice the ! char! Ok, thanx for poi
Fabrice (no longer in Chrome) 2015/10/01 18:29:55 I think we should leave a CHECK here as stated abo
michaeln 2015/10/01 23:11:12 If this check is to defend against bad ipc inputs,
Fabrice (no longer in Chrome) 2015/10/02 16:37:34 Looking at the calling stack, this is actually tak
DCHECK_EQ(ChildProcessHost::kInvalidUniqueID, render_process_id_);
DCHECK_NE(ChildProcessHost::kInvalidUniqueID, new_process_id);
DCHECK_NE(MSG_ROUTING_NONE, new_frame_id);
@@ -541,6 +566,42 @@ void ServiceWorkerProviderHost::CompleteCrossSiteTransfer(
}
}
+// PlzNavigate
+void ServiceWorkerProviderHost::CompleteNavigationInitialized(
+ int process_id,
+ int frame_id,
+ ServiceWorkerDispatcherHost* dispatcher_host) {
+ CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
michaeln 2015/10/01 01:42:16 same question about CHECK vs DCHECK?
Fabrice (no longer in Chrome) 2015/10/01 18:29:55 If we get here, it means the browser received a ne
michaeln 2015/10/01 23:11:11 Please use BadMessageRecieved for that and put the
+ switches::kEnableBrowserSideNavigation));
+ DCHECK_EQ(kVirtualProcessIDForBrowserRequest, render_process_id_);
+ DCHECK_EQ(SERVICE_WORKER_PROVIDER_FOR_WINDOW, provider_type_);
+ DCHECK_EQ(kDocumentMainThreadId, render_thread_id_);
+
+ DCHECK_NE(ChildProcessHost::kInvalidUniqueID, process_id);
+ DCHECK_NE(MSG_ROUTING_NONE, frame_id);
+
+ render_process_id_ = process_id;
+ route_id_ = frame_id;
+ dispatcher_host_ = dispatcher_host;
+
+ for (const GURL& pattern : associated_patterns_)
michaeln 2015/10/01 01:42:16 CompleteCrossSiteTransfer and CompleteNavigationIn
Fabrice (no longer in Chrome) 2015/10/01 18:29:55 Done.
+ IncreaseProcessReference(pattern);
+
+ for (auto& key_registration : matching_registrations_)
+ IncreaseProcessReference(key_registration.second->pattern());
+
+ if (associated_registration_.get()) {
+ SendAssociateRegistrationMessage();
+ if (dispatcher_host_ && associated_registration_->active_version()) {
+ Send(new ServiceWorkerMsg_SetControllerServiceWorker(
+ render_thread_id_, provider_id(),
+ GetOrCreateServiceWorkerHandle(
+ associated_registration_->active_version()),
+ false /* shouldNotifyControllerChange */));
+ }
+ }
+}
+
void ServiceWorkerProviderHost::SendUpdateFoundMessage(
int registration_handle_id) {
if (!dispatcher_host_)

Powered by Google App Engine
This is Rietveld 408576698