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

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

Powered by Google App Engine
This is Rietveld 408576698