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

Unified Diff: content/browser/frame_host/navigation_request.cc

Issue 1294243004: PlzNavigate: Make ServiceWorker work with PlzNavigate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 5 years, 2 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/frame_host/navigation_request.cc
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
index 2c784a3e43e081e332d114953b37c687ca6d2d3b..185f170abae8204e5922c55a281857166245236b 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -4,6 +4,7 @@
#include "content/browser/frame_host/navigation_request.h"
+#include "base/command_line.h"
#include "content/browser/frame_host/frame_tree.h"
#include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/navigation_controller_impl.h"
@@ -11,15 +12,18 @@
#include "content/browser/frame_host/navigation_request_info.h"
#include "content/browser/frame_host/navigator.h"
#include "content/browser/loader/navigation_url_loader.h"
+#include "content/browser/service_worker/service_worker_provider_host.h"
#include "content/browser/site_instance_impl.h"
#include "content/common/resource_request_body.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/browser/stream_handle.h"
#include "content/public/common/content_client.h"
+#include "content/public/common/content_switches.h"
#include "net/base/load_flags.h"
#include "net/http/http_request_headers.h"
#include "net/url_request/redirect_info.h"
+#include "third_party/WebKit/public/web/WebSandboxFlags.h"
namespace content {
@@ -50,6 +54,21 @@ int LoadFlagFromNavigationType(FrameMsg_Navigate_Type::Value navigation_type) {
return load_flags;
}
+// Next ServiceWorkerProviderHost ID for navigations, starts at -2 and keeps
+// going down.
+int g_next_navigation_provider_id = -2;
+
+// Returns the next ServiceWorkerProviderHost ID for navigations.
+// Returns kInvalidServiceWorkerProviderId if sandbox_flags indicates a
nasko 2015/10/02 22:09:45 nit: Reflow this comment as a single sentence: Ret
Fabrice (no longer in Chrome) 2015/10/06 17:21:37 Done.
+// sandboxed frame.
+int GetNextNavigationProviderId(blink::WebSandboxFlags sandbox_flags) {
+ bool sandboxed_frame = (sandbox_flags & blink::WebSandboxFlags::Origin) ==
+ blink::WebSandboxFlags::Origin;
+ if (sandboxed_frame)
nasko 2015/10/02 22:09:45 Why use a full boolean variable instead of checkin
Fabrice (no longer in Chrome) 2015/10/06 17:21:37 Thought it was a bit clearer but I changed it.
+ return kInvalidServiceWorkerProviderId;
+ return g_next_navigation_provider_id--;
+}
+
} // namespace
// static
@@ -89,7 +108,10 @@ scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
entry.ConstructCommonNavigationParams(dest_url, dest_referrer,
frame_entry, navigation_type),
BeginNavigationParams(method, headers.ToString(),
- LoadFlagFromNavigationType(navigation_type), false),
+ LoadFlagFromNavigationType(navigation_type),
+ false, // has_user_gestures
+ false, // skip_service_worker
+ REQUEST_CONTEXT_TYPE_HYPERLINK),
entry.ConstructRequestNavigationParams(
frame_entry, navigation_start, is_same_document_history_load,
frame_tree_node->has_committed_real_load(),
@@ -116,9 +138,21 @@ scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated(
// renderer and sent to the browser instead of being measured here.
// TODO(clamy): The pending history list offset should be properly set.
// TODO(clamy): Set has_committed_real_load.
- RequestNavigationParams request_params;
- request_params.current_history_list_offset = current_history_list_offset;
- request_params.current_history_list_length = current_history_list_length;
+ RequestNavigationParams request_params(
+ false, // is_overriding_user_agent
+ base::TimeTicks::Now(), // browser_navigation_start
+ std::vector<GURL>(), // redirects
+ false, // can_load_local_resources
+ base::Time::Now(), // request_time
+ PageState(), // page_state
+ -1, // page_id
+ 0, // nav_entry_id
+ false, // is_same_document_history_load
+ false, // has_committed_real_load
+ false, // intended_as_new_entry
+ -1, // pending_history_list_offset
+ current_history_list_offset, current_history_list_length,
+ false); // should_clear_history_list
nasko 2015/10/02 22:09:45 nit: align this comment vertically with the rest a
Fabrice (no longer in Chrome) 2015/10/06 17:21:38 Done in the other patch.
scoped_ptr<NavigationRequest> navigation_request(
new NavigationRequest(frame_tree_node, common_params, begin_params,
request_params, body, false, nullptr, nullptr));
@@ -194,6 +228,16 @@ bool NavigationRequest::BeginNavigation() {
return false;
}
+ // Initialize the service_worker_provider_id here.
+ blink::WebSandboxFlags sandbox_flags =
+ frame_tree_node_->current_replication_state().sandbox_flags;
+ int service_worker_provider_id = GetNextNavigationProviderId(sandbox_flags);
+
+ info_->service_worker_provider_id = service_worker_provider_id;
+ request_params_.service_worker_provider_id = service_worker_provider_id;
+ navigation_handle_->set_service_worker_provider_id(
+ service_worker_provider_id);
+
loader_ = NavigationURLLoader::Create(
frame_tree_node_->navigator()->GetController()->GetBrowserContext(),
info_.Pass(), this);
@@ -211,9 +255,9 @@ bool NavigationRequest::BeginNavigation() {
// DidStartProvisionalLoadForFrame for the navigation.
}
-void NavigationRequest::CreateNavigationHandle(NavigatorDelegate* delegate) {
+void NavigationRequest::CreateNavigationHandle() {
navigation_handle_ = NavigationHandleImpl::Create(
- common_params_.url, frame_tree_node_->IsMainFrame(), delegate);
+ common_params_.url, frame_tree_node_->IsMainFrame(), frame_tree_node_);
}
void NavigationRequest::TransferNavigationHandleOwnership(

Powered by Google App Engine
This is Rietveld 408576698