| 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 4e33ea547767c76736e051700b3c2269b7a81f7e..f1e1809831d7f2485051ea7b264066908c6e4a3a 100644
|
| --- a/content/browser/frame_host/navigation_request.cc
|
| +++ b/content/browser/frame_host/navigation_request.cc
|
| @@ -5,47 +5,22 @@
|
| #include "content/browser/frame_host/navigation_request.h"
|
|
|
| #include "base/logging.h"
|
| +#include "content/browser/frame_host/frame_tree_node.h"
|
| #include "content/browser/frame_host/navigation_request_info.h"
|
| -#include "content/browser/loader/resource_dispatcher_host_impl.h"
|
| +#include "content/browser/frame_host/navigator.h"
|
| #include "content/common/resource_request_body.h"
|
| -#include "content/public/browser/browser_thread.h"
|
| +#include "content/public/browser/stream_handle.h"
|
| +#include "net/url_request/redirect_info.h"
|
|
|
| namespace content {
|
|
|
| -namespace {
|
| -
|
| -// The next available browser-global navigation request ID.
|
| -static int64 next_navigation_request_id_ = 0;
|
| -
|
| -void OnBeginNavigation(const CommonNavigationParams& common_params,
|
| - const NavigationRequestInfo& info,
|
| - scoped_refptr<ResourceRequestBody> request_body,
|
| - int64 navigation_request_id,
|
| - int64 frame_tree_node_id) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - ResourceDispatcherHostImpl::Get()->StartNavigationRequest(
|
| - common_params,
|
| - info,
|
| - request_body,
|
| - navigation_request_id,
|
| - frame_tree_node_id);
|
| -}
|
| -
|
| -void CancelNavigationRequest(int64 navigation_request_id,
|
| - int64 frame_tree_node_id) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - ResourceDispatcherHostImpl::Get()->CancelNavigationRequest(
|
| - navigation_request_id, frame_tree_node_id);
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| NavigationRequest::NavigationRequest(
|
| - int64 frame_tree_node_id,
|
| + BrowserContext* browser_context,
|
| + FrameTreeNode* frame_tree_node,
|
| const CommonNavigationParams& common_params,
|
| const CommitNavigationParams& commit_params)
|
| - : navigation_request_id_(++next_navigation_request_id_),
|
| - frame_tree_node_id_(frame_tree_node_id),
|
| + : browser_context_(browser_context),
|
| + frame_tree_node_(frame_tree_node),
|
| common_params_(common_params),
|
| commit_params_(commit_params) {
|
| }
|
| @@ -56,26 +31,31 @@ NavigationRequest::~NavigationRequest() {
|
| void NavigationRequest::BeginNavigation(
|
| scoped_ptr<NavigationRequestInfo> info,
|
| scoped_refptr<ResourceRequestBody> request_body) {
|
| - info_ = info.Pass();
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - BrowserThread::PostTask(
|
| - BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(&OnBeginNavigation,
|
| - common_params_,
|
| - *info_,
|
| - request_body,
|
| - navigation_request_id_,
|
| - frame_tree_node_id_));
|
| + DCHECK(!loader_);
|
| + loader_ = NavigationURLLoader::Create(
|
| + browser_context_, frame_tree_node_->frame_tree_node_id(),
|
| + common_params_, info.Pass(), request_body.get(), this);
|
| +}
|
| +
|
| +void NavigationRequest::OnRequestRedirected(
|
| + const net::RedirectInfo& redirect_info,
|
| + ResourceResponse* response) {
|
| + common_params_.url = redirect_info.new_url;
|
| +
|
| + // TODO(davidben): This where prerender and navigation_interceptor should be
|
| + // integrated. For now, just always follow all redirects.
|
| + loader_->FollowRedirect();
|
| +}
|
| +
|
| +void NavigationRequest::OnResponseStarted(ResourceResponse* response,
|
| + scoped_ptr<StreamHandle> body) {
|
| + frame_tree_node_->navigator()->CommitNavigation(frame_tree_node_,
|
| + response, body.Pass());
|
| }
|
|
|
| -void NavigationRequest::CancelNavigation() {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - BrowserThread::PostTask(
|
| - BrowserThread::IO,
|
| - FROM_HERE,
|
| - base::Bind(&CancelNavigationRequest,
|
| - navigation_request_id_, frame_tree_node_id_));
|
| +void NavigationRequest::OnRequestFailed(int net_error) {
|
| + // TODO(davidben): Network failures should display a network error page.
|
| + NOTIMPLEMENTED();
|
| }
|
|
|
| } // namespace content
|
|
|