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 // 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/child/resource_dispatcher.h" | 7 #include "content/child/resource_dispatcher.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 } | 476 } |
477 | 477 |
478 void ResourceDispatcher::SetDefersLoading(int request_id, bool value) { | 478 void ResourceDispatcher::SetDefersLoading(int request_id, bool value) { |
479 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 479 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
480 if (!request_info) { | 480 if (!request_info) { |
481 DLOG(ERROR) << "unknown request"; | 481 DLOG(ERROR) << "unknown request"; |
482 return; | 482 return; |
483 } | 483 } |
484 if (value) { | 484 if (value) { |
485 request_info->is_deferred = value; | 485 request_info->is_deferred = value; |
| 486 if (request_info->url_loader_client) |
| 487 request_info->url_loader_client->SetDefersLoading(); |
486 } else if (request_info->is_deferred) { | 488 } else if (request_info->is_deferred) { |
487 request_info->is_deferred = false; | 489 request_info->is_deferred = false; |
488 | 490 |
| 491 if (request_info->url_loader_client) |
| 492 request_info->url_loader_client->UnsetDefersLoading(); |
| 493 |
489 FollowPendingRedirect(request_id, request_info); | 494 FollowPendingRedirect(request_id, request_info); |
490 | 495 |
491 main_thread_task_runner_->PostTask( | 496 main_thread_task_runner_->PostTask( |
492 FROM_HERE, base::Bind(&ResourceDispatcher::FlushDeferredMessages, | 497 FROM_HERE, base::Bind(&ResourceDispatcher::FlushDeferredMessages, |
493 weak_factory_.GetWeakPtr(), request_id)); | 498 weak_factory_.GetWeakPtr(), request_id)); |
494 } | 499 } |
495 } | 500 } |
496 | 501 |
497 void ResourceDispatcher::DidChangePriority(int request_id, | 502 void ResourceDispatcher::DidChangePriority(int request_id, |
498 net::RequestPriority new_priority, | 503 net::RequestPriority new_priority, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 IPC_MESSAGE_HANDLER(ResourceMsg_DataReceived, OnReceivedData) | 551 IPC_MESSAGE_HANDLER(ResourceMsg_DataReceived, OnReceivedData) |
547 IPC_MESSAGE_HANDLER(ResourceMsg_DataDownloaded, OnDownloadedData) | 552 IPC_MESSAGE_HANDLER(ResourceMsg_DataDownloaded, OnDownloadedData) |
548 IPC_MESSAGE_HANDLER(ResourceMsg_RequestComplete, OnRequestComplete) | 553 IPC_MESSAGE_HANDLER(ResourceMsg_RequestComplete, OnRequestComplete) |
549 IPC_END_MESSAGE_MAP() | 554 IPC_END_MESSAGE_MAP() |
550 } | 555 } |
551 | 556 |
552 void ResourceDispatcher::FlushDeferredMessages(int request_id) { | 557 void ResourceDispatcher::FlushDeferredMessages(int request_id) { |
553 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 558 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
554 if (!request_info || request_info->is_deferred) | 559 if (!request_info || request_info->is_deferred) |
555 return; | 560 return; |
| 561 |
| 562 if (request_info->url_loader) { |
| 563 DCHECK(request_info->deferred_message_queue.empty()); |
| 564 request_info->url_loader_client->FlushDeferredMessages(); |
| 565 return; |
| 566 } |
| 567 |
556 // Because message handlers could result in request_info being destroyed, | 568 // Because message handlers could result in request_info being destroyed, |
557 // we need to work with a stack reference to the deferred queue. | 569 // we need to work with a stack reference to the deferred queue. |
558 MessageQueue q; | 570 MessageQueue q; |
559 q.swap(request_info->deferred_message_queue); | 571 q.swap(request_info->deferred_message_queue); |
560 while (!q.empty()) { | 572 while (!q.empty()) { |
561 IPC::Message* m = q.front(); | 573 IPC::Message* m = q.front(); |
562 q.pop_front(); | 574 q.pop_front(); |
563 DispatchMessage(*m); | 575 DispatchMessage(*m); |
564 delete m; | 576 delete m; |
565 // We need to find the request again in the list as it may have completed | 577 // We need to find the request again in the list as it may have completed |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 delete message; | 811 delete message; |
800 } | 812 } |
801 } | 813 } |
802 | 814 |
803 void ResourceDispatcher::SetResourceSchedulingFilter( | 815 void ResourceDispatcher::SetResourceSchedulingFilter( |
804 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { | 816 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { |
805 resource_scheduling_filter_ = resource_scheduling_filter; | 817 resource_scheduling_filter_ = resource_scheduling_filter; |
806 } | 818 } |
807 | 819 |
808 } // namespace content | 820 } // namespace content |
OLD | NEW |