#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
-#include "content/browser/frame_host/navigation_request_info.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/browser/loader/navigation_url_loader_delegate.h"
#include "content/common/content_export.h"
+#include "content/common/navigation_params.h"
namespace content {
+
+class FrameTreeNode;
+class NavigationURLLoader;
class ResourceRequestBody;
+struct NavigationRequestInfo;
// PlzNavigate
// A UI thread object that owns a navigation request until it commits. It
// ResourceDispatcherHost (that lives on the IO thread).
// TODO(clamy): Describe the interactions between the UI and IO thread during
// the navigation following its refactoring.
-class NavigationRequest {
+class CONTENT_EXPORT NavigationRequest : public NavigationURLLoaderDelegate {
public:
- NavigationRequest(const NavigationRequestInfo& info,
- int64 frame_tree_node_id);
-
- ~NavigationRequest();
+ NavigationRequest(FrameTreeNode* frame_tree_node,
+ const CommonNavigationParams& common_params,
+ const CommitNavigationParams& commit_params);
- // Called on the UI thread by the RenderFrameHostManager which owns the
- // NavigationRequest. After calling this function, |body| can no longer be
- // manipulated on the UI thread.
- void BeginNavigation(scoped_refptr<ResourceRequestBody> body);
+ ~NavigationRequest() override;
// Called on the UI thread by the RenderFrameHostManager which owns the
- // NavigationRequest whenever this navigation request should be canceled.
- void CancelNavigation();
+ // NavigationRequest. Takes ownership of |info|. After calling this function,
+ // |body| can no longer be manipulated on the UI thread.
+ void BeginNavigation(scoped_ptr<NavigationRequestInfo> info,
+ scoped_refptr<ResourceRequestBody> body);
- const NavigationRequestInfo& info() const { return info_; }
+ CommonNavigationParams& common_params() { return common_params_; }
- int64 frame_tree_node_id() const { return frame_tree_node_id_; }
+ const CommitNavigationParams& commit_params() const { return commit_params_; }
- int64 navigation_request_id() const { return navigation_request_id_; }
+ NavigationURLLoader* loader_for_testing() const { return loader_.get(); }
private:
- const int64 navigation_request_id_;
- const NavigationRequestInfo info_;
- const int64 frame_tree_node_id_;
+ // NavigationURLLoaderDelegate implementation.
+ void OnRequestRedirected(
+ const net::RedirectInfo& redirect_info,
+ const scoped_refptr<ResourceResponse>& response) override;
+ void OnResponseStarted(const scoped_refptr<ResourceResponse>& response,
+ scoped_ptr<StreamHandle> body) override;
+ void OnRequestFailed(int net_error) override;
+
+ FrameTreeNode* frame_tree_node_;
+
+ // Initialized on creation of the NavigationRequest. Sent to the renderer when
+ // the navigation is ready to commit.
+ // Note: When the navigation is ready to commit, the url in |common_params|
+ // will be set to the final navigation url, obtained after following all
+ // redirects.
+ CommonNavigationParams common_params_;
+ const CommitNavigationParams commit_params_;
+
+ scoped_ptr<NavigationURLLoader> loader_;
DISALLOW_COPY_AND_ASSIGN(NavigationRequest);
};