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

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

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 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" 5 #include "content/browser/renderer_host/resource_request_info_impl.h"
6 6
7 #include "content/browser/renderer_host/resource_handler.h" 7 #include "content/browser/renderer_host/resource_handler.h"
8 #include "content/browser/ssl/ssl_client_auth_handler.h" 8 #include "content/browser/ssl/ssl_client_auth_handler.h"
9 #include "content/browser/worker_host/worker_service_impl.h"
9 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" 10 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
10 #include "net/url_request/url_request.h" 11 #include "net/url_request/url_request.h"
11 #include "webkit/blob/blob_data.h" 12 #include "webkit/blob/blob_data.h"
12 13
13 ResourceDispatcherHostRequestInfo::ResourceDispatcherHostRequestInfo( 14 namespace content {
15
16 // static
17 const ResourceRequestInfo* ResourceRequestInfo::ForRequest(
18 const net::URLRequest* request) {
19 return static_cast<const ResourceRequestInfo*>(request->GetUserData(NULL));
20 }
21
22 // static
23 void ResourceRequestInfo::DecorateForTesting(
24 net::URLRequest* request,
25 ResourceContext* context) {
26 request->SetUserData(
27 NULL,
28 new ResourceRequestInfoImpl(
29 NULL, // handler
30 PROCESS_TYPE_RENDERER, // process_type
31 -1, // child_id
32 MSG_ROUTING_NONE, // route_id
33 0, // origin_pid
34 0, // request_id
35 true, // is_main_frame
36 0, // frame_id
37 false, // parent_is_main_frame
38 0, // parent_frame_id
39 ResourceType::MAIN_FRAME, // resource_type
40 PAGE_TRANSITION_LINK, // transition_type
41 0, // upload_size
42 false, // is_download
43 true, // allow_download
44 false, // has_user_gesture
45 WebKit::WebReferrerPolicyDefault, // referrer_policy
46 context)); // context
47 }
48
49 ResourceRequestInfoImpl::ResourceRequestInfoImpl(
14 ResourceHandler* handler, 50 ResourceHandler* handler,
15 content::ProcessType process_type, 51 ProcessType process_type,
16 int child_id, 52 int child_id,
17 int route_id, 53 int route_id,
18 int origin_pid, 54 int origin_pid,
19 int request_id, 55 int request_id,
20 bool is_main_frame, 56 bool is_main_frame,
21 int64 frame_id, 57 int64 frame_id,
22 bool parent_is_main_frame, 58 bool parent_is_main_frame,
23 int64 parent_frame_id, 59 int64 parent_frame_id,
24 ResourceType::Type resource_type, 60 ResourceType::Type resource_type,
25 content::PageTransition transition_type, 61 PageTransition transition_type,
26 uint64 upload_size, 62 uint64 upload_size,
27 bool is_download, 63 bool is_download,
28 bool allow_download, 64 bool allow_download,
29 bool has_user_gesture, 65 bool has_user_gesture,
30 WebKit::WebReferrerPolicy referrer_policy, 66 WebKit::WebReferrerPolicy referrer_policy,
31 content::ResourceContext* context) 67 ResourceContext* context)
32 : resource_handler_(handler), 68 : resource_handler_(handler),
33 cross_site_handler_(NULL), 69 cross_site_handler_(NULL),
34 process_type_(process_type), 70 process_type_(process_type),
35 child_id_(child_id), 71 child_id_(child_id),
36 route_id_(route_id), 72 route_id_(route_id),
37 origin_pid_(origin_pid), 73 origin_pid_(origin_pid),
38 request_id_(request_id), 74 request_id_(request_id),
39 is_main_frame_(is_main_frame), 75 is_main_frame_(is_main_frame),
40 frame_id_(frame_id), 76 frame_id_(frame_id),
41 parent_is_main_frame_(parent_is_main_frame), 77 parent_is_main_frame_(parent_is_main_frame),
(...skipping 10 matching lines...) Expand all
52 waiting_for_upload_progress_ack_(false), 88 waiting_for_upload_progress_ack_(false),
53 memory_cost_(0), 89 memory_cost_(0),
54 referrer_policy_(referrer_policy), 90 referrer_policy_(referrer_policy),
55 context_(context), 91 context_(context),
56 is_paused_(false), 92 is_paused_(false),
57 called_on_response_started_(false), 93 called_on_response_started_(false),
58 has_started_reading_(false), 94 has_started_reading_(false),
59 paused_read_bytes_(0) { 95 paused_read_bytes_(0) {
60 } 96 }
61 97
62 ResourceDispatcherHostRequestInfo::~ResourceDispatcherHostRequestInfo() { 98 ResourceRequestInfoImpl::~ResourceRequestInfoImpl() {
63 resource_handler_->OnRequestClosed(); 99 if (resource_handler_)
100 resource_handler_->OnRequestClosed();
64 } 101 }
65 102
66 void ResourceDispatcherHostRequestInfo::set_resource_handler( 103 ResourceContext* ResourceRequestInfoImpl::GetContext() const {
104 return context_;
105 }
106
107 int ResourceRequestInfoImpl::GetChildID() const {
108 return child_id_;
109 }
110
111 int ResourceRequestInfoImpl::GetRouteID() const {
112 return route_id_;
113 }
114
115 int ResourceRequestInfoImpl::GetOriginPID() const {
116 return origin_pid_;
117 }
118
119 int ResourceRequestInfoImpl::GetRequestID() const {
120 return request_id_;
121 }
122
123 bool ResourceRequestInfoImpl::IsMainFrame() const {
124 return is_main_frame_;
125 }
126
127 int64 ResourceRequestInfoImpl::GetFrameID() const {
128 return frame_id_;
129 }
130
131 bool ResourceRequestInfoImpl::ParentIsMainFrame() const {
132 return parent_is_main_frame_;
133 }
134
135 int64 ResourceRequestInfoImpl::GetParentFrameID() const {
136 return parent_frame_id_;
137 }
138
139 ResourceType::Type ResourceRequestInfoImpl::GetResourceType() const {
140 return resource_type_;
141 }
142
143 WebKit::WebReferrerPolicy ResourceRequestInfoImpl::GetReferrerPolicy() const {
144 return referrer_policy_;
145 }
146
147 uint64 ResourceRequestInfoImpl::GetUploadSize() const {
148 return upload_size_;
149 }
150
151 bool ResourceRequestInfoImpl::GetAssociatedRenderView(
152 int* render_process_id,
153 int* render_view_id) const {
154 // If the request is from the worker process, find a tab that owns the worker.
155 if (process_type_ == PROCESS_TYPE_WORKER) {
156 // Need to display some related UI for this network request - pick an
157 // arbitrary parent to do so.
158 if (!WorkerServiceImpl::GetInstance()->GetRendererForWorker(
159 child_id_, render_process_id, render_view_id)) {
160 *render_process_id = -1;
161 *render_view_id = -1;
162 return false;
163 }
164 } else {
165 *render_process_id = child_id_;
166 *render_view_id = route_id_;
167 }
168 return true;
169 }
170
171 void ResourceRequestInfoImpl::set_resource_handler(
67 ResourceHandler* resource_handler) { 172 ResourceHandler* resource_handler) {
68 resource_handler_ = resource_handler; 173 resource_handler_ = resource_handler;
69 } 174 }
70 175
71 void ResourceDispatcherHostRequestInfo::set_login_delegate( 176 void ResourceRequestInfoImpl::set_login_delegate(
72 content::ResourceDispatcherHostLoginDelegate* ld) { 177 ResourceDispatcherHostLoginDelegate* ld) {
73 login_delegate_ = ld; 178 login_delegate_ = ld;
74 } 179 }
75 180
76 void ResourceDispatcherHostRequestInfo::set_ssl_client_auth_handler( 181 void ResourceRequestInfoImpl::set_ssl_client_auth_handler(
77 SSLClientAuthHandler* s) { 182 SSLClientAuthHandler* s) {
78 ssl_client_auth_handler_ = s; 183 ssl_client_auth_handler_ = s;
79 } 184 }
80 185
81 void ResourceDispatcherHostRequestInfo::set_requested_blob_data( 186 void ResourceRequestInfoImpl::set_requested_blob_data(
82 webkit_blob::BlobData* data) { 187 webkit_blob::BlobData* data) {
83 requested_blob_data_ = data; 188 requested_blob_data_ = data;
84 } 189 }
190
191 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698