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