Chromium Code Reviews| 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 <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
|
mmenke
2016/11/21 19:51:55
No longer needed.
horo
2016/11/22 01:12:08
Done.
| |
| 16 #include "base/supports_user_data.h" | 16 #include "base/supports_user_data.h" |
| 17 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 17 #include "content/browser/loader/resource_requester_info.h" |
| 18 #include "content/common/resource_request_body_impl.h" | 18 #include "content/common/resource_request_body_impl.h" |
| 19 #include "content/public/browser/navigation_ui_data.h" | 19 #include "content/public/browser/navigation_ui_data.h" |
| 20 #include "content/public/browser/resource_request_info.h" | 20 #include "content/public/browser/resource_request_info.h" |
| 21 #include "content/public/common/referrer.h" | 21 #include "content/public/common/referrer.h" |
| 22 #include "content/public/common/resource_type.h" | 22 #include "content/public/common/resource_type.h" |
| 23 #include "net/base/load_states.h" | 23 #include "net/base/load_states.h" |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 class DetachableResourceHandler; | 26 class DetachableResourceHandler; |
| 27 class ResourceContext; | 27 class ResourceContext; |
| 28 class ResourceMessageFilter; | 28 class ResourceMessageFilter; |
|
mmenke
2016/11/21 19:51:55
No longer needed
horo
2016/11/22 01:12:08
Done.
| |
| 29 struct GlobalRequestID; | 29 struct GlobalRequestID; |
| 30 struct GlobalRoutingID; | 30 struct GlobalRoutingID; |
| 31 | 31 |
| 32 // Holds the data ResourceDispatcherHost associates with each request. | 32 // Holds the data ResourceDispatcherHost associates with each request. |
| 33 // Retrieve this data by calling ResourceDispatcherHost::InfoForRequest. | 33 // Retrieve this data by calling ResourceDispatcherHost::InfoForRequest. |
| 34 class ResourceRequestInfoImpl : public ResourceRequestInfo, | 34 class ResourceRequestInfoImpl : public ResourceRequestInfo, |
| 35 public base::SupportsUserData::Data { | 35 public base::SupportsUserData::Data { |
| 36 public: | 36 public: |
| 37 // Returns the ResourceRequestInfoImpl associated with the given URLRequest. | 37 // Returns the ResourceRequestInfoImpl associated with the given URLRequest. |
| 38 CONTENT_EXPORT static ResourceRequestInfoImpl* ForRequest( | 38 CONTENT_EXPORT static ResourceRequestInfoImpl* ForRequest( |
| 39 net::URLRequest* request); | 39 net::URLRequest* request); |
| 40 | 40 |
| 41 // And, a const version for cases where you only need read access. | 41 // And, a const version for cases where you only need read access. |
| 42 CONTENT_EXPORT static const ResourceRequestInfoImpl* ForRequest( | 42 CONTENT_EXPORT static const ResourceRequestInfoImpl* ForRequest( |
| 43 const net::URLRequest* request); | 43 const net::URLRequest* request); |
| 44 | 44 |
| 45 CONTENT_EXPORT ResourceRequestInfoImpl( | 45 CONTENT_EXPORT ResourceRequestInfoImpl( |
| 46 int process_type, | 46 scoped_refptr<ResourceRequesterInfo> requester_info, |
| 47 int child_id, | |
| 48 int route_id, | 47 int route_id, |
| 49 int frame_tree_node_id, | 48 int frame_tree_node_id, |
| 50 int origin_pid, | 49 int origin_pid, |
| 51 int request_id, | 50 int request_id, |
| 52 int render_frame_id, | 51 int render_frame_id, |
| 53 bool is_main_frame, | 52 bool is_main_frame, |
| 54 bool parent_is_main_frame, | 53 bool parent_is_main_frame, |
| 55 ResourceType resource_type, | 54 ResourceType resource_type, |
| 56 ui::PageTransition transition_type, | 55 ui::PageTransition transition_type, |
| 57 bool should_replace_current_entry, | 56 bool should_replace_current_entry, |
| 58 bool is_download, | 57 bool is_download, |
| 59 bool is_stream, | 58 bool is_stream, |
| 60 bool allow_download, | 59 bool allow_download, |
| 61 bool has_user_gesture, | 60 bool has_user_gesture, |
| 62 bool enable_load_timing, | 61 bool enable_load_timing, |
| 63 bool enable_upload_progress, | 62 bool enable_upload_progress, |
| 64 bool do_not_prompt_for_login, | 63 bool do_not_prompt_for_login, |
| 65 blink::WebReferrerPolicy referrer_policy, | 64 blink::WebReferrerPolicy referrer_policy, |
| 66 blink::WebPageVisibilityState visibility_state, | 65 blink::WebPageVisibilityState visibility_state, |
| 67 ResourceContext* context, | 66 ResourceContext* context, |
| 68 base::WeakPtr<ResourceMessageFilter> filter, | |
| 69 bool report_raw_headers, | 67 bool report_raw_headers, |
| 70 bool is_async, | 68 bool is_async, |
| 71 bool is_using_lofi, | 69 bool is_using_lofi, |
| 72 const std::string& original_headers, | 70 const std::string& original_headers, |
| 73 const scoped_refptr<ResourceRequestBodyImpl> body, | 71 const scoped_refptr<ResourceRequestBodyImpl> body, |
| 74 bool initiated_in_secure_context); | 72 bool initiated_in_secure_context); |
| 75 ~ResourceRequestInfoImpl() override; | 73 ~ResourceRequestInfoImpl() override; |
| 76 | 74 |
| 77 // ResourceRequestInfo implementation: | 75 // ResourceRequestInfo implementation: |
| 78 WebContentsGetter GetWebContentsGetterForRequest() const override; | 76 WebContentsGetter GetWebContentsGetterForRequest() const override; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 103 CONTENT_EXPORT void AssociateWithRequest(net::URLRequest* request); | 101 CONTENT_EXPORT void AssociateWithRequest(net::URLRequest* request); |
| 104 | 102 |
| 105 CONTENT_EXPORT int GetRequestID() const; | 103 CONTENT_EXPORT int GetRequestID() const; |
| 106 GlobalRoutingID GetGlobalRoutingID() const; | 104 GlobalRoutingID GetGlobalRoutingID() const; |
| 107 | 105 |
| 108 // PlzNavigate | 106 // PlzNavigate |
| 109 // The id of the FrameTreeNode that initiated this request (for a navigation | 107 // The id of the FrameTreeNode that initiated this request (for a navigation |
| 110 // request). | 108 // request). |
| 111 int frame_tree_node_id() const { return frame_tree_node_id_; } | 109 int frame_tree_node_id() const { return frame_tree_node_id_; } |
| 112 | 110 |
| 113 // May be NULL (e.g., if process dies during a transfer). | 111 ResourceRequesterInfo& requester_info() const { return *requester_info_; } |
|
mmenke
2016/11/21 19:51:55
const methods returning non-const references seems
horo
2016/11/22 01:12:07
Reflecting on kinuko's opinion, I changed Resource
kinuko
2016/11/22 02:44:47
Then this method should be non-const too, right?
| |
| 114 ResourceMessageFilter* filter() const { | |
| 115 return filter_.get(); | |
| 116 } | |
| 117 | 112 |
| 118 // Updates the data associated with this request after it is is transferred | 113 // Updates the data associated with this request after it is is transferred |
| 119 // to a new renderer process. Not all data will change during a transfer. | 114 // to a new renderer process. Not all data will change during a transfer. |
| 120 // We do not expect the ResourceContext to change during navigation, so that | 115 // We do not expect the ResourceContext to change during navigation, so that |
| 121 // does not need to be updated. | 116 // does not need to be updated. |
| 122 void UpdateForTransfer(int child_id, | 117 void UpdateForTransfer(int route_id, |
| 123 int route_id, | |
| 124 int render_frame_id, | 118 int render_frame_id, |
| 125 int origin_pid, | 119 int origin_pid, |
| 126 int request_id, | 120 int request_id, |
| 127 base::WeakPtr<ResourceMessageFilter> filter); | 121 ResourceRequesterInfo* requester_info); |
| 128 | 122 |
| 129 // Whether this request is part of a navigation that should replace the | 123 // Whether this request is part of a navigation that should replace the |
| 130 // current session history entry. This state is shuffled up and down the stack | 124 // current session history entry. This state is shuffled up and down the stack |
| 131 // for request transfers. | 125 // for request transfers. |
| 132 bool should_replace_current_entry() const { | 126 bool should_replace_current_entry() const { |
| 133 return should_replace_current_entry_; | 127 return should_replace_current_entry_; |
| 134 } | 128 } |
| 135 | 129 |
| 136 // DetachableResourceHandler for this request. May be NULL. | 130 // DetachableResourceHandler for this request. May be NULL. |
| 137 DetachableResourceHandler* detachable_handler() const { | 131 DetachableResourceHandler* detachable_handler() const { |
| 138 return detachable_handler_; | 132 return detachable_handler_; |
| 139 } | 133 } |
| 140 void set_detachable_handler(DetachableResourceHandler* h) { | 134 void set_detachable_handler(DetachableResourceHandler* h) { |
| 141 detachable_handler_ = h; | 135 detachable_handler_ = h; |
| 142 } | 136 } |
| 143 | 137 |
| 144 // Identifies the type of process (renderer, plugin, etc.) making the request. | |
| 145 int process_type() const { return process_type_; } | |
| 146 | |
| 147 // Downloads are allowed only as a top level request. | 138 // Downloads are allowed only as a top level request. |
| 148 bool allow_download() const { return allow_download_; } | 139 bool allow_download() const { return allow_download_; } |
| 149 | 140 |
| 150 // Whether this is a download. | 141 // Whether this is a download. |
| 151 void set_is_download(bool download) { is_download_ = download; } | 142 void set_is_download(bool download) { is_download_ = download; } |
| 152 | 143 |
| 153 // Whether this is a stream. | 144 // Whether this is a stream. |
| 154 bool is_stream() const { return is_stream_; } | 145 bool is_stream() const { return is_stream_; } |
| 155 void set_is_stream(bool stream) { is_stream_ = stream; } | 146 void set_is_stream(bool stream) { is_stream_ = stream; } |
| 156 | 147 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 } | 182 } |
| 192 void set_initiated_in_secure_context_for_testing(bool secure) { | 183 void set_initiated_in_secure_context_for_testing(bool secure) { |
| 193 initiated_in_secure_context_ = secure; | 184 initiated_in_secure_context_ = secure; |
| 194 } | 185 } |
| 195 | 186 |
| 196 void set_navigation_ui_data( | 187 void set_navigation_ui_data( |
| 197 std::unique_ptr<NavigationUIData> navigation_ui_data) { | 188 std::unique_ptr<NavigationUIData> navigation_ui_data) { |
| 198 navigation_ui_data_ = std::move(navigation_ui_data); | 189 navigation_ui_data_ = std::move(navigation_ui_data); |
| 199 } | 190 } |
| 200 | 191 |
| 201 // PlzNavigate: used in navigations to store the ServiceWorkerContext, since | |
| 202 // the ResourceMessageFilter will be null in this case. All other requests | |
| 203 // should access the ServiceWorkerContext through the ResourceMessageFilter. | |
| 204 void set_service_worker_context( | |
| 205 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) { | |
| 206 service_worker_context_ = service_worker_context; | |
| 207 } | |
| 208 ServiceWorkerContextWrapper* service_worker_context() const { | |
| 209 return service_worker_context_.get(); | |
| 210 } | |
| 211 | |
| 212 private: | 192 private: |
| 213 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 193 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 214 DeletedFilterDetached); | 194 DeletedFilterDetached); |
| 215 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 195 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 216 DeletedFilterDetachedRedirect); | 196 DeletedFilterDetachedRedirect); |
| 217 // Non-owning, may be NULL. | 197 // Non-owning, may be NULL. |
| 218 DetachableResourceHandler* detachable_handler_; | 198 DetachableResourceHandler* detachable_handler_; |
| 219 | 199 |
| 220 int process_type_; | 200 scoped_refptr<ResourceRequesterInfo> requester_info_; |
|
mmenke
2016/11/21 19:51:55
Can this be scoped_refptr<const ResourceRequesterI
horo
2016/11/22 01:12:07
Reflecting on kinuko's opinion, I changed Resource
| |
| 221 int child_id_; | |
| 222 int route_id_; | 201 int route_id_; |
| 223 const int frame_tree_node_id_; | 202 const int frame_tree_node_id_; |
| 224 int origin_pid_; | 203 int origin_pid_; |
| 225 int request_id_; | 204 int request_id_; |
| 226 int render_frame_id_; | 205 int render_frame_id_; |
| 227 bool is_main_frame_; | 206 bool is_main_frame_; |
| 228 bool parent_is_main_frame_; | 207 bool parent_is_main_frame_; |
| 229 bool should_replace_current_entry_; | 208 bool should_replace_current_entry_; |
| 230 bool is_download_; | 209 bool is_download_; |
| 231 bool is_stream_; | 210 bool is_stream_; |
| 232 bool allow_download_; | 211 bool allow_download_; |
| 233 bool has_user_gesture_; | 212 bool has_user_gesture_; |
| 234 bool enable_load_timing_; | 213 bool enable_load_timing_; |
| 235 bool enable_upload_progress_; | 214 bool enable_upload_progress_; |
| 236 bool do_not_prompt_for_login_; | 215 bool do_not_prompt_for_login_; |
| 237 bool was_ignored_by_handler_; | 216 bool was_ignored_by_handler_; |
| 238 bool counted_as_in_flight_request_; | 217 bool counted_as_in_flight_request_; |
| 239 ResourceType resource_type_; | 218 ResourceType resource_type_; |
| 240 ui::PageTransition transition_type_; | 219 ui::PageTransition transition_type_; |
| 241 int memory_cost_; | 220 int memory_cost_; |
| 242 blink::WebReferrerPolicy referrer_policy_; | 221 blink::WebReferrerPolicy referrer_policy_; |
| 243 blink::WebPageVisibilityState visibility_state_; | 222 blink::WebPageVisibilityState visibility_state_; |
| 244 ResourceContext* context_; | 223 ResourceContext* context_; |
| 245 // The filter might be deleted without deleting this object if the process | |
| 246 // exits during a transfer. | |
| 247 base::WeakPtr<ResourceMessageFilter> filter_; | |
| 248 bool report_raw_headers_; | 224 bool report_raw_headers_; |
| 249 bool is_async_; | 225 bool is_async_; |
| 250 bool is_using_lofi_; | 226 bool is_using_lofi_; |
| 251 const std::string original_headers_; | 227 const std::string original_headers_; |
| 252 scoped_refptr<ResourceRequestBodyImpl> body_; | 228 scoped_refptr<ResourceRequestBodyImpl> body_; |
| 253 bool initiated_in_secure_context_; | 229 bool initiated_in_secure_context_; |
| 254 std::unique_ptr<NavigationUIData> navigation_ui_data_; | 230 std::unique_ptr<NavigationUIData> navigation_ui_data_; |
| 255 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | |
| 256 | 231 |
| 257 DISALLOW_COPY_AND_ASSIGN(ResourceRequestInfoImpl); | 232 DISALLOW_COPY_AND_ASSIGN(ResourceRequestInfoImpl); |
| 258 }; | 233 }; |
| 259 | 234 |
| 260 } // namespace content | 235 } // namespace content |
| 261 | 236 |
| 262 #endif // CONTENT_BROWSER_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ | 237 #endif // CONTENT_BROWSER_LOADER_RESOURCE_REQUEST_INFO_IMPL_H_ |
| OLD | NEW |