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_DISPATCHER_HOST_REQUEST_INFO_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_REQUEST_INFO_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_REQUEST_INFO_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 |
26 namespace content { | 25 namespace content { |
27 class CrossSiteResourceHandler; | 26 class CrossSiteResourceHandler; |
28 class ResourceContext; | 27 class ResourceContext; |
29 class ResourceDispatcherHostLoginDelegate; | 28 class ResourceDispatcherHostLoginDelegate; |
30 } | 29 } |
31 | 30 |
32 namespace net { | 31 namespace net { |
33 class URLRequest; | 32 class URLRequest; |
34 } | 33 } |
35 | 34 |
36 namespace webkit_blob { | 35 namespace webkit_blob { |
37 class BlobData; | 36 class BlobData; |
38 } | 37 } |
39 | 38 |
40 // Holds the data ResourceDispatcherHost associates with each request. | 39 // Holds the data ResourceDispatcherHost associates with each request. |
41 // Retrieve this data by calling ResourceDispatcherHost::InfoForRequest. | 40 // Retrieve this data by calling ResourceDispatcherHost::InfoForRequest. |
42 class ResourceDispatcherHostRequestInfo : public base::SupportsUserData::Data { | 41 class ResourceDispatcherHostRequestInfo : public content::ResourceRequestInfo { |
43 public: | 42 public: |
44 // This will take a reference to the handler. | 43 // This will take a reference to the handler. |
45 CONTENT_EXPORT ResourceDispatcherHostRequestInfo( | 44 CONTENT_EXPORT ResourceDispatcherHostRequestInfo( |
46 ResourceHandler* handler, | 45 ResourceHandler* handler, |
47 content::ProcessType process_type, | 46 content::ProcessType process_type, |
48 int child_id, | 47 int child_id, |
49 int route_id, | 48 int route_id, |
50 int origin_pid, | 49 int origin_pid, |
51 int request_id, | 50 int request_id, |
52 bool is_main_frame, | 51 bool is_main_frame, |
53 int64 frame_id, | 52 int64 frame_id, |
54 bool parent_is_main_frame, | 53 bool parent_is_main_frame, |
55 int64 parent_frame_id, | 54 int64 parent_frame_id, |
56 ResourceType::Type resource_type, | 55 ResourceType::Type resource_type, |
57 content::PageTransition transition_type, | 56 content::PageTransition transition_type, |
58 uint64 upload_size, | 57 uint64 upload_size, |
59 bool is_download, | 58 bool is_download, |
60 bool allow_download, | 59 bool allow_download, |
61 bool has_user_gesture, | 60 bool has_user_gesture, |
62 WebKit::WebReferrerPolicy referrer_policy, | 61 WebKit::WebReferrerPolicy referrer_policy, |
63 content::ResourceContext* context); | 62 content::ResourceContext* context); |
64 virtual ~ResourceDispatcherHostRequestInfo(); | 63 virtual ~ResourceDispatcherHostRequestInfo(); |
65 | 64 |
| 65 // ResourceRequestInfo implementation: |
| 66 virtual bool GetAssociatedRenderView(int* render_process_id, |
| 67 int* render_view_id) const OVERRIDE; |
| 68 |
66 // Top-level ResourceHandler servicing this request. | 69 // Top-level ResourceHandler servicing this request. |
67 ResourceHandler* resource_handler() { return resource_handler_.get(); } | 70 ResourceHandler* resource_handler() { return resource_handler_.get(); } |
68 void set_resource_handler(ResourceHandler* resource_handler); | 71 void set_resource_handler(ResourceHandler* resource_handler); |
69 | 72 |
70 // CrossSiteResourceHandler for this request, if it is a cross-site request. | 73 // CrossSiteResourceHandler for this request, if it is a cross-site request. |
71 // (NULL otherwise.) This handler is part of the chain of ResourceHandlers | 74 // (NULL otherwise.) This handler is part of the chain of ResourceHandlers |
72 // pointed to by resource_handler, and is not owned by this class. | 75 // pointed to by resource_handler, and is not owned by this class. |
73 content::CrossSiteResourceHandler* cross_site_handler() { | 76 content::CrossSiteResourceHandler* cross_site_handler() { |
74 return cross_site_handler_; | 77 return cross_site_handler_; |
75 } | 78 } |
(...skipping 12 matching lines...) Expand all Loading... |
88 SSLClientAuthHandler* ssl_client_auth_handler() const { | 91 SSLClientAuthHandler* ssl_client_auth_handler() const { |
89 return ssl_client_auth_handler_.get(); | 92 return ssl_client_auth_handler_.get(); |
90 } | 93 } |
91 void set_ssl_client_auth_handler(SSLClientAuthHandler* s); | 94 void set_ssl_client_auth_handler(SSLClientAuthHandler* s); |
92 | 95 |
93 // Identifies the type of process (renderer, plugin, etc.) making the request. | 96 // Identifies the type of process (renderer, plugin, etc.) making the request. |
94 content::ProcessType process_type() const { | 97 content::ProcessType process_type() const { |
95 return process_type_; | 98 return process_type_; |
96 } | 99 } |
97 | 100 |
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 | 101 // 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). | 102 // page (as in iframe transfer using adoptNode JS API). |
109 void set_route_id(int route_id) { route_id_ = route_id; } | 103 void set_route_id(int route_id) { route_id_ = route_id; } |
110 | 104 |
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 | 105 // 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. | 106 // ACK for. This allows us to avoid having too many messages in flight. |
133 int pending_data_count() const { return pending_data_count_; } | 107 int pending_data_count() const { return pending_data_count_; } |
134 void IncrementPendingDataCount() { pending_data_count_++; } | 108 void IncrementPendingDataCount() { pending_data_count_++; } |
135 void DecrementPendingDataCount() { pending_data_count_--; } | 109 void DecrementPendingDataCount() { pending_data_count_--; } |
136 | 110 |
137 // Downloads are allowed only as a top level request. | 111 // Downloads are allowed only as a top level request. |
138 bool allow_download() const { return allow_download_; } | 112 bool allow_download() const { return allow_download_; } |
139 | 113 |
140 bool has_user_gesture() const { return has_user_gesture_; } | 114 bool has_user_gesture() const { return has_user_gesture_; } |
141 | 115 |
142 // Whether this is a download. | 116 // Whether this is a download. |
143 bool is_download() const { return is_download_; } | 117 bool is_download() const { return is_download_; } |
144 void set_is_download(bool download) { is_download_ = download; } | 118 void set_is_download(bool download) { is_download_ = download; } |
145 | 119 |
146 // The number of clients that have called pause on this request. | 120 // The number of clients that have called pause on this request. |
147 int pause_count() const { return pause_count_; } | 121 int pause_count() const { return pause_count_; } |
148 void set_pause_count(int count) { pause_count_ = count; } | 122 void set_pause_count(int count) { pause_count_ = count; } |
149 | 123 |
150 // Identifies the type of resource, such as subframe, media, etc. | |
151 ResourceType::Type resource_type() const { return resource_type_; } | |
152 | |
153 content::PageTransition transition_type() const { return transition_type_; } | 124 content::PageTransition transition_type() const { return transition_type_; } |
154 | 125 |
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; } | 126 void set_upload_size(uint64 upload_size) { upload_size_ = upload_size; } |
159 | 127 |
160 // When we're uploading data, this is the the byte offset into the uploaded | 128 // 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. | 129 // data that we've uploaded that we've send an upload progress update about. |
162 // The ResourceDispatcherHost will periodically update this value to track | 130 // The ResourceDispatcherHost will periodically update this value to track |
163 // upload progress and make sure it doesn't sent out duplicate updates. | 131 // upload progress and make sure it doesn't sent out duplicate updates. |
164 uint64 last_upload_position() const { return last_upload_position_; } | 132 uint64 last_upload_position() const { return last_upload_position_; } |
165 void set_last_upload_position(uint64 p) { last_upload_position_ = p; } | 133 void set_last_upload_position(uint64 p) { last_upload_position_ = p; } |
166 | 134 |
167 // Indicates when the ResourceDispatcherHost last update the upload | 135 // Indicates when the ResourceDispatcherHost last update the upload |
(...skipping 16 matching lines...) Expand all Loading... |
184 int memory_cost() const { return memory_cost_; } | 152 int memory_cost() const { return memory_cost_; } |
185 void set_memory_cost(int cost) { memory_cost_ = cost; } | 153 void set_memory_cost(int cost) { memory_cost_ = cost; } |
186 | 154 |
187 // We hold a reference to the requested blob data to ensure it doesn't | 155 // 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. | 156 // get finally released prior to the net::URLRequestJob being started. |
189 webkit_blob::BlobData* requested_blob_data() const { | 157 webkit_blob::BlobData* requested_blob_data() const { |
190 return requested_blob_data_.get(); | 158 return requested_blob_data_.get(); |
191 } | 159 } |
192 void set_requested_blob_data(webkit_blob::BlobData* data); | 160 void set_requested_blob_data(webkit_blob::BlobData* data); |
193 | 161 |
194 WebKit::WebReferrerPolicy referrer_policy() const { return referrer_policy_; } | |
195 | |
196 content::ResourceContext* context() const { return context_; } | |
197 | |
198 private: | 162 private: |
199 friend class ResourceDispatcherHost; | 163 friend class ResourceDispatcherHost; |
200 | 164 |
201 // Request is temporarily not handling network data. Should be used only | 165 // Request is temporarily not handling network data. Should be used only |
202 // by the ResourceDispatcherHost, not the event handlers (accessors are | 166 // by the ResourceDispatcherHost, not the event handlers (accessors are |
203 // provided for consistency with the rest of the interface). | 167 // provided for consistency with the rest of the interface). |
204 bool is_paused() const { return is_paused_; } | 168 bool is_paused() const { return is_paused_; } |
205 void set_is_paused(bool paused) { is_paused_ = paused; } | 169 void set_is_paused(bool paused) { is_paused_ = paused; } |
206 | 170 |
207 // Whether we called OnResponseStarted for this request or not. Should be used | 171 // Whether we called OnResponseStarted for this request or not. Should be used |
(...skipping 20 matching lines...) Expand all Loading... |
228 void set_paused_read_bytes(int bytes) { paused_read_bytes_ = bytes; } | 192 void set_paused_read_bytes(int bytes) { paused_read_bytes_ = bytes; } |
229 | 193 |
230 scoped_refptr<ResourceHandler> resource_handler_; | 194 scoped_refptr<ResourceHandler> resource_handler_; |
231 | 195 |
232 // Non-owning, may be NULL. | 196 // Non-owning, may be NULL. |
233 content::CrossSiteResourceHandler* cross_site_handler_; | 197 content::CrossSiteResourceHandler* cross_site_handler_; |
234 | 198 |
235 scoped_refptr<content::ResourceDispatcherHostLoginDelegate> login_delegate_; | 199 scoped_refptr<content::ResourceDispatcherHostLoginDelegate> login_delegate_; |
236 scoped_refptr<SSLClientAuthHandler> ssl_client_auth_handler_; | 200 scoped_refptr<SSLClientAuthHandler> ssl_client_auth_handler_; |
237 content::ProcessType process_type_; | 201 content::ProcessType process_type_; |
238 int child_id_; | |
239 int route_id_; | |
240 int origin_pid_; | |
241 int request_id_; | |
242 bool is_main_frame_; | |
243 int64 frame_id_; | |
244 bool parent_is_main_frame_; | |
245 int64 parent_frame_id_; | |
246 int pending_data_count_; | 202 int pending_data_count_; |
247 bool is_download_; | 203 bool is_download_; |
248 bool allow_download_; | 204 bool allow_download_; |
249 bool has_user_gesture_; | 205 bool has_user_gesture_; |
250 int pause_count_; | 206 int pause_count_; |
251 ResourceType::Type resource_type_; | |
252 content::PageTransition transition_type_; | 207 content::PageTransition transition_type_; |
253 uint64 upload_size_; | |
254 uint64 last_upload_position_; | 208 uint64 last_upload_position_; |
255 base::TimeTicks last_upload_ticks_; | 209 base::TimeTicks last_upload_ticks_; |
256 bool waiting_for_upload_progress_ack_; | 210 bool waiting_for_upload_progress_ack_; |
257 int memory_cost_; | 211 int memory_cost_; |
258 scoped_refptr<webkit_blob::BlobData> requested_blob_data_; | 212 scoped_refptr<webkit_blob::BlobData> requested_blob_data_; |
259 WebKit::WebReferrerPolicy referrer_policy_; | |
260 content::ResourceContext* context_; | |
261 | 213 |
262 // "Private" data accessible only to ResourceDispatcherHost (use the | 214 // "Private" data accessible only to ResourceDispatcherHost (use the |
263 // accessors above for consistency). | 215 // accessors above for consistency). |
264 bool is_paused_; | 216 bool is_paused_; |
265 bool called_on_response_started_; | 217 bool called_on_response_started_; |
266 bool has_started_reading_; | 218 bool has_started_reading_; |
267 int paused_read_bytes_; | 219 int paused_read_bytes_; |
268 | 220 |
269 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostRequestInfo); | 221 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostRequestInfo); |
270 }; | 222 }; |
271 | 223 |
272 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_REQUEST_INFO_H
_ | 224 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_REQUEST_INFO_H
_ |
OLD | NEW |