Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: content/browser/frame_host/navigation_request.h

Issue 761013003: PlzNavigate: add support in several navigation controller unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved the functions to the TestRenderFrameHost Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browser/loader/navigation_url_loader_delegate.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/common/navigation_params.h" 13 #include "content/common/navigation_params.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 class FrameTreeNode; 17 class FrameTreeNode;
18 class NavigationURLLoader; 18 class NavigationURLLoader;
19 class ResourceRequestBody; 19 class ResourceRequestBody;
20 struct NavigationRequestInfo; 20 struct NavigationRequestInfo;
21 21
22 // PlzNavigate 22 // PlzNavigate
23 // 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
24 // ensures the UI thread can start a navigation request in the 24 // ensures the UI thread can start a navigation request in the
25 // ResourceDispatcherHost (that lives on the IO thread). 25 // ResourceDispatcherHost (that lives on the IO thread).
26 // 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
27 // the navigation following its refactoring. 27 // the navigation following its refactoring.
28 class CONTENT_EXPORT NavigationRequest : public NavigationURLLoaderDelegate { 28 class CONTENT_EXPORT NavigationRequest : public NavigationURLLoaderDelegate {
29 public: 29 public:
30 enum NavigationState {
clamy 2014/12/15 17:01:39 I actually plan to use this enum for things other
nasko 2014/12/16 01:40:26 Let's put a comment explaining the goal/usage of i
clamy 2014/12/17 15:47:57 Done.
31 NOT_STARTED = 0,
32 WAITING_FOR_RENDERER_RESPONSE,
33 STARTED,
34 RESPONSE_STARTED,
35 FAILED,
36 };
37
30 NavigationRequest(FrameTreeNode* frame_tree_node, 38 NavigationRequest(FrameTreeNode* frame_tree_node,
31 const CommonNavigationParams& common_params, 39 const CommonNavigationParams& common_params,
32 const CommitNavigationParams& commit_params); 40 const CommitNavigationParams& commit_params);
33 41
34 ~NavigationRequest() override; 42 ~NavigationRequest() override;
35 43
36 // Called on the UI thread by the RenderFrameHostManager which owns the 44 // Called on the UI thread by the RenderFrameHostManager which owns the
37 // NavigationRequest. Takes ownership of |info|. After calling this function, 45 // NavigationRequest. Takes ownership of |info|. After calling this function,
38 // |body| can no longer be manipulated on the UI thread. 46 // |body| can no longer be manipulated on the UI thread.
39 void BeginNavigation(scoped_ptr<NavigationRequestInfo> info, 47 void BeginNavigation(scoped_ptr<NavigationRequestInfo> info,
40 scoped_refptr<ResourceRequestBody> body); 48 scoped_refptr<ResourceRequestBody> body);
41 49
42 CommonNavigationParams& common_params() { return common_params_; } 50 CommonNavigationParams& common_params() { return common_params_; }
43 51
44 const CommitNavigationParams& commit_params() const { return commit_params_; } 52 const CommitNavigationParams& commit_params() const { return commit_params_; }
45 53
46 NavigationURLLoader* loader_for_testing() const { return loader_.get(); } 54 NavigationURLLoader* loader_for_testing() const { return loader_.get(); }
47 55
56 NavigationState state() const { return state_; }
57
58 void SetWaitingForRendererResponse() {
nasko 2014/12/16 01:40:26 Do we not expect to have other states being set ex
clamy 2014/12/16 19:19:05 No the other states are set because of the interac
nasko 2014/12/17 00:55:02 Acknowledged.
59 state_ = WAITING_FOR_RENDERER_RESPONSE;
60 }
61
48 private: 62 private:
49 // NavigationURLLoaderDelegate implementation. 63 // NavigationURLLoaderDelegate implementation.
50 void OnRequestRedirected( 64 void OnRequestRedirected(
51 const net::RedirectInfo& redirect_info, 65 const net::RedirectInfo& redirect_info,
52 const scoped_refptr<ResourceResponse>& response) override; 66 const scoped_refptr<ResourceResponse>& response) override;
53 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, 67 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response,
54 scoped_ptr<StreamHandle> body) override; 68 scoped_ptr<StreamHandle> body) override;
55 void OnRequestFailed(int net_error) override; 69 void OnRequestFailed(int net_error) override;
56 70
57 FrameTreeNode* frame_tree_node_; 71 FrameTreeNode* frame_tree_node_;
58 72
59 // Initialized on creation of the NavigationRequest. Sent to the renderer when 73 // Initialized on creation of the NavigationRequest. Sent to the renderer when
60 // the navigation is ready to commit. 74 // the navigation is ready to commit.
61 // Note: When the navigation is ready to commit, the url in |common_params| 75 // Note: When the navigation is ready to commit, the url in |common_params|
62 // will be set to the final navigation url, obtained after following all 76 // will be set to the final navigation url, obtained after following all
63 // redirects. 77 // redirects.
64 CommonNavigationParams common_params_; 78 CommonNavigationParams common_params_;
65 const CommitNavigationParams commit_params_; 79 const CommitNavigationParams commit_params_;
66 80
81 NavigationState state_;
82
67 scoped_ptr<NavigationURLLoader> loader_; 83 scoped_ptr<NavigationURLLoader> loader_;
68 84
69 DISALLOW_COPY_AND_ASSIGN(NavigationRequest); 85 DISALLOW_COPY_AND_ASSIGN(NavigationRequest);
70 }; 86 };
71 87
72 } // namespace content 88 } // namespace content
73 89
74 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ 90 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698