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" |
| 11 #include "content/browser/loader/navigation_url_loader_delegate.h" |
11 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
12 #include "content/common/navigation_params.h" | 13 #include "content/common/navigation_params.h" |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
16 class FrameTreeNode; | 17 class FrameTreeNode; |
| 18 class NavigationURLLoader; |
17 class ResourceRequestBody; | 19 class ResourceRequestBody; |
18 struct NavigationRequestInfo; | 20 struct NavigationRequestInfo; |
19 | 21 |
20 // PlzNavigate | 22 // PlzNavigate |
21 // A UI thread object that owns a navigation request until it commits. It | 23 // A UI thread object that owns a navigation request until it commits. It |
22 // ensures the UI thread can start a navigation request in the | 24 // ensures the UI thread can start a navigation request in the |
23 // ResourceDispatcherHost (that lives on the IO thread). | 25 // ResourceDispatcherHost (that lives on the IO thread). |
24 // TODO(clamy): Describe the interactions between the UI and IO thread during | 26 // TODO(clamy): Describe the interactions between the UI and IO thread during |
25 // the navigation following its refactoring. | 27 // the navigation following its refactoring. |
26 class CONTENT_EXPORT NavigationRequest { | 28 class CONTENT_EXPORT NavigationRequest : public NavigationURLLoaderDelegate { |
27 public: | 29 public: |
28 NavigationRequest(FrameTreeNode* frame_tree_node, | 30 NavigationRequest(FrameTreeNode* frame_tree_node, |
29 const CommonNavigationParams& common_params, | 31 const CommonNavigationParams& common_params, |
30 const CommitNavigationParams& commit_params); | 32 const CommitNavigationParams& commit_params); |
31 | 33 |
32 ~NavigationRequest(); | 34 ~NavigationRequest() override; |
33 | 35 |
34 // Called on the UI thread by the RenderFrameHostManager which owns the | 36 // Called on the UI thread by the RenderFrameHostManager which owns the |
35 // NavigationRequest. Takes ownership of |info|. After calling this function, | 37 // NavigationRequest. Takes ownership of |info|. After calling this function, |
36 // |body| can no longer be manipulated on the UI thread. | 38 // |body| can no longer be manipulated on the UI thread. |
37 void BeginNavigation(scoped_ptr<NavigationRequestInfo> info, | 39 void BeginNavigation(scoped_ptr<NavigationRequestInfo> info, |
38 scoped_refptr<ResourceRequestBody> body); | 40 scoped_refptr<ResourceRequestBody> body); |
39 | 41 |
40 CommonNavigationParams& common_params() { return common_params_; } | 42 CommonNavigationParams& common_params() { return common_params_; } |
41 | 43 |
42 const CommitNavigationParams& commit_params() const { return commit_params_; } | 44 const CommitNavigationParams& commit_params() const { return commit_params_; } |
43 | 45 |
44 NavigationRequestInfo* info_for_test() const { return info_.get(); } | 46 NavigationURLLoader* loader_for_testing() const { return loader_.get(); } |
45 | 47 |
46 private: | 48 private: |
| 49 // NavigationURLLoaderDelegate implementation. |
| 50 void OnRequestRedirected( |
| 51 const net::RedirectInfo& redirect_info, |
| 52 const scoped_refptr<ResourceResponse>& response) override; |
| 53 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, |
| 54 scoped_ptr<StreamHandle> body) override; |
| 55 void OnRequestFailed(int net_error) override; |
| 56 |
47 FrameTreeNode* frame_tree_node_; | 57 FrameTreeNode* frame_tree_node_; |
48 | 58 |
49 // Initialized on creation of the NavigationRequest. Sent to the renderer when | 59 // Initialized on creation of the NavigationRequest. Sent to the renderer when |
50 // the navigation is ready to commit. | 60 // the navigation is ready to commit. |
51 // Note: When the navigation is ready to commit, the url in |common_params| | 61 // Note: When the navigation is ready to commit, the url in |common_params| |
52 // will be set to the final navigation url, obtained after following all | 62 // will be set to the final navigation url, obtained after following all |
53 // redirects. | 63 // redirects. |
54 CommonNavigationParams common_params_; | 64 CommonNavigationParams common_params_; |
55 const CommitNavigationParams commit_params_; | 65 const CommitNavigationParams commit_params_; |
56 | 66 |
57 // Initialized when beginning the navigation. | 67 scoped_ptr<NavigationURLLoader> loader_; |
58 scoped_ptr<NavigationRequestInfo> info_; | |
59 | 68 |
60 DISALLOW_COPY_AND_ASSIGN(NavigationRequest); | 69 DISALLOW_COPY_AND_ASSIGN(NavigationRequest); |
61 }; | 70 }; |
62 | 71 |
63 } // namespace content | 72 } // namespace content |
64 | 73 |
65 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ | 74 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ |
OLD | NEW |