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..8216739329c3184408c4f4ea0bee622fd775cb0a 100644 |
--- a/content/browser/service_worker/service_worker_provider_host.cc |
+++ b/content/browser/service_worker/service_worker_provider_host.cc |
@@ -4,6 +4,8 @@ |
#include "content/browser/service_worker/service_worker_provider_host.h" |
+#include "base/atomic_sequence_num.h" |
+#include "base/command_line.h" |
#include "base/guid.h" |
#include "base/stl_util.h" |
#include "base/time/time.h" |
@@ -27,6 +29,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 +62,15 @@ ServiceWorkerClientInfo FocusOnUIThread(int render_process_id, |
} // anonymous namespace |
+// PlzNavigate |
+int ServiceWorkerProviderHost::kVirtualProcessIDForBrowserRequest = -2; |
+ |
+// PlzNavigate |
+int ServiceWorkerProviderHost::GetNextBrowserProviderID() { |
+ static base::StaticAtomicSequenceNumber sequence; |
michaeln
2015/09/16 00:56:42
Use of a thread safe construct here can be mislead
Fabrice (no longer in Chrome)
2015/09/30 17:32:07
Done.
|
+ return -2 - sequence.GetNext(); // Start at -2 |
+} |
+ |
ServiceWorkerProviderHost::OneShotGetReadyCallback::OneShotGetReadyCallback( |
const GetRegistrationForReadyCallback& callback) |
: callback(callback), |
@@ -87,6 +99,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; |
@@ -339,20 +357,26 @@ ServiceWorkerProviderHost::CreateRequestHandler( |
RequestContextFrameType frame_type, |
base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
scoped_refptr<ResourceRequestBody> body) { |
+ scoped_ptr<ServiceWorkerRequestHandler> handler; |
if (IsHostToRunningServiceWorker()) { |
- return scoped_ptr<ServiceWorkerRequestHandler>( |
+ handler = scoped_ptr<ServiceWorkerRequestHandler>( |
new ServiceWorkerContextRequestHandler( |
context_, AsWeakPtr(), blob_storage_context, resource_type)); |
} |
if (ServiceWorkerUtils::IsMainResourceType(resource_type) || |
controlling_version()) { |
- return scoped_ptr<ServiceWorkerRequestHandler>( |
+ handler = scoped_ptr<ServiceWorkerRequestHandler>( |
new ServiceWorkerControlleeRequestHandler( |
context_, AsWeakPtr(), blob_storage_context, request_mode, |
credentials_mode, redirect_mode, resource_type, |
request_context_type, frame_type, body)); |
} |
- return scoped_ptr<ServiceWorkerRequestHandler>(); |
+ if (handler && render_process_id_ == kVirtualProcessIDForBrowserRequest) { |
+ // PlzNavigate |
+ handler->SetBrowserProviderHost( |
michaeln
2015/09/16 00:56:42
This is an odd hidden artifact? See comments about
Fabrice (no longer in Chrome)
2015/09/30 17:32:07
Done.
|
+ scoped_ptr<ServiceWorkerProviderHost>(this)); |
+ } |
+ return handler; |
} |
ServiceWorkerObjectInfo |
@@ -512,6 +536,8 @@ void ServiceWorkerProviderHost::CompleteCrossSiteTransfer( |
int new_provider_id, |
ServiceWorkerProviderType new_provider_type, |
ServiceWorkerDispatcherHost* new_dispatcher_host) { |
+ CHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableBrowserSideNavigation)); |
DCHECK_EQ(ChildProcessHost::kInvalidUniqueID, render_process_id_); |
DCHECK_NE(ChildProcessHost::kInvalidUniqueID, new_process_id); |
DCHECK_NE(MSG_ROUTING_NONE, new_frame_id); |
@@ -541,6 +567,22 @@ void ServiceWorkerProviderHost::CompleteCrossSiteTransfer( |
} |
} |
+// PlzNavigate |
+void ServiceWorkerProviderHost::CompleteBrowserInitialized(int process_id, |
+ int frame_id) { |
+ CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ 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; |
michaeln
2015/09/19 00:14:40
Oh, we also need to set dispatcher_host_ in here.
Fabrice (no longer in Chrome)
2015/09/30 17:32:07
Added everything that was missing.
|
+} |
+ |
void ServiceWorkerProviderHost::SendUpdateFoundMessage( |
int registration_handle_id) { |
if (!dispatcher_host_) |