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

Side by Side Diff: chrome/browser/renderer_host/resource_dispatcher_host.cc

Issue 7276: Adding security info to canceled requests (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
10 10
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 ResourceHandler* handler) { 195 ResourceHandler* handler) {
196 if (!ResourceType::IsFrame(type) || URLRequest::IsHandledURL(url)) 196 if (!ResourceType::IsFrame(type) || URLRequest::IsHandledURL(url))
197 return false; 197 return false;
198 198
199 ui_loop_->PostTask(FROM_HERE, NewRunnableFunction( 199 ui_loop_->PostTask(FROM_HERE, NewRunnableFunction(
200 &ExternalProtocolHandler::LaunchUrl, url, render_process_host_id, 200 &ExternalProtocolHandler::LaunchUrl, url, render_process_host_id,
201 tab_contents_id)); 201 tab_contents_id));
202 202
203 handler->OnResponseCompleted(request_id, URLRequestStatus( 203 handler->OnResponseCompleted(request_id, URLRequestStatus(
204 URLRequestStatus::FAILED, 204 URLRequestStatus::FAILED,
205 net::ERR_ABORTED)); 205 net::ERR_ABORTED),
206 std::string()); // No security info necessary.
206 return true; 207 return true;
207 } 208 }
208 209
209 void ResourceDispatcherHost::BeginRequest( 210 void ResourceDispatcherHost::BeginRequest(
210 Receiver* receiver, 211 Receiver* receiver,
211 base::ProcessHandle render_process_handle, 212 base::ProcessHandle render_process_handle,
212 int render_process_host_id, 213 int render_process_host_id,
213 int render_view_id, 214 int render_view_id,
214 int request_id, 215 int request_id,
215 const ViewHostMsg_Resource_Request& request_data, 216 const ViewHostMsg_Resource_Request& request_data,
216 URLRequestContext* request_context, 217 URLRequestContext* request_context,
217 IPC::Message* sync_result) { 218 IPC::Message* sync_result) {
218 if (is_shutdown_ || 219 if (is_shutdown_ ||
219 !ShouldServiceRequest(render_process_host_id, request_data)) { 220 !ShouldServiceRequest(render_process_host_id, request_data)) {
220 // Tell the renderer that this request was disallowed. 221 // Tell the renderer that this request was disallowed.
221 receiver->Send(new ViewMsg_Resource_RequestComplete( 222 receiver->Send(new ViewMsg_Resource_RequestComplete(
222 render_view_id, 223 render_view_id,
223 request_id, 224 request_id,
224 URLRequestStatus(URLRequestStatus::FAILED, net::ERR_ABORTED))); 225 URLRequestStatus(URLRequestStatus::FAILED, net::ERR_ABORTED),
226 std::string())); // No security info needed, connection was not
227 // established.
225 return; 228 return;
226 } 229 }
227 230
228 // Ensure the Chrome plugins are loaded, as they may intercept network 231 // Ensure the Chrome plugins are loaded, as they may intercept network
229 // requests. Does nothing if they are already loaded. 232 // requests. Does nothing if they are already loaded.
230 // TODO(mpcomplete): This takes 200 ms! Investigate parallelizing this by 233 // TODO(mpcomplete): This takes 200 ms! Investigate parallelizing this by
231 // starting the load earlier in a BG thread. 234 // starting the load earlier in a BG thread.
232 plugin_service_->LoadChromePlugins(this); 235 plugin_service_->LoadChromePlugins(this);
233 236
234 // Construct the event handler. 237 // Construct the event handler.
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 info->memory_cost = CalculateApproximateMemoryCost(request); 912 info->memory_cost = CalculateApproximateMemoryCost(request);
910 int memory_cost = IncrementOutstandingRequestsMemoryCost( 913 int memory_cost = IncrementOutstandingRequestsMemoryCost(
911 info->memory_cost, 914 info->memory_cost,
912 info->render_process_host_id); 915 info->render_process_host_id);
913 916
914 // If enqueing/starting this request will exceed our per-process memory 917 // If enqueing/starting this request will exceed our per-process memory
915 // bound, abort it right away. 918 // bound, abort it right away.
916 if (memory_cost > max_outstanding_requests_cost_per_process_) { 919 if (memory_cost > max_outstanding_requests_cost_per_process_) {
917 // We call "CancelWithError()" as a way of setting the URLRequest's 920 // We call "CancelWithError()" as a way of setting the URLRequest's
918 // status -- it has no effect beyond this, since the request hasn't started. 921 // status -- it has no effect beyond this, since the request hasn't started.
919 request->CancelWithError(net::ERR_INSUFFICIENT_RESOURCES); 922 request->SimulateError(net::ERR_INSUFFICIENT_RESOURCES);
920 923
921 // TODO(eroman): this is kinda funky -- we insert the unstarted request into 924 // TODO(eroman): this is kinda funky -- we insert the unstarted request into
922 // |pending_requests_| simply to please OnResponseCompleted(). 925 // |pending_requests_| simply to please OnResponseCompleted().
923 GlobalRequestID global_id(info->render_process_host_id, info->request_id); 926 GlobalRequestID global_id(info->render_process_host_id, info->request_id);
924 pending_requests_[global_id] = request; 927 pending_requests_[global_id] = request;
925 OnResponseCompleted(request); 928 OnResponseCompleted(request);
926 return; 929 return;
927 } 930 }
928 931
929 std::pair<int, int> pair_id(info->render_process_host_id, 932 std::pair<int, int> pair_id(info->render_process_host_id,
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 return false; 1114 return false;
1112 } 1115 }
1113 1116
1114 return *bytes_read != 0; 1117 return *bytes_read != 0;
1115 } 1118 }
1116 1119
1117 void ResourceDispatcherHost::OnResponseCompleted(URLRequest* request) { 1120 void ResourceDispatcherHost::OnResponseCompleted(URLRequest* request) {
1118 RESOURCE_LOG("OnResponseCompleted: " << request->url().spec()); 1121 RESOURCE_LOG("OnResponseCompleted: " << request->url().spec());
1119 ExtraRequestInfo* info = ExtraInfoForRequest(request); 1122 ExtraRequestInfo* info = ExtraInfoForRequest(request);
1120 1123
1124 std::string security_info;
1125 const net::SSLInfo& ssl_info = request->ssl_info();
1126 if (ssl_info.cert != NULL) {
1127 int cert_id = CertStore::GetSharedInstance()->
1128 StoreCert(ssl_info.cert, info->render_process_host_id);
1129 security_info = SSLManager::SerializeSecurityInfo(cert_id,
1130 ssl_info.cert_status,
1131 ssl_info.security_bits);
1132 }
1133
1121 if (info->resource_handler->OnResponseCompleted(info->request_id, 1134 if (info->resource_handler->OnResponseCompleted(info->request_id,
1122 request->status())) { 1135 request->status(),
1136 security_info)) {
1123 NotifyResponseCompleted(request, info->render_process_host_id); 1137 NotifyResponseCompleted(request, info->render_process_host_id);
1124 1138
1125 // The request is complete so we can remove it. 1139 // The request is complete so we can remove it.
1126 RemovePendingRequest(info->render_process_host_id, info->request_id); 1140 RemovePendingRequest(info->render_process_host_id, info->request_id);
1127 } 1141 }
1128 // If the handler's OnResponseCompleted returns false, we are deferring the 1142 // If the handler's OnResponseCompleted returns false, we are deferring the
1129 // call until later. We will notify the world and clean up when we resume. 1143 // call until later. We will notify the world and clean up when we resume.
1130 } 1144 }
1131 1145
1132 void ResourceDispatcherHost::AddObserver(Observer* obs) { 1146 void ResourceDispatcherHost::AddObserver(Observer* obs) {
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost, 1436 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost,
1423 info->render_process_host_id); 1437 info->render_process_host_id);
1424 if (cancel_requests) 1438 if (cancel_requests)
1425 delete req_iter->url_request; 1439 delete req_iter->url_request;
1426 else 1440 else
1427 BeginRequestInternal(req_iter->url_request, req_iter->mixed_content); 1441 BeginRequestInternal(req_iter->url_request, req_iter->mixed_content);
1428 } 1442 }
1429 1443
1430 delete requests; 1444 delete requests;
1431 } 1445 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698