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

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

Issue 46094: Fix our handling of mixed SSL / non-SSL content.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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) 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 "chrome/browser/renderer_host/resource_dispatcher_host.h" 7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // Insert a buffered event handler before the actual one. 316 // Insert a buffered event handler before the actual one.
317 handler = new BufferedResourceHandler(handler, this, request); 317 handler = new BufferedResourceHandler(handler, this, request);
318 318
319 // Make extra info and read footer (contains request ID). 319 // Make extra info and read footer (contains request ID).
320 ExtraRequestInfo* extra_info = 320 ExtraRequestInfo* extra_info =
321 new ExtraRequestInfo(handler, 321 new ExtraRequestInfo(handler,
322 process_type, 322 process_type,
323 process_id, 323 process_id,
324 route_id, 324 route_id,
325 request_id, 325 request_id,
326 request_data.mixed_content, 326 request_data.frame_origin,
327 request_data.main_frame_origin,
327 request_data.resource_type, 328 request_data.resource_type,
328 upload_size); 329 upload_size);
329 extra_info->allow_download = 330 extra_info->allow_download =
330 ResourceType::IsFrame(request_data.resource_type); 331 ResourceType::IsFrame(request_data.resource_type);
331 request->set_user_data(extra_info); // takes pointer ownership 332 request->set_user_data(extra_info); // takes pointer ownership
332 333
333 BeginRequestInternal(request, request_data.mixed_content); 334 BeginRequestInternal(request);
334 } 335 }
335 336
336 // We are explicitly forcing the download of 'url'. 337 // We are explicitly forcing the download of 'url'.
337 void ResourceDispatcherHost::BeginDownload(const GURL& url, 338 void ResourceDispatcherHost::BeginDownload(const GURL& url,
338 const GURL& referrer, 339 const GURL& referrer,
339 int process_id, 340 int process_id,
340 int route_id, 341 int route_id,
341 URLRequestContext* request_context) { 342 URLRequestContext* request_context) {
342 if (is_shutdown_) 343 if (is_shutdown_)
343 return; 344 return;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 request->set_method("GET"); 387 request->set_method("GET");
387 request->set_referrer(referrer.spec()); 388 request->set_referrer(referrer.spec());
388 request->set_context(request_context); 389 request->set_context(request_context);
389 390
390 ExtraRequestInfo* extra_info = 391 ExtraRequestInfo* extra_info =
391 new ExtraRequestInfo(handler, 392 new ExtraRequestInfo(handler,
392 ChildProcessInfo::RENDER_PROCESS, 393 ChildProcessInfo::RENDER_PROCESS,
393 process_id, 394 process_id,
394 route_id, 395 route_id,
395 request_id_, 396 request_id_,
396 false, // Downloads are not considered mixed-content 397 "null", // frame_origin
398 "null", // main_frame_origin
397 ResourceType::SUB_RESOURCE, 399 ResourceType::SUB_RESOURCE,
398 0 /* upload_size */ ); 400 0 /* upload_size */ );
399 extra_info->allow_download = true; 401 extra_info->allow_download = true;
400 extra_info->is_download = true; 402 extra_info->is_download = true;
401 request->set_user_data(extra_info); // Takes pointer ownership. 403 request->set_user_data(extra_info); // Takes pointer ownership.
402 404
403 BeginRequestInternal(request, false); 405 BeginRequestInternal(request);
404 } 406 }
405 407
406 // This function is only used for saving feature. 408 // This function is only used for saving feature.
407 void ResourceDispatcherHost::BeginSaveFile(const GURL& url, 409 void ResourceDispatcherHost::BeginSaveFile(const GURL& url,
408 const GURL& referrer, 410 const GURL& referrer,
409 int process_id, 411 int process_id,
410 int route_id, 412 int route_id,
411 URLRequestContext* request_context) { 413 URLRequestContext* request_context) {
412 if (is_shutdown_) 414 if (is_shutdown_)
413 return; 415 return;
(...skipping 25 matching lines...) Expand all
439 // future, maybe we can use a configuration to configure this behavior. 441 // future, maybe we can use a configuration to configure this behavior.
440 request->set_load_flags(net::LOAD_ONLY_FROM_CACHE); 442 request->set_load_flags(net::LOAD_ONLY_FROM_CACHE);
441 request->set_context(request_context); 443 request->set_context(request_context);
442 444
443 ExtraRequestInfo* extra_info = 445 ExtraRequestInfo* extra_info =
444 new ExtraRequestInfo(handler, 446 new ExtraRequestInfo(handler,
445 ChildProcessInfo::RENDER_PROCESS, 447 ChildProcessInfo::RENDER_PROCESS,
446 process_id, 448 process_id,
447 route_id, 449 route_id,
448 request_id_, 450 request_id_,
449 false, 451 "null", // frame_origin
452 "null", // main_frame_origin
450 ResourceType::SUB_RESOURCE, 453 ResourceType::SUB_RESOURCE,
451 0 /* upload_size */); 454 0 /* upload_size */);
452 // Just saving some resources we need, disallow downloading. 455 // Just saving some resources we need, disallow downloading.
453 extra_info->allow_download = false; 456 extra_info->allow_download = false;
454 extra_info->is_download = false; 457 extra_info->is_download = false;
455 request->set_user_data(extra_info); // Takes pointer ownership. 458 request->set_user_data(extra_info); // Takes pointer ownership.
456 459
457 BeginRequestInternal(request, false); 460 BeginRequestInternal(request);
458 } 461 }
459 462
460 void ResourceDispatcherHost::CancelRequest(int process_id, 463 void ResourceDispatcherHost::CancelRequest(int process_id,
461 int request_id, 464 int request_id,
462 bool from_renderer) { 465 bool from_renderer) {
463 CancelRequest(process_id, request_id, from_renderer, true); 466 CancelRequest(process_id, request_id, from_renderer, true);
464 } 467 }
465 468
466 void ResourceDispatcherHost::CancelRequest(int process_id, 469 void ResourceDispatcherHost::CancelRequest(int process_id,
467 int request_id, 470 int request_id,
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 } 921 }
919 } 922 }
920 } 923 }
921 #endif 924 #endif
922 925
923 // Note that this expression will typically be dominated by: 926 // Note that this expression will typically be dominated by:
924 // |kAvgBytesPerOutstandingRequest|. 927 // |kAvgBytesPerOutstandingRequest|.
925 return kAvgBytesPerOutstandingRequest + strings_cost + upload_cost; 928 return kAvgBytesPerOutstandingRequest + strings_cost + upload_cost;
926 } 929 }
927 930
928 void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request, 931 void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request) {
929 bool mixed_content) {
930 DCHECK(!request->is_pending()); 932 DCHECK(!request->is_pending());
931 ExtraRequestInfo* info = ExtraInfoForRequest(request); 933 ExtraRequestInfo* info = ExtraInfoForRequest(request);
932 934
933 // Add the memory estimate that starting this request will consume. 935 // Add the memory estimate that starting this request will consume.
934 info->memory_cost = CalculateApproximateMemoryCost(request); 936 info->memory_cost = CalculateApproximateMemoryCost(request);
935 int memory_cost = IncrementOutstandingRequestsMemoryCost( 937 int memory_cost = IncrementOutstandingRequestsMemoryCost(
936 info->memory_cost, 938 info->memory_cost,
937 info->process_id); 939 info->process_id);
938 940
939 // If enqueing/starting this request will exceed our per-process memory 941 // If enqueing/starting this request will exceed our per-process memory
940 // bound, abort it right away. 942 // bound, abort it right away.
941 if (memory_cost > max_outstanding_requests_cost_per_process_) { 943 if (memory_cost > max_outstanding_requests_cost_per_process_) {
942 // We call "CancelWithError()" as a way of setting the URLRequest's 944 // We call "CancelWithError()" as a way of setting the URLRequest's
943 // status -- it has no effect beyond this, since the request hasn't started. 945 // status -- it has no effect beyond this, since the request hasn't started.
944 request->SimulateError(net::ERR_INSUFFICIENT_RESOURCES); 946 request->SimulateError(net::ERR_INSUFFICIENT_RESOURCES);
945 947
946 // TODO(eroman): this is kinda funky -- we insert the unstarted request into 948 // TODO(eroman): this is kinda funky -- we insert the unstarted request into
947 // |pending_requests_| simply to please OnResponseCompleted(). 949 // |pending_requests_| simply to please OnResponseCompleted().
948 GlobalRequestID global_id(info->process_id, info->request_id); 950 GlobalRequestID global_id(info->process_id, info->request_id);
949 pending_requests_[global_id] = request; 951 pending_requests_[global_id] = request;
950 OnResponseCompleted(request); 952 OnResponseCompleted(request);
951 return; 953 return;
952 } 954 }
953 955
954 std::pair<int, int> pair_id(info->process_id, info->route_id); 956 std::pair<int, int> pair_id(info->process_id, info->route_id);
955 BlockedRequestMap::const_iterator iter = blocked_requests_map_.find(pair_id); 957 BlockedRequestMap::const_iterator iter = blocked_requests_map_.find(pair_id);
956 if (iter != blocked_requests_map_.end()) { 958 if (iter != blocked_requests_map_.end()) {
957 // The request should be blocked. 959 // The request should be blocked.
958 iter->second->push_back(BlockedRequest(request, mixed_content)); 960 iter->second->push_back(request);
959 return; 961 return;
960 } 962 }
961 963
962 GlobalRequestID global_id(info->process_id, info->request_id); 964 GlobalRequestID global_id(info->process_id, info->request_id);
963 pending_requests_[global_id] = request; 965 pending_requests_[global_id] = request;
964 if (mixed_content) { 966 if (SSLManager::ShouldDelayRequest(this, request, ui_loop_)) {
965 // We don't start the request in that case. The SSLManager will potentially 967 // The SSLManager has told us that we shouldn't start the request yet. The
966 // change the request (potentially to indicate its content should be 968 // SSLManager will potentially change the request (potentially to indicate
967 // filtered) and start it itself. 969 // its content should be filtered) and start it itself.
968 SSLManager::OnMixedContentRequest(this, request, ui_loop_);
969 return; 970 return;
970 } 971 }
971 request->Start(); 972 request->Start();
972 973
973 // Make sure we have the load state monitor running 974 // Make sure we have the load state monitor running
974 if (!update_load_states_timer_.IsRunning()) { 975 if (!update_load_states_timer_.IsRunning()) {
975 update_load_states_timer_.Start( 976 update_load_states_timer_.Start(
976 TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), 977 TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec),
977 this, &ResourceDispatcherHost::UpdateLoadStates); 978 this, &ResourceDispatcherHost::UpdateLoadStates);
978 } 979 }
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 for (BlockedRequestsList::iterator req_iter = requests->begin(); 1447 for (BlockedRequestsList::iterator req_iter = requests->begin();
1447 req_iter != requests->end(); ++req_iter) { 1448 req_iter != requests->end(); ++req_iter) {
1448 // Remove the memory credit that we added when pushing the request onto 1449 // Remove the memory credit that we added when pushing the request onto
1449 // the blocked list. 1450 // the blocked list.
1450 ExtraRequestInfo* info = ExtraInfoForRequest(req_iter->url_request); 1451 ExtraRequestInfo* info = ExtraInfoForRequest(req_iter->url_request);
1451 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost, 1452 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost,
1452 info->process_id); 1453 info->process_id);
1453 if (cancel_requests) 1454 if (cancel_requests)
1454 delete req_iter->url_request; 1455 delete req_iter->url_request;
1455 else 1456 else
1456 BeginRequestInternal(req_iter->url_request, req_iter->mixed_content); 1457 BeginRequestInternal(req_iter->url_request);
1457 } 1458 }
1458 1459
1459 delete requests; 1460 delete requests;
1460 } 1461 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698