| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ | 5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ |
| 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ | 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 // Helper function to determine if the navigation request to |url| should be | 55 // Helper function to determine if the navigation request to |url| should be |
| 56 // sent to the network stack. | 56 // sent to the network stack. |
| 57 static bool ShouldMakeNetworkRequest(const GURL& url); | 57 static bool ShouldMakeNetworkRequest(const GURL& url); |
| 58 | 58 |
| 59 // Creates a request for a browser-intiated navigation. | 59 // Creates a request for a browser-intiated navigation. |
| 60 static scoped_ptr<NavigationRequest> CreateBrowserInitiated( | 60 static scoped_ptr<NavigationRequest> CreateBrowserInitiated( |
| 61 FrameTreeNode* frame_tree_node, | 61 FrameTreeNode* frame_tree_node, |
| 62 const NavigationEntryImpl& entry, | 62 const NavigationEntryImpl& entry, |
| 63 FrameMsg_Navigate_Type::Value navigation_type, | 63 FrameMsg_Navigate_Type::Value navigation_type, |
| 64 base::TimeTicks navigation_start); | 64 base::TimeTicks navigation_start, |
| 65 const HistoryNavigationParams& history_params); |
| 65 | 66 |
| 66 // Creates a request for a renderer-intiated navigation. | 67 // Creates a request for a renderer-intiated navigation. |
| 67 // Note: |body| is sent to the IO thread when calling BeginNavigation, and | 68 // Note: |body| is sent to the IO thread when calling BeginNavigation, and |
| 68 // should no longer be manipulated afterwards on the UI thread. | 69 // should no longer be manipulated afterwards on the UI thread. |
| 69 static scoped_ptr<NavigationRequest> CreateRendererInitiated( | 70 static scoped_ptr<NavigationRequest> CreateRendererInitiated( |
| 70 FrameTreeNode* frame_tree_node, | 71 FrameTreeNode* frame_tree_node, |
| 71 const CommonNavigationParams& common_params, | 72 const CommonNavigationParams& common_params, |
| 72 const BeginNavigationParams& begin_params, | 73 const BeginNavigationParams& begin_params, |
| 73 scoped_refptr<ResourceRequestBody> body); | 74 scoped_refptr<ResourceRequestBody> body, |
| 75 int current_history_list_offset, |
| 76 int current_history_list_length); |
| 74 | 77 |
| 75 ~NavigationRequest() override; | 78 ~NavigationRequest() override; |
| 76 | 79 |
| 77 // Called on the UI thread by the Navigator to start the navigation. Returns | 80 // Called on the UI thread by the Navigator to start the navigation. Returns |
| 78 // whether a request was made on the IO thread. | 81 // whether a request was made on the IO thread. |
| 79 // TODO(clamy): see if ResourceRequestBody could be un-refcounted to avoid | 82 // TODO(clamy): see if ResourceRequestBody could be un-refcounted to avoid |
| 80 // threading subtleties. | 83 // threading subtleties. |
| 81 bool BeginNavigation(); | 84 bool BeginNavigation(); |
| 82 | 85 |
| 83 const CommonNavigationParams& common_params() const { return common_params_; } | 86 const CommonNavigationParams& common_params() const { return common_params_; } |
| 84 | 87 |
| 85 const BeginNavigationParams& begin_params() const { return begin_params_; } | 88 const BeginNavigationParams& begin_params() const { return begin_params_; } |
| 86 | 89 |
| 87 const CommitNavigationParams& commit_params() const { return commit_params_; } | 90 const CommitNavigationParams& commit_params() const { return commit_params_; } |
| 88 | 91 |
| 92 const HistoryNavigationParams& history_params() const { |
| 93 return history_params_; |
| 94 } |
| 95 |
| 89 NavigationURLLoader* loader_for_testing() const { return loader_.get(); } | 96 NavigationURLLoader* loader_for_testing() const { return loader_.get(); } |
| 90 | 97 |
| 91 NavigationState state() const { return state_; } | 98 NavigationState state() const { return state_; } |
| 92 | 99 |
| 93 SiteInstanceImpl* source_site_instance() const { | 100 SiteInstanceImpl* source_site_instance() const { |
| 94 return source_site_instance_.get(); | 101 return source_site_instance_.get(); |
| 95 } | 102 } |
| 96 | 103 |
| 97 SiteInstanceImpl* dest_site_instance() const { | 104 SiteInstanceImpl* dest_site_instance() const { |
| 98 return dest_site_instance_.get(); | 105 return dest_site_instance_.get(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 111 void SetWaitingForRendererResponse() { | 118 void SetWaitingForRendererResponse() { |
| 112 DCHECK(state_ == NOT_STARTED); | 119 DCHECK(state_ == NOT_STARTED); |
| 113 state_ = WAITING_FOR_RENDERER_RESPONSE; | 120 state_ = WAITING_FOR_RENDERER_RESPONSE; |
| 114 } | 121 } |
| 115 | 122 |
| 116 private: | 123 private: |
| 117 NavigationRequest(FrameTreeNode* frame_tree_node, | 124 NavigationRequest(FrameTreeNode* frame_tree_node, |
| 118 const CommonNavigationParams& common_params, | 125 const CommonNavigationParams& common_params, |
| 119 const BeginNavigationParams& begin_params, | 126 const BeginNavigationParams& begin_params, |
| 120 const CommitNavigationParams& commit_params, | 127 const CommitNavigationParams& commit_params, |
| 128 const HistoryNavigationParams& history_params, |
| 121 scoped_refptr<ResourceRequestBody> body, | 129 scoped_refptr<ResourceRequestBody> body, |
| 122 bool browser_initiated, | 130 bool browser_initiated, |
| 123 const NavigationEntryImpl* navitation_entry); | 131 const NavigationEntryImpl* navitation_entry); |
| 124 | 132 |
| 125 // NavigationURLLoaderDelegate implementation. | 133 // NavigationURLLoaderDelegate implementation. |
| 126 void OnRequestRedirected( | 134 void OnRequestRedirected( |
| 127 const net::RedirectInfo& redirect_info, | 135 const net::RedirectInfo& redirect_info, |
| 128 const scoped_refptr<ResourceResponse>& response) override; | 136 const scoped_refptr<ResourceResponse>& response) override; |
| 129 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, | 137 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, |
| 130 scoped_ptr<StreamHandle> body) override; | 138 scoped_ptr<StreamHandle> body) override; |
| 131 void OnRequestFailed(int net_error) override; | 139 void OnRequestFailed(int net_error) override; |
| 132 void OnRequestStarted(base::TimeTicks timestamp) override; | 140 void OnRequestStarted(base::TimeTicks timestamp) override; |
| 133 | 141 |
| 134 FrameTreeNode* frame_tree_node_; | 142 FrameTreeNode* frame_tree_node_; |
| 135 | 143 |
| 136 // Initialized on creation of the NavigationRequest. Sent to the renderer when | 144 // Initialized on creation of the NavigationRequest. Sent to the renderer when |
| 137 // the navigation is ready to commit. | 145 // the navigation is ready to commit. |
| 138 // Note: When the navigation is ready to commit, the url in |common_params| | 146 // Note: When the navigation is ready to commit, the url in |common_params| |
| 139 // will be set to the final navigation url, obtained after following all | 147 // will be set to the final navigation url, obtained after following all |
| 140 // redirects. | 148 // redirects. |
| 141 CommonNavigationParams common_params_; | 149 CommonNavigationParams common_params_; |
| 142 const BeginNavigationParams begin_params_; | 150 const BeginNavigationParams begin_params_; |
| 143 const CommitNavigationParams commit_params_; | 151 const CommitNavigationParams commit_params_; |
| 152 const HistoryNavigationParams history_params_; |
| 144 const bool browser_initiated_; | 153 const bool browser_initiated_; |
| 145 | 154 |
| 146 NavigationState state_; | 155 NavigationState state_; |
| 147 | 156 |
| 148 | 157 |
| 149 // The parameters to send to the IO thread. |loader_| takes ownership of | 158 // The parameters to send to the IO thread. |loader_| takes ownership of |
| 150 // |info_| after calling BeginNavigation. | 159 // |info_| after calling BeginNavigation. |
| 151 scoped_ptr<NavigationRequestInfo> info_; | 160 scoped_ptr<NavigationRequestInfo> info_; |
| 152 | 161 |
| 153 scoped_ptr<NavigationURLLoader> loader_; | 162 scoped_ptr<NavigationURLLoader> loader_; |
| 154 | 163 |
| 155 // These next items are used in browser-initiated navigations to store | 164 // These next items are used in browser-initiated navigations to store |
| 156 // information from the NavigationEntryImpl that is required after request | 165 // information from the NavigationEntryImpl that is required after request |
| 157 // creation time. | 166 // creation time. |
| 158 scoped_refptr<SiteInstanceImpl> source_site_instance_; | 167 scoped_refptr<SiteInstanceImpl> source_site_instance_; |
| 159 scoped_refptr<SiteInstanceImpl> dest_site_instance_; | 168 scoped_refptr<SiteInstanceImpl> dest_site_instance_; |
| 160 NavigationEntryImpl::RestoreType restore_type_; | 169 NavigationEntryImpl::RestoreType restore_type_; |
| 161 bool is_view_source_; | 170 bool is_view_source_; |
| 162 int bindings_; | 171 int bindings_; |
| 163 | 172 |
| 164 DISALLOW_COPY_AND_ASSIGN(NavigationRequest); | 173 DISALLOW_COPY_AND_ASSIGN(NavigationRequest); |
| 165 }; | 174 }; |
| 166 | 175 |
| 167 } // namespace content | 176 } // namespace content |
| 168 | 177 |
| 169 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ | 178 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ |
| OLD | NEW |