summaryrefslogtreecommitdiffstats
path: root/content/child/web_url_loader_impl.cc
diff options
context:
space:
mode:
authorclamy <clamy@chromium.org>2014-10-07 14:57:25 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-07 21:57:40 +0000
commitda97e832e41826d3ce0e6bd5c495feb636345ece (patch)
treea5f5566982a24807e6ddd836870a342deae586f2 /content/child/web_url_loader_impl.cc
parent0653ece4f182ab947d6809c311dfd4e8febaee1f (diff)
downloadchromium_src-da97e832e41826d3ce0e6bd5c495feb636345ece.zip
chromium_src-da97e832e41826d3ce0e6bd5c495feb636345ece.tar.gz
chromium_src-da97e832e41826d3ce0e6bd5c495feb636345ece.tar.bz2
PlzNavigate: Implement CommitNavigation on the renderer side
This CL implements the handler of FrameMsg_CommitNavigation in the renderer. Upon receiving this message, the renderer will create a WebURLRequest, with extra parameters in RequestExtraData. Those parameters will be used to override the url of the request and the ResourceResponse in WebURLLoaderImpl. The WebURLRequest created in RenderFrameImpl is then loaded by blink. BUG=376091 Review URL: https://codereview.chromium.org/539113003 Cr-Commit-Position: refs/heads/master@{#298581}
Diffstat (limited to 'content/child/web_url_loader_impl.cc')
-rw-r--r--content/child/web_url_loader_impl.cc33
1 files changed, 32 insertions, 1 deletions
diff --git a/content/child/web_url_loader_impl.cc b/content/child/web_url_loader_impl.cc
index a5b08da..c7a5146 100644
--- a/content/child/web_url_loader_impl.cc
+++ b/content/child/web_url_loader_impl.cc
@@ -7,6 +7,7 @@
#include "content/child/web_url_loader_impl.h"
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
@@ -24,6 +25,7 @@
#include "content/common/resource_request_body.h"
#include "content/common/service_worker/service_worker_types.h"
#include "content/public/child/request_peer.h"
+#include "content/public/common/content_switches.h"
#include "net/base/data_url.h"
#include "net/base/filename_util.h"
#include "net/base/load_flags.h"
@@ -376,6 +378,7 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
scoped_ptr<FtpDirectoryListingResponseDelegate> ftp_listing_delegate_;
scoped_ptr<MultipartResponseDelegate> multipart_delegate_;
scoped_ptr<ResourceLoaderBridge> completed_bridge_;
+ scoped_ptr<StreamOverrideParameters> stream_override_;
};
WebURLLoaderImpl::Context::Context(WebURLLoaderImpl* loader,
@@ -430,8 +433,26 @@ void WebURLLoaderImpl::Context::Start(const WebURLRequest& request,
DCHECK(!bridge_.get());
request_ = request; // Save the request.
+ if (request.extraData()) {
+ RequestExtraData* extra_data =
+ static_cast<RequestExtraData*>(request.extraData());
+ stream_override_ = extra_data->TakeStreamOverrideOwnership();
+ }
GURL url = request.url();
+
+ // PlzNavigate: during navigation, the renderer should request a stream which
+ // contains the body of the response. The request has already been made by the
+ // browser.
+ if (stream_override_.get()) {
+ CHECK(CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableBrowserSideNavigation));
+ DCHECK(!sync_load_response);
+ DCHECK_NE(WebURLRequest::FrameTypeNone, request.frameType());
+ DCHECK_EQ("GET", request.httpMethod().latin1());
+ url = stream_override_->stream_url;
+ }
+
if (CanHandleDataURLRequestLocally()) {
if (sync_load_response) {
// This is a sync load. Do the work now.
@@ -645,10 +666,20 @@ bool WebURLLoaderImpl::Context::OnReceivedRedirect(
}
void WebURLLoaderImpl::Context::OnReceivedResponse(
- const ResourceResponseInfo& info) {
+ const ResourceResponseInfo& initial_info) {
if (!client_)
return;
+ ResourceResponseInfo info = initial_info;
+
+ // PlzNavigate: during navigations, the ResourceResponse has already been
+ // received on the browser side, and has been passed down to the renderer.
+ if (stream_override_.get()) {
+ CHECK(CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableBrowserSideNavigation));
+ info = stream_override_->response;
+ }
+
WebURLResponse response;
response.initialize();
// Updates the request url if the response was fetched by a ServiceWorker,