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

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

Issue 1294243004: PlzNavigate: Make ServiceWorker work with PlzNavigate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 5 years, 2 months 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_HANDLE_IMPL_H_ 5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
7 7
8 #include "content/public/browser/navigation_handle.h" 8 #include "content/public/browser/navigation_handle.h"
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
13 #include "content/browser/frame_host/render_frame_host_impl.h" 14 #include "content/browser/frame_host/render_frame_host_impl.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 #include "content/public/browser/navigation_throttle.h" 16 #include "content/public/browser/navigation_throttle.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 class NavigatorDelegate; 21 class NavigatorDelegate;
22 class ServiceWorkerContextWrapper;
21 struct NavigationRequestInfo; 23 struct NavigationRequestInfo;
22 24
23 // This class keeps track of a single navigation. It is created upon receipt of 25 // This class keeps track of a single navigation. It is created upon receipt of
24 // a DidStartProvisionalLoad IPC in a RenderFrameHost. The RenderFrameHost owns 26 // a DidStartProvisionalLoad IPC in a RenderFrameHost. The RenderFrameHost owns
25 // the newly created NavigationHandleImpl as long as the navigation is ongoing. 27 // the newly created NavigationHandleImpl as long as the navigation is ongoing.
26 // The NavigationHandleImpl in the RenderFrameHost will be reset when the 28 // The NavigationHandleImpl in the RenderFrameHost will be reset when the
27 // navigation stops, that is if one of the following events happen: 29 // navigation stops, that is if one of the following events happen:
28 // - The RenderFrameHost receives a DidStartProvisionalLoad IPC for a new 30 // - The RenderFrameHost receives a DidStartProvisionalLoad IPC for a new
29 // navigation (see below for special cases where the DidStartProvisionalLoad 31 // navigation (see below for special cases where the DidStartProvisionalLoad
30 // message does not indicate the start of a new navigation). 32 // message does not indicate the start of a new navigation).
(...skipping 17 matching lines...) Expand all
48 // NavigationRequest. It is then owned by the NavigationRequest until the 50 // NavigationRequest. It is then owned by the NavigationRequest until the
49 // navigation is ready to commit. The NavigationHandleImpl ownership is then 51 // navigation is ready to commit. The NavigationHandleImpl ownership is then
50 // transferred to the RenderFrameHost in which the navigation will commit. 52 // transferred to the RenderFrameHost in which the navigation will commit.
51 // 53 //
52 // When PlzNavigate is enabled, the NavigationHandleImpl will never be reset 54 // When PlzNavigate is enabled, the NavigationHandleImpl will never be reset
53 // following the receipt of a DidStartProvisionalLoad IPC. There are also no 55 // following the receipt of a DidStartProvisionalLoad IPC. There are also no
54 // transferring navigations. The other causes of NavigationHandleImpl reset in 56 // transferring navigations. The other causes of NavigationHandleImpl reset in
55 // the RenderFrameHost still apply. 57 // the RenderFrameHost still apply.
56 class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle { 58 class CONTENT_EXPORT NavigationHandleImpl : public NavigationHandle {
57 public: 59 public:
58 static scoped_ptr<NavigationHandleImpl> Create(const GURL& url, 60 static scoped_ptr<NavigationHandleImpl>
59 bool is_main_frame, 61 Create(const GURL& url, bool is_main_frame, FrameTreeNode* frame_tree_node);
60 NavigatorDelegate* delegate);
61 ~NavigationHandleImpl() override; 62 ~NavigationHandleImpl() override;
62 63
63 // NavigationHandle implementation: 64 // NavigationHandle implementation:
64 const GURL& GetURL() override; 65 const GURL& GetURL() override;
65 bool IsInMainFrame() override; 66 bool IsInMainFrame() override;
66 bool IsPost() override; 67 bool IsPost() override;
67 const Referrer& GetReferrer() override; 68 const Referrer& GetReferrer() override;
68 bool HasUserGesture() override; 69 bool HasUserGesture() override;
69 ui::PageTransition GetPageTransition() override; 70 ui::PageTransition GetPageTransition() override;
70 bool IsExternalProtocol() override; 71 bool IsExternalProtocol() override;
(...skipping 24 matching lines...) Expand all
95 96
96 // Returns whether the navigation is currently being transferred from one 97 // Returns whether the navigation is currently being transferred from one
97 // RenderFrameHost to another. In particular, a DidStartProvisionalLoad IPC 98 // RenderFrameHost to another. In particular, a DidStartProvisionalLoad IPC
98 // for the navigation URL, received in the new RenderFrameHost, should not 99 // for the navigation URL, received in the new RenderFrameHost, should not
99 // indicate the start of a new navigation in that case. 100 // indicate the start of a new navigation in that case.
100 bool is_transferring() const { return is_transferring_; } 101 bool is_transferring() const { return is_transferring_; }
101 void set_is_transferring(bool is_transferring) { 102 void set_is_transferring(bool is_transferring) {
102 is_transferring_ = is_transferring; 103 is_transferring_ = is_transferring;
103 } 104 }
104 105
106 // PlzNavigate
107 void set_service_worker_provider_id(int service_worker_provider_id) {
108 service_worker_provider_id_ = service_worker_provider_id;
109 }
110
105 // Called when the URLRequest will start in the network stack. 111 // Called when the URLRequest will start in the network stack.
106 NavigationThrottle::ThrottleCheckResult WillStartRequest( 112 NavigationThrottle::ThrottleCheckResult WillStartRequest(
107 bool is_post, 113 bool is_post,
108 const Referrer& sanitized_referrer, 114 const Referrer& sanitized_referrer,
109 bool has_user_gesture, 115 bool has_user_gesture,
110 ui::PageTransition transition, 116 ui::PageTransition transition,
111 bool is_external_protocol); 117 bool is_external_protocol);
112 118
113 // Called when the URLRequest will be redirected in the network stack. 119 // Called when the URLRequest will be redirected in the network stack.
114 NavigationThrottle::ThrottleCheckResult WillRedirectRequest( 120 NavigationThrottle::ThrottleCheckResult WillRedirectRequest(
(...skipping 20 matching lines...) Expand all
135 // Used to track the state the navigation is currently in. 141 // Used to track the state the navigation is currently in.
136 enum State { 142 enum State {
137 INITIAL = 0, 143 INITIAL = 0,
138 WILL_SEND_REQUEST, 144 WILL_SEND_REQUEST,
139 READY_TO_COMMIT, 145 READY_TO_COMMIT,
140 DID_COMMIT, 146 DID_COMMIT,
141 DID_COMMIT_ERROR_PAGE, 147 DID_COMMIT_ERROR_PAGE,
142 }; 148 };
143 149
144 NavigationHandleImpl(const GURL& url, 150 NavigationHandleImpl(const GURL& url,
145 const bool is_main_frame, 151 bool is_main_frame,
nasko 2015/10/02 22:09:45 Why did we lose the const here?
Fabrice (no longer in Chrome) 2015/10/06 17:21:37 It was inconsistent. This has been removed in the
146 NavigatorDelegate* delegate); 152 FrameTreeNode* frame_tree_node);
147 153
148 // See NavigationHandle for a description of those member variables. 154 // See NavigationHandle for a description of those member variables.
149 GURL url_; 155 GURL url_;
150 const bool is_main_frame_; 156 const bool is_main_frame_;
151 bool is_post_; 157 bool is_post_;
152 Referrer sanitized_referrer_; 158 Referrer sanitized_referrer_;
153 bool has_user_gesture_; 159 bool has_user_gesture_;
154 ui::PageTransition transition_; 160 ui::PageTransition transition_;
155 bool is_external_protocol_; 161 bool is_external_protocol_;
156 net::Error net_error_code_; 162 net::Error net_error_code_;
157 RenderFrameHostImpl* render_frame_host_; 163 RenderFrameHostImpl* render_frame_host_;
158 bool is_same_page_; 164 bool is_same_page_;
159 165
160 // The state the navigation is in. 166 // The state the navigation is in.
161 State state_; 167 State state_;
162 168
163 // Whether the navigation is in the middle of a transfer. Set to false when 169 // Whether the navigation is in the middle of a transfer. Set to false when
164 // the DidStartProvisionalLoad is received from the new renderer. 170 // the DidStartProvisionalLoad is received from the new renderer.
165 bool is_transferring_; 171 bool is_transferring_;
166 172
167 // The delegate that should be notified about events related to this 173 // The delegate that should be notified about events related to this
168 // navigation. 174 // navigation.
169 NavigatorDelegate* delegate_; 175 NavigatorDelegate* delegate_;
170 176
171 // A list of Throttles registered for this navigation. 177 // A list of Throttles registered for this navigation.
172 ScopedVector<NavigationThrottle> throttles_; 178 ScopedVector<NavigationThrottle> throttles_;
173 179
180 // PlzNavigate
181 // The ServiceWorkerProviderHost ID used for navigations.
182 // Set to kInvalidServiceWorkerProviderId for sandboxed frames and sync loads.
183 // This is unused for current navigation.
clamy 2015/10/05 12:18:16 nit: rephrase as "This parameter is not used in th
Fabrice (no longer in Chrome) 2015/10/06 17:21:37 Done.
184 int service_worker_provider_id_;
185
186 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
nasko 2015/10/02 22:09:45 Can you add a comment on this member?
clamy 2015/10/05 12:18:16 I'd rather you store the FrameTreeNode (see commen
Fabrice (no longer in Chrome) 2015/10/06 17:21:37 Done.
187
174 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl); 188 DISALLOW_COPY_AND_ASSIGN(NavigationHandleImpl);
175 }; 189 };
176 190
177 } // namespace content 191 } // namespace content
178 192
179 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_ 193 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATION_HANDLE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698