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 e0c1215bbe6bbcf38e39c25301bece63901d8876..fcb1665ca3b0afe4d711d74467cb120b4d24073e 100644 |
--- a/content/browser/frame_host/navigation_request.cc |
+++ b/content/browser/frame_host/navigation_request.cc |
@@ -5,65 +5,53 @@ |
#include "content/browser/frame_host/navigation_request.h" |
#include "base/logging.h" |
-#include "content/browser/loader/resource_dispatcher_host_impl.h" |
-#include "content/common/resource_request_body.h" |
-#include "content/public/browser/browser_thread.h" |
+#include "content/browser/frame_host/frame_tree_node.h" |
+#include "content/browser/frame_host/render_frame_host_manager.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 NavigationRequestInfo& info, |
- scoped_refptr<ResourceRequestBody> request_body, |
- int64 navigation_request_id, |
- int64 frame_tree_node_id) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
- ResourceDispatcherHostImpl::Get()->StartNavigationRequest( |
- info, request_body, navigation_request_id, frame_tree_node_id); |
+NavigationRequest::NavigationRequest(const NavigationRequestInfo& info, |
+ BrowserContext* browser_context, |
+ FrameTreeNode* frame_tree_node) |
+ : info_(info), |
+ browser_context_(browser_context), |
+ frame_tree_node_(frame_tree_node) { |
} |
-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); |
+NavigationRequest::~NavigationRequest() { |
} |
-} // namespace |
+void NavigationRequest::BeginNavigation( |
+ scoped_refptr<ResourceRequestBody> request_body) { |
+ DCHECK(!loader_); |
-NavigationRequest::NavigationRequest(const NavigationRequestInfo& info, |
- int64 frame_tree_node_id) |
- : navigation_request_id_(++next_navigation_request_id_), |
- info_(info), |
- frame_tree_node_id_(frame_tree_node_id) { |
+ final_url_ = info_.navigation_params.url; |
+ loader_.reset(NavigationURLLoader::Create( |
+ browser_context_, frame_tree_node_->frame_tree_node_id(), |
+ info_, request_body.get(), this)); |
} |
-NavigationRequest::~NavigationRequest() { |
+void NavigationRequest::OnRequestRedirected( |
+ const net::RedirectInfo& redirect_info, |
+ ResourceResponse* response) { |
+ final_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::BeginNavigation( |
- scoped_refptr<ResourceRequestBody> request_body) { |
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
- BrowserThread::PostTask( |
- BrowserThread::IO, |
- FROM_HERE, |
- base::Bind(&OnBeginNavigation, |
- info_, |
- request_body, |
- navigation_request_id_, |
- frame_tree_node_id_)); |
+void NavigationRequest::OnResponseStarted(ResourceResponse* response, |
+ scoped_ptr<StreamHandle> body) { |
+ frame_tree_node_->render_manager()->CommitNavigation( |
+ final_url_, 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 |