OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 // If sync_result is non-null, then a SyncLoad reply will be generated, else | 445 // If sync_result is non-null, then a SyncLoad reply will be generated, else |
446 // a normal asynchronous set of response messages will be generated. | 446 // a normal asynchronous set of response messages will be generated. |
447 void ResourceDispatcherHost::OnSyncLoad( | 447 void ResourceDispatcherHost::OnSyncLoad( |
448 int request_id, | 448 int request_id, |
449 const ResourceHostMsg_Request& request_data, | 449 const ResourceHostMsg_Request& request_data, |
450 IPC::Message* sync_result) { | 450 IPC::Message* sync_result) { |
451 BeginRequest(request_id, request_data, sync_result, | 451 BeginRequest(request_id, request_data, sync_result, |
452 sync_result->routing_id()); | 452 sync_result->routing_id()); |
453 } | 453 } |
454 | 454 |
| 455 // TODO(mpcomplete): hack |
| 456 static GURL g_deferred_url; |
| 457 static int g_deferred_child_id; |
| 458 static int g_deferred_request_id; |
| 459 |
455 void ResourceDispatcherHost::BeginRequest( | 460 void ResourceDispatcherHost::BeginRequest( |
456 int request_id, | 461 int request_id, |
457 const ResourceHostMsg_Request& request_data, | 462 const ResourceHostMsg_Request& request_data, |
458 IPC::Message* sync_result, // only valid for sync | 463 IPC::Message* sync_result, // only valid for sync |
459 int route_id) { | 464 int route_id) { |
460 ChildProcessInfo::ProcessType process_type = filter_->process_type(); | 465 ChildProcessInfo::ProcessType process_type = filter_->process_type(); |
461 int child_id = filter_->child_id(); | 466 int child_id = filter_->child_id(); |
462 | 467 |
463 // If we crash here, figure out what URL the renderer was requesting. | 468 // If we crash here, figure out what URL the renderer was requesting. |
464 // http://crbug.com/91398 | 469 // http://crbug.com/91398 |
465 char url_buf[128]; | 470 char url_buf[128]; |
466 base::strlcpy(url_buf, request_data.url.spec().c_str(), arraysize(url_buf)); | 471 base::strlcpy(url_buf, request_data.url.spec().c_str(), arraysize(url_buf)); |
467 base::debug::Alias(url_buf); | 472 base::debug::Alias(url_buf); |
468 | 473 |
| 474 // TODO(mpcomplete): Step 3. (See steps 1-2 below). |
| 475 // If the request that's coming in is a cross-process transferring, then we |
| 476 // want to reuse and resume the old request rather than start a new one. |
| 477 // I'm not entirely sure how much of the BeginRequest code should run. We |
| 478 // definitely want to create new ResourceHandlers and ExtraInfo, since those |
| 479 // are tied to the process. |
| 480 // Also, I'm not clear what should happen if any of the early returns are hit |
| 481 // before we actually resume the request via FollowDeferredRedirect. I think |
| 482 // we're then left with an orphaned request that will never be deleted. We |
| 483 // probably want to cancel it in those cases. |
| 484 // It's probably best to split apart BeginRequest into 2 methods, 1 for |
| 485 // regular requests and one for transferred ones - probably with some shared |
| 486 // code, but not all. |
| 487 net::URLRequest* deferred_request = NULL; |
| 488 if (!g_deferred_url.is_empty() && request_data.url == g_deferred_url) { |
| 489 g_deferred_url = GURL(); |
| 490 GlobalRequestID old_id(g_deferred_child_id, g_deferred_request_id); |
| 491 PendingRequestList::iterator i = pending_requests_.find(old_id); |
| 492 DCHECK(i != pending_requests_.end()); |
| 493 deferred_request = i->second; |
| 494 ResourceDispatcherHostRequestInfo* info = InfoForRequest(deferred_request); |
| 495 |
| 496 pending_requests_.erase(old_id); |
| 497 } |
| 498 |
469 const content::ResourceContext& resource_context = | 499 const content::ResourceContext& resource_context = |
470 filter_->resource_context(); | 500 filter_->resource_context(); |
471 | 501 |
472 // Might need to resolve the blob references in the upload data. | 502 // Might need to resolve the blob references in the upload data. |
473 if (request_data.upload_data) { | 503 if (request_data.upload_data) { |
474 resource_context.blob_storage_context()->controller()-> | 504 resource_context.blob_storage_context()->controller()-> |
475 ResolveBlobReferencesInUploadData(request_data.upload_data.get()); | 505 ResolveBlobReferencesInUploadData(request_data.upload_data.get()); |
476 } | 506 } |
477 | 507 |
478 if (is_shutdown_ || | 508 if (is_shutdown_ || |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 handler = new RedirectToFileResourceHandler(handler, child_id, this); | 540 handler = new RedirectToFileResourceHandler(handler, child_id, this); |
511 | 541 |
512 if (HandleExternalProtocol(request_id, child_id, route_id, | 542 if (HandleExternalProtocol(request_id, child_id, route_id, |
513 request_data.url, request_data.resource_type, | 543 request_data.url, request_data.resource_type, |
514 *resource_context.request_context()->job_factory(), | 544 *resource_context.request_context()->job_factory(), |
515 handler)) { | 545 handler)) { |
516 return; | 546 return; |
517 } | 547 } |
518 | 548 |
519 // Construct the request. | 549 // Construct the request. |
520 net::URLRequest* request = new net::URLRequest(request_data.url, this); | 550 net::URLRequest* request; |
521 request->set_method(request_data.method); | 551 if (deferred_request) { |
522 request->set_first_party_for_cookies(request_data.first_party_for_cookies); | 552 request = deferred_request; |
523 request->set_referrer(referrer.spec()); | 553 } else { |
524 net::HttpRequestHeaders headers; | 554 request = new net::URLRequest(request_data.url, this); |
525 headers.AddHeadersFromString(request_data.headers); | 555 request->set_method(request_data.method); |
526 request->SetExtraRequestHeaders(headers); | 556 request->set_first_party_for_cookies(request_data.first_party_for_cookies); |
| 557 request->set_referrer(referrer.spec()); |
| 558 net::HttpRequestHeaders headers; |
| 559 headers.AddHeadersFromString(request_data.headers); |
| 560 request->SetExtraRequestHeaders(headers); |
527 | 561 |
528 int load_flags = request_data.load_flags; | 562 int load_flags = request_data.load_flags; |
529 // Although EV status is irrelevant to sub-frames and sub-resources, we have | 563 // Although EV status is irrelevant to sub-frames and sub-resources, we have |
530 // to perform EV certificate verification on all resources because an HTTP | 564 // to perform EV certificate verification on all resources because an HTTP |
531 // keep-alive connection created to load a sub-frame or a sub-resource could | 565 // keep-alive connection created to load a sub-frame or a sub-resource could |
532 // be reused to load a main frame. | 566 // be reused to load a main frame. |
533 load_flags |= net::LOAD_VERIFY_EV_CERT; | 567 load_flags |= net::LOAD_VERIFY_EV_CERT; |
534 if (request_data.resource_type == ResourceType::MAIN_FRAME) { | 568 if (request_data.resource_type == ResourceType::MAIN_FRAME) { |
535 load_flags |= net::LOAD_MAIN_FRAME; | 569 load_flags |= net::LOAD_MAIN_FRAME; |
536 } else if (request_data.resource_type == ResourceType::SUB_FRAME) { | 570 } else if (request_data.resource_type == ResourceType::SUB_FRAME) { |
537 load_flags |= net::LOAD_SUB_FRAME; | 571 load_flags |= net::LOAD_SUB_FRAME; |
538 } else if (request_data.resource_type == ResourceType::PREFETCH) { | 572 } else if (request_data.resource_type == ResourceType::PREFETCH) { |
539 load_flags |= (net::LOAD_PREFETCH | net::LOAD_DO_NOT_PROMPT_FOR_LOGIN); | 573 load_flags |= (net::LOAD_PREFETCH | net::LOAD_DO_NOT_PROMPT_FOR_LOGIN); |
540 } else if (request_data.resource_type == ResourceType::FAVICON) { | 574 } else if (request_data.resource_type == ResourceType::FAVICON) { |
541 load_flags |= net::LOAD_DO_NOT_PROMPT_FOR_LOGIN; | 575 load_flags |= net::LOAD_DO_NOT_PROMPT_FOR_LOGIN; |
| 576 } |
| 577 |
| 578 if (sync_result) |
| 579 load_flags |= net::LOAD_IGNORE_LIMITS; |
| 580 |
| 581 // Raw headers are sensitive, as they inclide Cookie/Set-Cookie, so only |
| 582 // allow requesting them if requestor has ReadRawCookies permission. |
| 583 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) |
| 584 && !ChildProcessSecurityPolicy::GetInstance()-> |
| 585 CanReadRawCookies(child_id)) { |
| 586 VLOG(1) << "Denied unathorized request for raw headers"; |
| 587 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; |
| 588 } |
| 589 |
| 590 request->set_load_flags(load_flags); |
542 } | 591 } |
543 | 592 |
544 if (sync_result) | |
545 load_flags |= net::LOAD_IGNORE_LIMITS; | |
546 | |
547 // Raw headers are sensitive, as they inclide Cookie/Set-Cookie, so only | |
548 // allow requesting them if requestor has ReadRawCookies permission. | |
549 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) | |
550 && !ChildProcessSecurityPolicy::GetInstance()-> | |
551 CanReadRawCookies(child_id)) { | |
552 VLOG(1) << "Denied unathorized request for raw headers"; | |
553 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; | |
554 } | |
555 | |
556 request->set_load_flags(load_flags); | |
557 request->set_context( | 593 request->set_context( |
558 filter_->GetURLRequestContext(request_data.resource_type)); | 594 filter_->GetURLRequestContext(request_data.resource_type)); |
559 request->set_priority(DetermineRequestPriority(request_data.resource_type)); | 595 request->set_priority(DetermineRequestPriority(request_data.resource_type)); |
560 | 596 |
561 // Set upload data. | 597 // Set upload data. |
562 uint64 upload_size = 0; | 598 uint64 upload_size = 0; |
563 if (request_data.upload_data) { | 599 if (request_data.upload_data) { |
564 request->set_upload(request_data.upload_data); | 600 request->set_upload(request_data.upload_data); |
565 upload_size = request_data.upload_data->GetContentLength(); | 601 upload_size = request_data.upload_data->GetContentLength(); |
566 } | 602 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 resource_context.blob_storage_context()->controller(); | 655 resource_context.blob_storage_context()->controller(); |
620 extra_info->set_requested_blob_data( | 656 extra_info->set_requested_blob_data( |
621 controller->GetBlobDataFromUrl(request->url())); | 657 controller->GetBlobDataFromUrl(request->url())); |
622 } | 658 } |
623 | 659 |
624 // Have the appcache associate its extra info with the request. | 660 // Have the appcache associate its extra info with the request. |
625 appcache::AppCacheInterceptor::SetExtraRequestInfo( | 661 appcache::AppCacheInterceptor::SetExtraRequestInfo( |
626 request, resource_context.appcache_service(), child_id, | 662 request, resource_context.appcache_service(), child_id, |
627 request_data.appcache_host_id, request_data.resource_type); | 663 request_data.appcache_host_id, request_data.resource_type); |
628 | 664 |
629 BeginRequestInternal(request); | 665 if (deferred_request) { |
| 666 GlobalRequestID global_id(extra_info->child_id(), extra_info->request_id()); |
| 667 pending_requests_[global_id] = request; |
| 668 request->FollowDeferredRedirect(); |
| 669 } else { |
| 670 BeginRequestInternal(request); |
| 671 } |
630 } | 672 } |
631 | 673 |
632 void ResourceDispatcherHost::OnReleaseDownloadedFile(int request_id) { | 674 void ResourceDispatcherHost::OnReleaseDownloadedFile(int request_id) { |
633 DCHECK(pending_requests_.end() == | 675 DCHECK(pending_requests_.end() == |
634 pending_requests_.find( | 676 pending_requests_.find( |
635 GlobalRequestID(filter_->child_id(), request_id))); | 677 GlobalRequestID(filter_->child_id(), request_id))); |
636 UnregisterDownloadedTempFile(filter_->child_id(), request_id); | 678 UnregisterDownloadedTempFile(filter_->child_id(), request_id); |
637 } | 679 } |
638 | 680 |
639 void ResourceDispatcherHost::OnDataReceivedACK(int request_id) { | 681 void ResourceDispatcherHost::OnDataReceivedACK(int request_id) { |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 NOTREACHED() << "Trying to remove a request that's not here"; | 1220 NOTREACHED() << "Trying to remove a request that's not here"; |
1179 return; | 1221 return; |
1180 } | 1222 } |
1181 RemovePendingRequest(i); | 1223 RemovePendingRequest(i); |
1182 } | 1224 } |
1183 | 1225 |
1184 void ResourceDispatcherHost::RemovePendingRequest( | 1226 void ResourceDispatcherHost::RemovePendingRequest( |
1185 const PendingRequestList::iterator& iter) { | 1227 const PendingRequestList::iterator& iter) { |
1186 ResourceDispatcherHostRequestInfo* info = InfoForRequest(iter->second); | 1228 ResourceDispatcherHostRequestInfo* info = InfoForRequest(iter->second); |
1187 | 1229 |
| 1230 // This is called via CancelRequestsForRoute to remove all requests for a |
| 1231 // closing tab. We don't want to remove requests that are being transferred |
| 1232 // to a new tab. |
| 1233 if (info->child_id() == g_deferred_child_id && |
| 1234 info->request_id() == g_deferred_request_id) |
| 1235 return; |
| 1236 |
1188 // Remove the memory credit that we added when pushing the request onto | 1237 // Remove the memory credit that we added when pushing the request onto |
1189 // the pending list. | 1238 // the pending list. |
1190 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), | 1239 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), |
1191 info->child_id()); | 1240 info->child_id()); |
1192 | 1241 |
1193 // Notify interested parties that the request object is going away. | 1242 // Notify interested parties that the request object is going away. |
1194 if (info->login_delegate()) | 1243 if (info->login_delegate()) |
1195 info->login_delegate()->OnRequestCancelled(); | 1244 info->login_delegate()->OnRequestCancelled(); |
1196 if (info->ssl_client_auth_handler()) | 1245 if (info->ssl_client_auth_handler()) |
1197 info->ssl_client_auth_handler()->OnRequestCancelled(); | 1246 info->ssl_client_auth_handler()->OnRequestCancelled(); |
1198 resource_queue_.RemoveRequest(iter->first); | 1247 resource_queue_.RemoveRequest(iter->first); |
1199 | 1248 |
1200 delete iter->second; | 1249 delete iter->second; |
1201 pending_requests_.erase(iter); | 1250 pending_requests_.erase(iter); |
1202 | 1251 |
1203 // If we have no more pending requests, then stop the load state monitor | 1252 // If we have no more pending requests, then stop the load state monitor |
1204 if (pending_requests_.empty()) | 1253 if (pending_requests_.empty()) |
1205 update_load_states_timer_.Stop(); | 1254 update_load_states_timer_.Stop(); |
1206 } | 1255 } |
1207 | 1256 |
| 1257 // TODO(mpcomplete): ILLEGAL! remove this |
| 1258 #include "chrome/browser/profiles/profile_io_data.h" |
| 1259 #include "chrome/browser/extensions/extension_info_map.h" |
1208 // net::URLRequest::Delegate --------------------------------------------------- | 1260 // net::URLRequest::Delegate --------------------------------------------------- |
1209 | 1261 |
| 1262 |
1210 void ResourceDispatcherHost::OnReceivedRedirect(net::URLRequest* request, | 1263 void ResourceDispatcherHost::OnReceivedRedirect(net::URLRequest* request, |
1211 const GURL& new_url, | 1264 const GURL& new_url, |
1212 bool* defer_redirect) { | 1265 bool* defer_redirect) { |
1213 VLOG(1) << "OnReceivedRedirect: " << request->url().spec(); | 1266 VLOG(1) << "OnReceivedRedirect: " << request->url().spec(); |
1214 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1267 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
1215 | 1268 |
1216 DCHECK(request->status().is_success()); | 1269 DCHECK(request->status().is_success()); |
1217 | 1270 |
1218 if (info->process_type() != ChildProcessInfo::PLUGIN_PROCESS && | 1271 if (info->process_type() != ChildProcessInfo::PLUGIN_PROCESS && |
1219 !ChildProcessSecurityPolicy::GetInstance()-> | 1272 !ChildProcessSecurityPolicy::GetInstance()-> |
(...skipping 11 matching lines...) Expand all Loading... |
1231 if (HandleExternalProtocol(info->request_id(), info->child_id(), | 1284 if (HandleExternalProtocol(info->request_id(), info->child_id(), |
1232 info->route_id(), new_url, | 1285 info->route_id(), new_url, |
1233 info->resource_type(), | 1286 info->resource_type(), |
1234 *request->context()->job_factory(), | 1287 *request->context()->job_factory(), |
1235 info->resource_handler())) { | 1288 info->resource_handler())) { |
1236 // The request is complete so we can remove it. | 1289 // The request is complete so we can remove it. |
1237 RemovePendingRequest(info->child_id(), info->request_id()); | 1290 RemovePendingRequest(info->child_id(), info->request_id()); |
1238 return; | 1291 return; |
1239 } | 1292 } |
1240 | 1293 |
| 1294 // If we're redirecting into an extension process, we want to switch |
| 1295 // processes. We do this by cancelling the redirect and reissuing the request, |
| 1296 // so that the navigation controller properly assigns the right process to |
| 1297 // host the new URL. |
| 1298 const content::ResourceContext& resource_context = *info->context(); |
| 1299 ProfileIOData* io_data = |
| 1300 reinterpret_cast<ProfileIOData*>(resource_context.GetUserData(NULL)); |
| 1301 |
| 1302 // TODO(mpcomplete): Step 1. |
| 1303 // This code should move into a resource handler instead. See the call to |
| 1304 // delegate_->RequestBeginning below - the resource handler should live in |
| 1305 // chrome/ so that it can reference extensions. |
| 1306 if (io_data->GetExtensionInfoMap()->extensions().GetByURL(new_url) != |
| 1307 io_data->GetExtensionInfoMap()->extensions().GetByURL(request->url())) { |
| 1308 int render_process_id, render_view_id; |
| 1309 if (RenderViewForRequest(request, &render_process_id, &render_view_id)) { |
| 1310 // TODO(mpcomplete): Step 2. |
| 1311 // This is uber hacky to short-circuit all the plumbing gunk we need to |
| 1312 // do. We'll have to thread the child_id/request_id pair through the |
| 1313 // navigation calls from browser to renderer and back again: |
| 1314 // 1. new RVHD method that TabContents implements, like TransferNavigation |
| 1315 // that issues a new navigation in a new renderer but tells it the ID |
| 1316 // pair. Use NavigationController::LoadURL to load the request. |
| 1317 // 2. thread the ID pair through |
| 1318 // [browser] NavigationEntry, |
| 1319 // [browser->renderer] ViewMsg_Navigate, |
| 1320 // [renderer] NavigationState -> RequestExtraData, |
| 1321 // [renderer->browser] ResourceHostMsg_RequestResource |
| 1322 // 3. In ResourceDispatcherHost::BeginRequest (which handles the message |
| 1323 // above), check if it is a transferred navigation. If so, proceed as I do |
| 1324 // below when g_deferred_url is non-empty. |
| 1325 |
| 1326 g_deferred_url = new_url; |
| 1327 g_deferred_child_id = render_process_id; |
| 1328 g_deferred_request_id = info->request_id(); |
| 1329 CallRenderViewHostDelegate( |
| 1330 render_process_id, render_view_id, |
| 1331 &RenderViewHostDelegate::RequestOpenURL, |
| 1332 new_url, GURL(request->referrer()), CURRENT_TAB, info->frame_id_); |
| 1333 *defer_redirect = true; |
| 1334 return; |
| 1335 } |
| 1336 } |
| 1337 |
1241 scoped_refptr<ResourceResponse> response(new ResourceResponse); | 1338 scoped_refptr<ResourceResponse> response(new ResourceResponse); |
1242 PopulateResourceResponse(request, response); | 1339 PopulateResourceResponse(request, response); |
1243 if (!info->resource_handler()->OnRequestRedirected(info->request_id(), | 1340 if (!info->resource_handler()->OnRequestRedirected(info->request_id(), |
1244 new_url, | 1341 new_url, |
1245 response, defer_redirect)) | 1342 response, defer_redirect)) |
1246 CancelRequestInternal(request, false); | 1343 CancelRequestInternal(request, false); |
1247 } | 1344 } |
1248 | 1345 |
1249 void ResourceDispatcherHost::OnAuthRequired( | 1346 void ResourceDispatcherHost::OnAuthRequired( |
1250 net::URLRequest* request, | 1347 net::URLRequest* request, |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 | 1507 |
1411 NotifyResponseStarted(request, info->child_id()); | 1508 NotifyResponseStarted(request, info->child_id()); |
1412 info->set_called_on_response_started(true); | 1509 info->set_called_on_response_started(true); |
1413 return info->resource_handler()->OnResponseStarted(info->request_id(), | 1510 return info->resource_handler()->OnResponseStarted(info->request_id(), |
1414 response.get()); | 1511 response.get()); |
1415 } | 1512 } |
1416 | 1513 |
1417 void ResourceDispatcherHost::CancelRequest(int child_id, | 1514 void ResourceDispatcherHost::CancelRequest(int child_id, |
1418 int request_id, | 1515 int request_id, |
1419 bool from_renderer) { | 1516 bool from_renderer) { |
| 1517 if (from_renderer && |
| 1518 child_id == g_deferred_child_id && |
| 1519 request_id == g_deferred_request_id) { |
| 1520 // When the old renderer dies, it sends a message to us to cancel its |
| 1521 // requests. |
| 1522 return; |
| 1523 } |
| 1524 |
1420 PendingRequestList::iterator i = pending_requests_.find( | 1525 PendingRequestList::iterator i = pending_requests_.find( |
1421 GlobalRequestID(child_id, request_id)); | 1526 GlobalRequestID(child_id, request_id)); |
1422 if (i == pending_requests_.end()) { | 1527 if (i == pending_requests_.end()) { |
1423 // We probably want to remove this warning eventually, but I wanted to be | 1528 // We probably want to remove this warning eventually, but I wanted to be |
1424 // able to notice when this happens during initial development since it | 1529 // able to notice when this happens during initial development since it |
1425 // should be rare and may indicate a bug. | 1530 // should be rare and may indicate a bug. |
1426 DLOG(WARNING) << "Canceling a request that wasn't found"; | 1531 DLOG(WARNING) << "Canceling a request that wasn't found"; |
1427 return; | 1532 return; |
1428 } | 1533 } |
1429 net::URLRequest* request = i->second; | 1534 net::URLRequest* request = i->second; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 OutstandingRequestsMemoryCostMap::iterator prev_entry = | 1578 OutstandingRequestsMemoryCostMap::iterator prev_entry = |
1474 outstanding_requests_memory_cost_map_.find(child_id); | 1579 outstanding_requests_memory_cost_map_.find(child_id); |
1475 int new_cost = 0; | 1580 int new_cost = 0; |
1476 if (prev_entry != outstanding_requests_memory_cost_map_.end()) | 1581 if (prev_entry != outstanding_requests_memory_cost_map_.end()) |
1477 new_cost = prev_entry->second; | 1582 new_cost = prev_entry->second; |
1478 | 1583 |
1479 // Insert/update the total; delete entries when their value reaches 0. | 1584 // Insert/update the total; delete entries when their value reaches 0. |
1480 new_cost += cost; | 1585 new_cost += cost; |
1481 CHECK(new_cost >= 0); | 1586 CHECK(new_cost >= 0); |
1482 if (new_cost == 0) | 1587 if (new_cost == 0) |
1483 outstanding_requests_memory_cost_map_.erase(prev_entry); | 1588 outstanding_requests_memory_cost_map_.erase(child_id); |
1484 else | 1589 else |
1485 outstanding_requests_memory_cost_map_[child_id] = new_cost; | 1590 outstanding_requests_memory_cost_map_[child_id] = new_cost; |
1486 | 1591 |
1487 return new_cost; | 1592 return new_cost; |
1488 } | 1593 } |
1489 | 1594 |
1490 // static | 1595 // static |
1491 int ResourceDispatcherHost::CalculateApproximateMemoryCost( | 1596 int ResourceDispatcherHost::CalculateApproximateMemoryCost( |
1492 net::URLRequest* request) { | 1597 net::URLRequest* request) { |
1493 // The following fields should be a minor size contribution (experimentally | 1598 // The following fields should be a minor size contribution (experimentally |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2162 return HTTP_AUTH_RESOURCE_BLOCKED_CROSS; | 2267 return HTTP_AUTH_RESOURCE_BLOCKED_CROSS; |
2163 } | 2268 } |
2164 | 2269 |
2165 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { | 2270 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { |
2166 return allow_cross_origin_auth_prompt_; | 2271 return allow_cross_origin_auth_prompt_; |
2167 } | 2272 } |
2168 | 2273 |
2169 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { | 2274 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { |
2170 allow_cross_origin_auth_prompt_ = value; | 2275 allow_cross_origin_auth_prompt_ = value; |
2171 } | 2276 } |
OLD | NEW |