OLD | NEW |
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/loader/resource_scheduler.h" | 5 #include "content/browser/loader/resource_scheduler.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "content/common/resource_messages.h" | 8 #include "content/common/resource_messages.h" |
9 #include "content/browser/loader/resource_message_delegate.h" | 9 #include "content/browser/loader/resource_message_delegate.h" |
10 #include "content/public/browser/resource_controller.h" | 10 #include "content/public/browser/resource_controller.h" |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 367 |
368 while (!request_iter.is_null()) { | 368 while (!request_iter.is_null()) { |
369 ScheduledResourceRequest* request = request_iter.value(); | 369 ScheduledResourceRequest* request = request_iter.value(); |
370 ShouldStartReqResult query_result = ShouldStartRequest(request, client); | 370 ShouldStartReqResult query_result = ShouldStartRequest(request, client); |
371 | 371 |
372 if (query_result == START_REQUEST) { | 372 if (query_result == START_REQUEST) { |
373 client->pending_requests.Erase(request); | 373 client->pending_requests.Erase(request); |
374 StartRequest(request, client); | 374 StartRequest(request, client); |
375 | 375 |
376 // StartRequest can modify the pending list, so we (re)start evaluation | 376 // StartRequest can modify the pending list, so we (re)start evaluation |
377 // from the currently highest priority request. | 377 // from the currently highest priority request. Avoid copying a singular |
| 378 // iterator, which would trigger undefined behavior. |
| 379 if (client->pending_requests.GetNextHighestIterator().is_null()) |
| 380 break; |
378 request_iter = client->pending_requests.GetNextHighestIterator(); | 381 request_iter = client->pending_requests.GetNextHighestIterator(); |
379 } else if (query_result == DO_NOT_START_REQUEST_AND_KEEP_SEARCHING) { | 382 } else if (query_result == DO_NOT_START_REQUEST_AND_KEEP_SEARCHING) { |
380 ++request_iter; | 383 ++request_iter; |
381 continue; | 384 continue; |
382 } else { | 385 } else { |
383 DCHECK(query_result == DO_NOT_START_REQUEST_AND_STOP_SEARCHING); | 386 DCHECK(query_result == DO_NOT_START_REQUEST_AND_STOP_SEARCHING); |
384 break; | 387 break; |
385 } | 388 } |
386 } | 389 } |
387 } | 390 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 | 493 |
491 return START_REQUEST; | 494 return START_REQUEST; |
492 } | 495 } |
493 | 496 |
494 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( | 497 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( |
495 int child_id, int route_id) { | 498 int child_id, int route_id) { |
496 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; | 499 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; |
497 } | 500 } |
498 | 501 |
499 } // namespace content | 502 } // namespace content |
OLD | NEW |