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

Side by Side Diff: content/browser/renderer_host/resource_request_info_impl.h

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

Powered by Google App Engine
This is Rietveld 408576698