| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 // The response started on the IO thread and is ready to be committed. This | 46 // The response started on the IO thread and is ready to be committed. This |
| 47 // is one of the two final states for the request. | 47 // is one of the two final states for the request. |
| 48 RESPONSE_STARTED, | 48 RESPONSE_STARTED, |
| 49 | 49 |
| 50 // The request failed on the IO thread and an error page should be | 50 // The request failed on the IO thread and an error page should be |
| 51 // displayed. This is one of the two final states for the request. | 51 // displayed. This is one of the two final states for the request. |
| 52 FAILED, | 52 FAILED, |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 static scoped_ptr<NavigationRequest> Create( | 55 // Creates a request for a browser-intiated navigation. |
| 56 FrameTreeNode* frame_tree_node, | 56 static scoped_ptr<NavigationRequest> CreateBrowserInitiated( |
| 57 const NavigationEntryImpl& entry, | 57 FrameTreeNode* frame_tree_node, |
| 58 FrameMsg_Navigate_Type::Value navigation_type, | 58 const NavigationEntryImpl& entry, |
| 59 base::TimeTicks navigation_start); | 59 FrameMsg_Navigate_Type::Value navigation_type, |
| 60 base::TimeTicks navigation_start); |
| 60 | 61 |
| 61 NavigationRequest(FrameTreeNode* frame_tree_node, | 62 // Creates a request for a renderer-intiated navigation. |
| 62 const CommonNavigationParams& common_params, | 63 // Note: |body| is sent to the IO thread when calling BeginNavigation, and |
| 63 const CommitNavigationParams& commit_params, | 64 // should no longer be manipulated afterwards on the UI thread. |
| 64 const NavigationEntryImpl* navitation_entry); | 65 static scoped_ptr<NavigationRequest> CreateRendererInitiated( |
| 66 FrameTreeNode* frame_tree_node, |
| 67 const CommonNavigationParams& common_params, |
| 68 const BeginNavigationParams& begin_params, |
| 69 scoped_refptr<ResourceRequestBody> body); |
| 65 | 70 |
| 66 ~NavigationRequest() override; | 71 ~NavigationRequest() override; |
| 67 | 72 |
| 68 // Called on the UI thread by the RenderFrameHostManager which owns the | 73 // Called on the UI thread by the Navigator to start the navigation on the IO |
| 69 // NavigationRequest. Takes ownership of |info|. After calling this function, | 74 // thread. |
| 70 // |body| can no longer be manipulated on the UI thread. | 75 // TODO(clamy): see if ResourceRequestBody could be un-refcounted to avoid |
| 71 void BeginNavigation(scoped_ptr<NavigationRequestInfo> info, | 76 // threading subtleties. |
| 72 scoped_refptr<ResourceRequestBody> body); | 77 void BeginNavigation(); |
| 73 | |
| 74 CommonNavigationParams& common_params() { return common_params_; } | |
| 75 | 78 |
| 76 const CommonNavigationParams& common_params() const { return common_params_; } | 79 const CommonNavigationParams& common_params() const { return common_params_; } |
| 77 | 80 |
| 78 const CommitNavigationParams& commit_params() const { return commit_params_; } | 81 const CommitNavigationParams& commit_params() const { return commit_params_; } |
| 79 | 82 |
| 80 NavigationURLLoader* loader_for_testing() const { return loader_.get(); } | 83 NavigationURLLoader* loader_for_testing() const { return loader_.get(); } |
| 81 | 84 |
| 82 NavigationState state() const { return state_; } | 85 NavigationState state() const { return state_; } |
| 83 | 86 |
| 84 SiteInstanceImpl* source_site_instance() const { | 87 SiteInstanceImpl* source_site_instance() const { |
| 85 return source_site_instance_.get(); | 88 return source_site_instance_.get(); |
| 86 } | 89 } |
| 87 | 90 |
| 88 SiteInstanceImpl* dest_site_instance() const { | 91 SiteInstanceImpl* dest_site_instance() const { |
| 89 return dest_site_instance_.get(); | 92 return dest_site_instance_.get(); |
| 90 } | 93 } |
| 91 | 94 |
| 92 NavigationEntryImpl::RestoreType restore_type() const { | 95 NavigationEntryImpl::RestoreType restore_type() const { |
| 93 return restore_type_; | 96 return restore_type_; |
| 94 }; | 97 }; |
| 95 | 98 |
| 96 bool is_view_source() const { return is_view_source_; }; | 99 bool is_view_source() const { return is_view_source_; }; |
| 97 | 100 |
| 98 int bindings() const { return bindings_; }; | 101 int bindings() const { return bindings_; }; |
| 99 | 102 |
| 103 bool browser_initiated() const { return browser_initiated_ ; } |
| 104 |
| 100 void SetWaitingForRendererResponse() { | 105 void SetWaitingForRendererResponse() { |
| 101 DCHECK(state_ == NOT_STARTED); | 106 DCHECK(state_ == NOT_STARTED); |
| 102 state_ = WAITING_FOR_RENDERER_RESPONSE; | 107 state_ = WAITING_FOR_RENDERER_RESPONSE; |
| 103 } | 108 } |
| 104 | 109 |
| 105 private: | 110 private: |
| 111 NavigationRequest(FrameTreeNode* frame_tree_node, |
| 112 const CommonNavigationParams& common_params, |
| 113 const BeginNavigationParams& begin_params, |
| 114 const CommitNavigationParams& commit_params, |
| 115 scoped_refptr<ResourceRequestBody> body, |
| 116 bool browser_initiated, |
| 117 const NavigationEntryImpl* navitation_entry); |
| 118 |
| 106 // NavigationURLLoaderDelegate implementation. | 119 // NavigationURLLoaderDelegate implementation. |
| 107 void OnRequestRedirected( | 120 void OnRequestRedirected( |
| 108 const net::RedirectInfo& redirect_info, | 121 const net::RedirectInfo& redirect_info, |
| 109 const scoped_refptr<ResourceResponse>& response) override; | 122 const scoped_refptr<ResourceResponse>& response) override; |
| 110 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, | 123 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, |
| 111 scoped_ptr<StreamHandle> body) override; | 124 scoped_ptr<StreamHandle> body) override; |
| 112 void OnRequestFailed(int net_error) override; | 125 void OnRequestFailed(int net_error) override; |
| 113 void OnRequestStarted(base::TimeTicks timestamp) override; | 126 void OnRequestStarted(base::TimeTicks timestamp) override; |
| 114 | 127 |
| 115 FrameTreeNode* frame_tree_node_; | 128 FrameTreeNode* frame_tree_node_; |
| 116 | 129 |
| 117 // Initialized on creation of the NavigationRequest. Sent to the renderer when | 130 // Initialized on creation of the NavigationRequest. Sent to the renderer when |
| 118 // the navigation is ready to commit. | 131 // the navigation is ready to commit. |
| 119 // Note: When the navigation is ready to commit, the url in |common_params| | 132 // Note: When the navigation is ready to commit, the url in |common_params| |
| 120 // will be set to the final navigation url, obtained after following all | 133 // will be set to the final navigation url, obtained after following all |
| 121 // redirects. | 134 // redirects. |
| 122 CommonNavigationParams common_params_; | 135 CommonNavigationParams common_params_; |
| 136 const BeginNavigationParams begin_params_; |
| 123 const CommitNavigationParams commit_params_; | 137 const CommitNavigationParams commit_params_; |
| 138 const bool browser_initiated_; |
| 124 | 139 |
| 125 NavigationState state_; | 140 NavigationState state_; |
| 126 | 141 |
| 142 |
| 143 // The parameters to send to the IO thread. |loader_| takes ownership of |
| 144 // |info_| after calling BeginNavigation. |
| 145 scoped_ptr<NavigationRequestInfo> info_; |
| 146 |
| 127 scoped_ptr<NavigationURLLoader> loader_; | 147 scoped_ptr<NavigationURLLoader> loader_; |
| 128 | 148 |
| 129 // These next items are used in browser-initiated navigations to store | 149 // These next items are used in browser-initiated navigations to store |
| 130 // information from the NavigationEntryImpl that is required after request | 150 // information from the NavigationEntryImpl that is required after request |
| 131 // creation time. | 151 // creation time. |
| 132 scoped_refptr<SiteInstanceImpl> source_site_instance_; | 152 scoped_refptr<SiteInstanceImpl> source_site_instance_; |
| 133 scoped_refptr<SiteInstanceImpl> dest_site_instance_; | 153 scoped_refptr<SiteInstanceImpl> dest_site_instance_; |
| 134 NavigationEntryImpl::RestoreType restore_type_; | 154 NavigationEntryImpl::RestoreType restore_type_; |
| 135 bool is_view_source_; | 155 bool is_view_source_; |
| 136 int bindings_; | 156 int bindings_; |
| 137 | 157 |
| 138 DISALLOW_COPY_AND_ASSIGN(NavigationRequest); | 158 DISALLOW_COPY_AND_ASSIGN(NavigationRequest); |
| 139 }; | 159 }; |
| 140 | 160 |
| 141 } // namespace content | 161 } // namespace content |
| 142 | 162 |
| 143 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ | 163 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ |
| OLD | NEW |