OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ |
6 #define CONTENT_BROWSER_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ | 6 #define CONTENT_BROWSER_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/supports_user_data.h" | 15 #include "base/supports_user_data.h" |
16 #include "content/public/browser/resource_request_info.h" | 16 #include "content/public/browser/resource_request_info.h" |
17 #include "content/public/common/referrer.h" | 17 #include "content/public/common/referrer.h" |
18 #include "content/public/common/resource_type.h" | 18 #include "content/public/common/resource_type.h" |
19 #include "net/base/load_states.h" | 19 #include "net/base/load_states.h" |
20 | 20 |
| 21 struct ResourceHostMsg_Request; |
| 22 |
21 namespace content { | 23 namespace content { |
22 class CrossSiteResourceHandler; | 24 class CrossSiteResourceHandler; |
23 class DetachableResourceHandler; | 25 class DetachableResourceHandler; |
24 class ResourceContext; | 26 class ResourceContext; |
25 class ResourceMessageFilter; | 27 class ResourceMessageFilter; |
26 struct GlobalRequestID; | 28 struct GlobalRequestID; |
27 struct GlobalRoutingID; | 29 struct GlobalRoutingID; |
28 | 30 |
29 // Holds the data ResourceDispatcherHost associates with each request. | 31 // Holds the data ResourceDispatcherHost associates with each request. |
30 // Retrieve this data by calling ResourceDispatcherHost::InfoForRequest. | 32 // Retrieve this data by calling ResourceDispatcherHost::InfoForRequest. |
31 class ResourceRequestInfoImpl : public ResourceRequestInfo, | 33 class ResourceRequestInfoImpl : public ResourceRequestInfo, |
32 public base::SupportsUserData::Data { | 34 public base::SupportsUserData::Data { |
33 public: | 35 public: |
34 // Returns the ResourceRequestInfoImpl associated with the given URLRequest. | 36 // Returns the ResourceRequestInfoImpl associated with the given URLRequest. |
35 CONTENT_EXPORT static ResourceRequestInfoImpl* ForRequest( | 37 CONTENT_EXPORT static ResourceRequestInfoImpl* ForRequest( |
36 net::URLRequest* request); | 38 net::URLRequest* request); |
37 | 39 |
38 // And, a const version for cases where you only need read access. | 40 // And, a const version for cases where you only need read access. |
39 CONTENT_EXPORT static const ResourceRequestInfoImpl* ForRequest( | 41 CONTENT_EXPORT static const ResourceRequestInfoImpl* ForRequest( |
40 const net::URLRequest* request); | 42 const net::URLRequest* request); |
41 | 43 |
| 44 // TODO(ricea): Something about this constructor. |
| 45 // |original_request| is owned by the caller. If non-NULL, it is copied by |
| 46 // the constructor. |
42 CONTENT_EXPORT ResourceRequestInfoImpl( | 47 CONTENT_EXPORT ResourceRequestInfoImpl( |
43 int process_type, | 48 int process_type, |
44 int child_id, | 49 int child_id, |
45 int route_id, | 50 int route_id, |
46 int frame_tree_node_id, | 51 int frame_tree_node_id, |
47 int origin_pid, | 52 int origin_pid, |
48 int request_id, | 53 int request_id, |
49 int render_frame_id, | 54 int render_frame_id, |
50 bool is_main_frame, | 55 bool is_main_frame, |
51 bool parent_is_main_frame, | 56 bool parent_is_main_frame, |
52 int parent_render_frame_id, | 57 int parent_render_frame_id, |
53 ResourceType resource_type, | 58 ResourceType resource_type, |
54 ui::PageTransition transition_type, | 59 ui::PageTransition transition_type, |
55 bool should_replace_current_entry, | 60 bool should_replace_current_entry, |
56 bool is_download, | 61 bool is_download, |
57 bool is_stream, | 62 bool is_stream, |
58 bool allow_download, | 63 bool allow_download, |
59 bool has_user_gesture, | 64 bool has_user_gesture, |
60 bool enable_load_timing, | 65 bool enable_load_timing, |
61 bool enable_upload_progress, | 66 bool enable_upload_progress, |
62 bool do_not_prompt_for_login, | 67 bool do_not_prompt_for_login, |
63 blink::WebReferrerPolicy referrer_policy, | 68 blink::WebReferrerPolicy referrer_policy, |
64 blink::WebPageVisibilityState visibility_state, | 69 blink::WebPageVisibilityState visibility_state, |
65 ResourceContext* context, | 70 ResourceContext* context, |
66 base::WeakPtr<ResourceMessageFilter> filter, | 71 base::WeakPtr<ResourceMessageFilter> filter, |
67 bool is_async); | 72 bool is_async, |
| 73 bool is_async_revalidation, |
| 74 const ResourceHostMsg_Request* original_request); |
68 ~ResourceRequestInfoImpl() override; | 75 ~ResourceRequestInfoImpl() override; |
69 | 76 |
70 // ResourceRequestInfo implementation: | 77 // ResourceRequestInfo implementation: |
71 ResourceContext* GetContext() const override; | 78 ResourceContext* GetContext() const override; |
72 int GetChildID() const override; | 79 int GetChildID() const override; |
73 int GetRouteID() const override; | 80 int GetRouteID() const override; |
74 int GetOriginPID() const override; | 81 int GetOriginPID() const override; |
75 int GetRequestID() const override; | 82 int GetRequestID() const override; |
76 int GetRenderFrameID() const override; | 83 int GetRenderFrameID() const override; |
77 bool IsMainFrame() const override; | 84 bool IsMainFrame() const override; |
78 bool ParentIsMainFrame() const override; | 85 bool ParentIsMainFrame() const override; |
79 int GetParentRenderFrameID() const override; | 86 int GetParentRenderFrameID() const override; |
80 ResourceType GetResourceType() const override; | 87 ResourceType GetResourceType() const override; |
81 int GetProcessType() const override; | 88 int GetProcessType() const override; |
82 blink::WebReferrerPolicy GetReferrerPolicy() const override; | 89 blink::WebReferrerPolicy GetReferrerPolicy() const override; |
83 blink::WebPageVisibilityState GetVisibilityState() const override; | 90 blink::WebPageVisibilityState GetVisibilityState() const override; |
84 ui::PageTransition GetPageTransition() const override; | 91 ui::PageTransition GetPageTransition() const override; |
85 bool HasUserGesture() const override; | 92 bool HasUserGesture() const override; |
86 bool WasIgnoredByHandler() const override; | 93 bool WasIgnoredByHandler() const override; |
87 bool GetAssociatedRenderFrame(int* render_process_id, | 94 bool GetAssociatedRenderFrame(int* render_process_id, |
88 int* render_frame_id) const override; | 95 int* render_frame_id) const override; |
89 bool IsAsync() const override; | 96 bool IsAsync() const override; |
90 bool IsDownload() const override; | 97 bool IsDownload() const override; |
| 98 bool IsAsyncRevalidation() const override; |
91 | 99 |
92 CONTENT_EXPORT void AssociateWithRequest(net::URLRequest* request); | 100 CONTENT_EXPORT void AssociateWithRequest(net::URLRequest* request); |
93 | 101 |
94 CONTENT_EXPORT GlobalRequestID GetGlobalRequestID() const; | 102 CONTENT_EXPORT GlobalRequestID GetGlobalRequestID() const; |
95 GlobalRoutingID GetGlobalRoutingID() const; | 103 GlobalRoutingID GetGlobalRoutingID() const; |
96 | 104 |
97 // PlzNavigate | 105 // PlzNavigate |
98 // The id of the FrameTreeNode that initiated this request (for a navigation | 106 // The id of the FrameTreeNode that initiated this request (for a navigation |
99 // request). | 107 // request). |
100 int frame_tree_node_id() const { return frame_tree_node_id_; } | 108 int frame_tree_node_id() const { return frame_tree_node_id_; } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 void set_memory_cost(int cost) { memory_cost_ = cost; } | 179 void set_memory_cost(int cost) { memory_cost_ = cost; } |
172 | 180 |
173 bool is_load_timing_enabled() const { return enable_load_timing_; } | 181 bool is_load_timing_enabled() const { return enable_load_timing_; } |
174 | 182 |
175 bool is_upload_progress_enabled() const { return enable_upload_progress_; } | 183 bool is_upload_progress_enabled() const { return enable_upload_progress_; } |
176 | 184 |
177 bool do_not_prompt_for_login() const { return do_not_prompt_for_login_; } | 185 bool do_not_prompt_for_login() const { return do_not_prompt_for_login_; } |
178 void set_do_not_prompt_for_login(bool do_not_prompt) { | 186 void set_do_not_prompt_for_login(bool do_not_prompt) { |
179 do_not_prompt_for_login_ = do_not_prompt; | 187 do_not_prompt_for_login_ = do_not_prompt; |
180 } | 188 } |
| 189 ResourceHostMsg_Request* original_request() { |
| 190 return original_request_.get(); |
| 191 } |
181 | 192 |
182 private: | 193 private: |
183 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 194 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
184 DeletedFilterDetached); | 195 DeletedFilterDetached); |
185 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 196 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
186 DeletedFilterDetachedRedirect); | 197 DeletedFilterDetachedRedirect); |
187 // Non-owning, may be NULL. | 198 // Non-owning, may be NULL. |
188 CrossSiteResourceHandler* cross_site_handler_; | 199 CrossSiteResourceHandler* cross_site_handler_; |
189 DetachableResourceHandler* detachable_handler_; | 200 DetachableResourceHandler* detachable_handler_; |
190 | 201 |
(...skipping 19 matching lines...) Expand all Loading... |
210 bool counted_as_in_flight_request_; | 221 bool counted_as_in_flight_request_; |
211 ResourceType resource_type_; | 222 ResourceType resource_type_; |
212 ui::PageTransition transition_type_; | 223 ui::PageTransition transition_type_; |
213 int memory_cost_; | 224 int memory_cost_; |
214 blink::WebReferrerPolicy referrer_policy_; | 225 blink::WebReferrerPolicy referrer_policy_; |
215 blink::WebPageVisibilityState visibility_state_; | 226 blink::WebPageVisibilityState visibility_state_; |
216 ResourceContext* context_; | 227 ResourceContext* context_; |
217 // The filter might be deleted without deleting this object if the process | 228 // The filter might be deleted without deleting this object if the process |
218 // exits during a transfer. | 229 // exits during a transfer. |
219 base::WeakPtr<ResourceMessageFilter> filter_; | 230 base::WeakPtr<ResourceMessageFilter> filter_; |
| 231 |
| 232 // Original request information required to clone the request if an async |
| 233 // revalidation will be performed. NULL if async revalidation is not |
| 234 // applicable to this request (eg. it is already an async revalidation, is not |
| 235 // method "GET", etc.). |
| 236 scoped_ptr<ResourceHostMsg_Request> original_request_; |
| 237 |
220 bool is_async_; | 238 bool is_async_; |
| 239 bool is_async_revalidation_; |
221 | 240 |
222 DISALLOW_COPY_AND_ASSIGN(ResourceRequestInfoImpl); | 241 DISALLOW_COPY_AND_ASSIGN(ResourceRequestInfoImpl); |
223 }; | 242 }; |
224 | 243 |
225 } // namespace content | 244 } // namespace content |
226 | 245 |
227 #endif // CONTENT_BROWSER_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ | 246 #endif // CONTENT_BROWSER_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ |
OLD | NEW |