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

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: Addressed Nasko's comments 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 // Keeps track of the various stages of a NavigationRequest.
31 enum NavigationState {
32 // Initial state.
33 NOT_STARTED = 0,
34
35 // Waiting for a BeginNavigation IPC from the renderer in a
36 // browser-initiated navigation. If there is no live renderer when the
37 // request is created, this stage is skipped.
38 WAITING_FOR_RENDERER_RESPONSE,
39
40 // The request was sent to the IO thread.
41 STARTED,
42
43 // The response started on the IO thread and is ready to be committed. This
44 // is one of the two final states for the request.
45 RESPONSE_STARTED,
46
47 // The request failed on the IO thread and an error page should be
48 // displayed. This is one of the two final states for the request.
49 FAILED,
50 };
51
30 NavigationRequest(FrameTreeNode* frame_tree_node, 52 NavigationRequest(FrameTreeNode* frame_tree_node,
31 const CommonNavigationParams& common_params, 53 const CommonNavigationParams& common_params,
32 const CommitNavigationParams& commit_params); 54 const CommitNavigationParams& commit_params);
33 55
34 ~NavigationRequest() override; 56 ~NavigationRequest() override;
35 57
36 // Called on the UI thread by the RenderFrameHostManager which owns the 58 // Called on the UI thread by the RenderFrameHostManager which owns the
37 // NavigationRequest. Takes ownership of |info|. After calling this function, 59 // NavigationRequest. Takes ownership of |info|. After calling this function,
38 // |body| can no longer be manipulated on the UI thread. 60 // |body| can no longer be manipulated on the UI thread.
39 void BeginNavigation(scoped_ptr<NavigationRequestInfo> info, 61 void BeginNavigation(scoped_ptr<NavigationRequestInfo> info,
40 scoped_refptr<ResourceRequestBody> body); 62 scoped_refptr<ResourceRequestBody> body);
41 63
42 CommonNavigationParams& common_params() { return common_params_; } 64 CommonNavigationParams& common_params() { return common_params_; }
43 65
44 const CommitNavigationParams& commit_params() const { return commit_params_; } 66 const CommitNavigationParams& commit_params() const { return commit_params_; }
45 67
46 NavigationURLLoader* loader_for_testing() const { return loader_.get(); } 68 NavigationURLLoader* loader_for_testing() const { return loader_.get(); }
47 69
70 NavigationState state() const { return state_; }
71
72 void SetWaitingForRendererResponse() {
73 DCHECK(state_ == NOT_STARTED);
74 state_ = WAITING_FOR_RENDERER_RESPONSE;
75 }
76
48 private: 77 private:
49 // NavigationURLLoaderDelegate implementation. 78 // NavigationURLLoaderDelegate implementation.
50 void OnRequestRedirected( 79 void OnRequestRedirected(
51 const net::RedirectInfo& redirect_info, 80 const net::RedirectInfo& redirect_info,
52 const scoped_refptr<ResourceResponse>& response) override; 81 const scoped_refptr<ResourceResponse>& response) override;
53 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, 82 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response,
54 scoped_ptr<StreamHandle> body) override; 83 scoped_ptr<StreamHandle> body) override;
55 void OnRequestFailed(int net_error) override; 84 void OnRequestFailed(int net_error) override;
56 85
57 FrameTreeNode* frame_tree_node_; 86 FrameTreeNode* frame_tree_node_;
58 87
59 // Initialized on creation of the NavigationRequest. Sent to the renderer when 88 // Initialized on creation of the NavigationRequest. Sent to the renderer when
60 // the navigation is ready to commit. 89 // the navigation is ready to commit.
61 // Note: When the navigation is ready to commit, the url in |common_params| 90 // 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 91 // will be set to the final navigation url, obtained after following all
63 // redirects. 92 // redirects.
64 CommonNavigationParams common_params_; 93 CommonNavigationParams common_params_;
65 const CommitNavigationParams commit_params_; 94 const CommitNavigationParams commit_params_;
66 95
96 NavigationState state_;
97
67 scoped_ptr<NavigationURLLoader> loader_; 98 scoped_ptr<NavigationURLLoader> loader_;
68 99
69 DISALLOW_COPY_AND_ASSIGN(NavigationRequest); 100 DISALLOW_COPY_AND_ASSIGN(NavigationRequest);
70 }; 101 };
71 102
72 } // namespace content 103 } // namespace content
73 104
74 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_ 105 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_REQUEST_H_
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl_unittest.cc ('k') | content/browser/frame_host/navigation_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698