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