| 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_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_REQUEST_INFO_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RESOURCE_REQUEST_INFO_IMPL_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_REQUEST_INFO_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_REQUEST_INFO_IMPL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/supports_user_data.h" | |
| 14 #include "base/time.h" | 13 #include "base/time.h" |
| 15 #include "content/common/content_export.h" | 14 #include "content/public/browser/resource_request_info.h" |
| 16 #include "content/public/common/page_transition_types.h" | 15 #include "content/public/common/page_transition_types.h" |
| 17 #include "content/public/common/process_type.h" | 16 #include "content/public/common/process_type.h" |
| 18 #include "content/public/common/referrer.h" | 17 #include "content/public/common/referrer.h" |
| 19 #include "net/base/load_states.h" | 18 #include "net/base/load_states.h" |
| 20 #include "webkit/glue/resource_type.h" | 19 #include "webkit/glue/resource_type.h" |
| 21 | 20 |
| 22 class ResourceDispatcherHost; | 21 class ResourceDispatcherHost; |
| 23 class ResourceHandler; | 22 class ResourceHandler; |
| 24 class SSLClientAuthHandler; | 23 class SSLClientAuthHandler; |
| 25 | 24 |
| 25 namespace webkit_blob { |
| 26 class BlobData; |
| 27 } |
| 28 |
| 26 namespace content { | 29 namespace content { |
| 27 class CrossSiteResourceHandler; | 30 class CrossSiteResourceHandler; |
| 28 class ResourceContext; | 31 class ResourceContext; |
| 29 class ResourceDispatcherHostLoginDelegate; | 32 class ResourceDispatcherHostLoginDelegate; |
| 30 } | |
| 31 | |
| 32 namespace net { | |
| 33 class URLRequest; | |
| 34 } | |
| 35 | |
| 36 namespace webkit_blob { | |
| 37 class BlobData; | |
| 38 } | |
| 39 | 33 |
| 40 // Holds the data ResourceDispatcherHost associates with each request. | 34 // Holds the data ResourceDispatcherHost associates with each request. |
| 41 // Retrieve this data by calling ResourceDispatcherHost::InfoForRequest. | 35 // Retrieve this data by calling ResourceDispatcherHost::InfoForRequest. |
| 42 class ResourceDispatcherHostRequestInfo : public base::SupportsUserData::Data { | 36 class ResourceRequestInfoImpl : public ResourceRequestInfo { |
| 43 public: | 37 public: |
| 44 // This will take a reference to the handler. | 38 // This will take a reference to the handler. |
| 45 CONTENT_EXPORT ResourceDispatcherHostRequestInfo( | 39 CONTENT_EXPORT ResourceRequestInfoImpl( |
| 46 ResourceHandler* handler, | 40 ResourceHandler* handler, |
| 47 content::ProcessType process_type, | 41 ProcessType process_type, |
| 48 int child_id, | 42 int child_id, |
| 49 int route_id, | 43 int route_id, |
| 50 int origin_pid, | 44 int origin_pid, |
| 51 int request_id, | 45 int request_id, |
| 52 bool is_main_frame, | 46 bool is_main_frame, |
| 53 int64 frame_id, | 47 int64 frame_id, |
| 54 bool parent_is_main_frame, | 48 bool parent_is_main_frame, |
| 55 int64 parent_frame_id, | 49 int64 parent_frame_id, |
| 56 ResourceType::Type resource_type, | 50 ResourceType::Type resource_type, |
| 57 content::PageTransition transition_type, | 51 PageTransition transition_type, |
| 58 uint64 upload_size, | 52 uint64 upload_size, |
| 59 bool is_download, | 53 bool is_download, |
| 60 bool allow_download, | 54 bool allow_download, |
| 61 bool has_user_gesture, | 55 bool has_user_gesture, |
| 62 WebKit::WebReferrerPolicy referrer_policy, | 56 WebKit::WebReferrerPolicy referrer_policy, |
| 63 content::ResourceContext* context); | 57 ResourceContext* context); |
| 64 virtual ~ResourceDispatcherHostRequestInfo(); | 58 virtual ~ResourceRequestInfoImpl(); |
| 59 |
| 60 // ResourceRequestInfo implementation: |
| 61 virtual ResourceContext* GetContext() const OVERRIDE; |
| 62 virtual int GetChildID() const OVERRIDE; |
| 63 virtual int GetRouteID() const OVERRIDE; |
| 64 virtual int GetOriginPID() const OVERRIDE; |
| 65 virtual int GetRequestID() const OVERRIDE; |
| 66 virtual bool IsMainFrame() const OVERRIDE; |
| 67 virtual int64 GetFrameID() const OVERRIDE; |
| 68 virtual bool ParentIsMainFrame() const OVERRIDE; |
| 69 virtual int64 GetParentFrameID() const OVERRIDE; |
| 70 virtual ResourceType::Type GetResourceType() const OVERRIDE; |
| 71 virtual WebKit::WebReferrerPolicy GetReferrerPolicy() const OVERRIDE; |
| 72 virtual uint64 GetUploadSize() const OVERRIDE; |
| 73 virtual bool GetAssociatedRenderView(int* render_process_id, |
| 74 int* render_view_id) const OVERRIDE; |
| 65 | 75 |
| 66 // Top-level ResourceHandler servicing this request. | 76 // Top-level ResourceHandler servicing this request. |
| 67 ResourceHandler* resource_handler() { return resource_handler_.get(); } | 77 ResourceHandler* resource_handler() { return resource_handler_.get(); } |
| 68 void set_resource_handler(ResourceHandler* resource_handler); | 78 void set_resource_handler(ResourceHandler* resource_handler); |
| 69 | 79 |
| 70 // CrossSiteResourceHandler for this request, if it is a cross-site request. | 80 // CrossSiteResourceHandler for this request, if it is a cross-site request. |
| 71 // (NULL otherwise.) This handler is part of the chain of ResourceHandlers | 81 // (NULL otherwise.) This handler is part of the chain of ResourceHandlers |
| 72 // pointed to by resource_handler, and is not owned by this class. | 82 // pointed to by resource_handler, and is not owned by this class. |
| 73 content::CrossSiteResourceHandler* cross_site_handler() { | 83 CrossSiteResourceHandler* cross_site_handler() { |
| 74 return cross_site_handler_; | 84 return cross_site_handler_; |
| 75 } | 85 } |
| 76 void set_cross_site_handler(content::CrossSiteResourceHandler* h) { | 86 void set_cross_site_handler(CrossSiteResourceHandler* h) { |
| 77 cross_site_handler_ = h; | 87 cross_site_handler_ = h; |
| 78 } | 88 } |
| 79 | 89 |
| 80 // Pointer to the login delegate, or NULL if there is none for this request. | 90 // Pointer to the login delegate, or NULL if there is none for this request. |
| 81 content::ResourceDispatcherHostLoginDelegate* login_delegate() const { | 91 ResourceDispatcherHostLoginDelegate* login_delegate() const { |
| 82 return login_delegate_.get(); | 92 return login_delegate_.get(); |
| 83 } | 93 } |
| 84 CONTENT_EXPORT void set_login_delegate( | 94 CONTENT_EXPORT void set_login_delegate( |
| 85 content::ResourceDispatcherHostLoginDelegate* ld); | 95 ResourceDispatcherHostLoginDelegate* ld); |
| 86 | 96 |
| 87 // Pointer to the SSL auth, or NULL if there is none for this request. | 97 // Pointer to the SSL auth, or NULL if there is none for this request. |
| 88 SSLClientAuthHandler* ssl_client_auth_handler() const { | 98 SSLClientAuthHandler* ssl_client_auth_handler() const { |
| 89 return ssl_client_auth_handler_.get(); | 99 return ssl_client_auth_handler_.get(); |
| 90 } | 100 } |
| 91 void set_ssl_client_auth_handler(SSLClientAuthHandler* s); | 101 void set_ssl_client_auth_handler(SSLClientAuthHandler* s); |
| 92 | 102 |
| 93 // Identifies the type of process (renderer, plugin, etc.) making the request. | 103 // Identifies the type of process (renderer, plugin, etc.) making the request. |
| 94 content::ProcessType process_type() const { | 104 ProcessType process_type() const { |
| 95 return process_type_; | 105 return process_type_; |
| 96 } | 106 } |
| 97 | 107 |
| 98 // The child process unique ID of the requestor. This duplicates the value | |
| 99 // stored on the request by SetChildProcessUniqueIDForRequest in | |
| 100 // url_request_tracking. | |
| 101 int child_id() const { return child_id_; } | |
| 102 | |
| 103 // The IPC route identifier for this request (this identifies the RenderView | |
| 104 // or like-thing in the renderer that the request gets routed to). | |
| 105 int route_id() const { return route_id_; } | |
| 106 | |
| 107 // The route_id of pending request can change when it is transferred to a new | 108 // The route_id of pending request can change when it is transferred to a new |
| 108 // page (as in iframe transfer using adoptNode JS API). | 109 // page (as in iframe transfer using adoptNode JS API). |
| 109 void set_route_id(int route_id) { route_id_ = route_id; } | 110 void set_route_id(int route_id) { route_id_ = route_id; } |
| 110 | 111 |
| 111 // The pid of the originating process, if the request is sent on behalf of a | |
| 112 // another process. Otherwise it is 0. | |
| 113 int origin_pid() const { return origin_pid_; } | |
| 114 | |
| 115 // Unique identifier for this resource request. | |
| 116 int request_id() const { return request_id_; } | |
| 117 | |
| 118 // True if |frame_id_| represents a main frame in the RenderView. | |
| 119 bool is_main_frame() const { return is_main_frame_; } | |
| 120 | |
| 121 // Frame ID that sent this resource request. -1 if unknown / invalid. | |
| 122 int64 frame_id() const { return frame_id_; } | |
| 123 | |
| 124 // True if |parent_frame_id_| represents a main frame in the RenderView. | |
| 125 bool parent_is_main_frame() const { return parent_is_main_frame_; } | |
| 126 | |
| 127 // Frame ID of parent frame of frame that sent this resource request. | |
| 128 // -1 if unknown / invalid. | |
| 129 int64 parent_frame_id() const { return parent_frame_id_; } | |
| 130 | |
| 131 // Number of messages we've sent to the renderer that we haven't gotten an | 112 // Number of messages we've sent to the renderer that we haven't gotten an |
| 132 // ACK for. This allows us to avoid having too many messages in flight. | 113 // ACK for. This allows us to avoid having too many messages in flight. |
| 133 int pending_data_count() const { return pending_data_count_; } | 114 int pending_data_count() const { return pending_data_count_; } |
| 134 void IncrementPendingDataCount() { pending_data_count_++; } | 115 void IncrementPendingDataCount() { pending_data_count_++; } |
| 135 void DecrementPendingDataCount() { pending_data_count_--; } | 116 void DecrementPendingDataCount() { pending_data_count_--; } |
| 136 | 117 |
| 137 // Downloads are allowed only as a top level request. | 118 // Downloads are allowed only as a top level request. |
| 138 bool allow_download() const { return allow_download_; } | 119 bool allow_download() const { return allow_download_; } |
| 139 | 120 |
| 140 bool has_user_gesture() const { return has_user_gesture_; } | 121 bool has_user_gesture() const { return has_user_gesture_; } |
| 141 | 122 |
| 142 // Whether this is a download. | 123 // Whether this is a download. |
| 143 bool is_download() const { return is_download_; } | 124 bool is_download() const { return is_download_; } |
| 144 void set_is_download(bool download) { is_download_ = download; } | 125 void set_is_download(bool download) { is_download_ = download; } |
| 145 | 126 |
| 146 // The number of clients that have called pause on this request. | 127 // The number of clients that have called pause on this request. |
| 147 int pause_count() const { return pause_count_; } | 128 int pause_count() const { return pause_count_; } |
| 148 void set_pause_count(int count) { pause_count_ = count; } | 129 void set_pause_count(int count) { pause_count_ = count; } |
| 149 | 130 |
| 150 // Identifies the type of resource, such as subframe, media, etc. | 131 PageTransition transition_type() const { return transition_type_; } |
| 151 ResourceType::Type resource_type() const { return resource_type_; } | |
| 152 | 132 |
| 153 content::PageTransition transition_type() const { return transition_type_; } | |
| 154 | |
| 155 // When there is upload data, this is the byte count of that data. When there | |
| 156 // is no upload, this will be 0. | |
| 157 uint64 upload_size() const { return upload_size_; } | |
| 158 void set_upload_size(uint64 upload_size) { upload_size_ = upload_size; } | 133 void set_upload_size(uint64 upload_size) { upload_size_ = upload_size; } |
| 159 | 134 |
| 160 // When we're uploading data, this is the the byte offset into the uploaded | 135 // When we're uploading data, this is the the byte offset into the uploaded |
| 161 // data that we've uploaded that we've send an upload progress update about. | 136 // data that we've uploaded that we've send an upload progress update about. |
| 162 // The ResourceDispatcherHost will periodically update this value to track | 137 // The ResourceDispatcherHost will periodically update this value to track |
| 163 // upload progress and make sure it doesn't sent out duplicate updates. | 138 // upload progress and make sure it doesn't sent out duplicate updates. |
| 164 uint64 last_upload_position() const { return last_upload_position_; } | 139 uint64 last_upload_position() const { return last_upload_position_; } |
| 165 void set_last_upload_position(uint64 p) { last_upload_position_ = p; } | 140 void set_last_upload_position(uint64 p) { last_upload_position_ = p; } |
| 166 | 141 |
| 167 // Indicates when the ResourceDispatcherHost last update the upload | 142 // Indicates when the ResourceDispatcherHost last update the upload |
| (...skipping 16 matching lines...) Expand all Loading... |
| 184 int memory_cost() const { return memory_cost_; } | 159 int memory_cost() const { return memory_cost_; } |
| 185 void set_memory_cost(int cost) { memory_cost_ = cost; } | 160 void set_memory_cost(int cost) { memory_cost_ = cost; } |
| 186 | 161 |
| 187 // We hold a reference to the requested blob data to ensure it doesn't | 162 // We hold a reference to the requested blob data to ensure it doesn't |
| 188 // get finally released prior to the net::URLRequestJob being started. | 163 // get finally released prior to the net::URLRequestJob being started. |
| 189 webkit_blob::BlobData* requested_blob_data() const { | 164 webkit_blob::BlobData* requested_blob_data() const { |
| 190 return requested_blob_data_.get(); | 165 return requested_blob_data_.get(); |
| 191 } | 166 } |
| 192 void set_requested_blob_data(webkit_blob::BlobData* data); | 167 void set_requested_blob_data(webkit_blob::BlobData* data); |
| 193 | 168 |
| 194 WebKit::WebReferrerPolicy referrer_policy() const { return referrer_policy_; } | |
| 195 | |
| 196 content::ResourceContext* context() const { return context_; } | |
| 197 | |
| 198 private: | 169 private: |
| 199 friend class ResourceDispatcherHost; | 170 friend class ::ResourceDispatcherHost; |
| 200 | 171 |
| 201 // Request is temporarily not handling network data. Should be used only | 172 // Request is temporarily not handling network data. Should be used only |
| 202 // by the ResourceDispatcherHost, not the event handlers (accessors are | 173 // by the ResourceDispatcherHost, not the event handlers (accessors are |
| 203 // provided for consistency with the rest of the interface). | 174 // provided for consistency with the rest of the interface). |
| 204 bool is_paused() const { return is_paused_; } | 175 bool is_paused() const { return is_paused_; } |
| 205 void set_is_paused(bool paused) { is_paused_ = paused; } | 176 void set_is_paused(bool paused) { is_paused_ = paused; } |
| 206 | 177 |
| 207 // Whether we called OnResponseStarted for this request or not. Should be used | 178 // Whether we called OnResponseStarted for this request or not. Should be used |
| 208 // only by the ResourceDispatcherHost, not the event handlers (accessors are | 179 // only by the ResourceDispatcherHost, not the event handlers (accessors are |
| 209 // provided for consistency with the rest of the interface). | 180 // provided for consistency with the rest of the interface). |
| (...skipping 13 matching lines...) Expand all Loading... |
| 223 | 194 |
| 224 // How many bytes have been read while this request has been paused. Should be | 195 // How many bytes have been read while this request has been paused. Should be |
| 225 // used only by the ResourceDispatcherHost, not the event handlers (accessors | 196 // used only by the ResourceDispatcherHost, not the event handlers (accessors |
| 226 // are provided for consistency with the rest of the interface). | 197 // are provided for consistency with the rest of the interface). |
| 227 int paused_read_bytes() const { return paused_read_bytes_; } | 198 int paused_read_bytes() const { return paused_read_bytes_; } |
| 228 void set_paused_read_bytes(int bytes) { paused_read_bytes_ = bytes; } | 199 void set_paused_read_bytes(int bytes) { paused_read_bytes_ = bytes; } |
| 229 | 200 |
| 230 scoped_refptr<ResourceHandler> resource_handler_; | 201 scoped_refptr<ResourceHandler> resource_handler_; |
| 231 | 202 |
| 232 // Non-owning, may be NULL. | 203 // Non-owning, may be NULL. |
| 233 content::CrossSiteResourceHandler* cross_site_handler_; | 204 CrossSiteResourceHandler* cross_site_handler_; |
| 234 | 205 |
| 235 scoped_refptr<content::ResourceDispatcherHostLoginDelegate> login_delegate_; | 206 scoped_refptr<ResourceDispatcherHostLoginDelegate> login_delegate_; |
| 236 scoped_refptr<SSLClientAuthHandler> ssl_client_auth_handler_; | 207 scoped_refptr<SSLClientAuthHandler> ssl_client_auth_handler_; |
| 237 content::ProcessType process_type_; | 208 ProcessType process_type_; |
| 238 int child_id_; | 209 int child_id_; |
| 239 int route_id_; | 210 int route_id_; |
| 240 int origin_pid_; | 211 int origin_pid_; |
| 241 int request_id_; | 212 int request_id_; |
| 242 bool is_main_frame_; | 213 bool is_main_frame_; |
| 243 int64 frame_id_; | 214 int64 frame_id_; |
| 244 bool parent_is_main_frame_; | 215 bool parent_is_main_frame_; |
| 245 int64 parent_frame_id_; | 216 int64 parent_frame_id_; |
| 246 int pending_data_count_; | 217 int pending_data_count_; |
| 247 bool is_download_; | 218 bool is_download_; |
| 248 bool allow_download_; | 219 bool allow_download_; |
| 249 bool has_user_gesture_; | 220 bool has_user_gesture_; |
| 250 int pause_count_; | 221 int pause_count_; |
| 251 ResourceType::Type resource_type_; | 222 ResourceType::Type resource_type_; |
| 252 content::PageTransition transition_type_; | 223 PageTransition transition_type_; |
| 253 uint64 upload_size_; | 224 uint64 upload_size_; |
| 254 uint64 last_upload_position_; | 225 uint64 last_upload_position_; |
| 255 base::TimeTicks last_upload_ticks_; | 226 base::TimeTicks last_upload_ticks_; |
| 256 bool waiting_for_upload_progress_ack_; | 227 bool waiting_for_upload_progress_ack_; |
| 257 int memory_cost_; | 228 int memory_cost_; |
| 258 scoped_refptr<webkit_blob::BlobData> requested_blob_data_; | 229 scoped_refptr<webkit_blob::BlobData> requested_blob_data_; |
| 259 WebKit::WebReferrerPolicy referrer_policy_; | 230 WebKit::WebReferrerPolicy referrer_policy_; |
| 260 content::ResourceContext* context_; | 231 ResourceContext* context_; |
| 261 | 232 |
| 262 // "Private" data accessible only to ResourceDispatcherHost (use the | 233 // "Private" data accessible only to ResourceDispatcherHost (use the |
| 263 // accessors above for consistency). | 234 // accessors above for consistency). |
| 264 bool is_paused_; | 235 bool is_paused_; |
| 265 bool called_on_response_started_; | 236 bool called_on_response_started_; |
| 266 bool has_started_reading_; | 237 bool has_started_reading_; |
| 267 int paused_read_bytes_; | 238 int paused_read_bytes_; |
| 268 | 239 |
| 269 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostRequestInfo); | 240 DISALLOW_COPY_AND_ASSIGN(ResourceRequestInfoImpl); |
| 270 }; | 241 }; |
| 271 | 242 |
| 272 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_REQUEST_INFO_H
_ | 243 } // namespace content |
| 244 |
| 245 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_REQUEST_INFO_IMPL_H_ |
| OLD | NEW |