Chromium Code Reviews| 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 request_info->url_loader_client->FlushDeferredMessages(); | |
|
kinuko
2016/12/23 13:11:23
Having two pending queues is confusing, it seems i
yhirano
2016/12/26 05:08:35
I've just noticed that |request_info| can be broke
| |
| 564 | |
| 556 // Because message handlers could result in request_info being destroyed, | 565 // Because message handlers could result in request_info being destroyed, |
| 557 // we need to work with a stack reference to the deferred queue. | 566 // we need to work with a stack reference to the deferred queue. |
| 558 MessageQueue q; | 567 MessageQueue q; |
| 559 q.swap(request_info->deferred_message_queue); | 568 q.swap(request_info->deferred_message_queue); |
| 560 while (!q.empty()) { | 569 while (!q.empty()) { |
| 561 IPC::Message* m = q.front(); | 570 IPC::Message* m = q.front(); |
| 562 q.pop_front(); | 571 q.pop_front(); |
| 563 DispatchMessage(*m); | 572 DispatchMessage(*m); |
| 564 delete m; | 573 delete m; |
| 565 // We need to find the request again in the list as it may have completed | 574 // 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; | 808 delete message; |
| 800 } | 809 } |
| 801 } | 810 } |
| 802 | 811 |
| 803 void ResourceDispatcher::SetResourceSchedulingFilter( | 812 void ResourceDispatcher::SetResourceSchedulingFilter( |
| 804 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { | 813 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { |
| 805 resource_scheduling_filter_ = resource_scheduling_filter; | 814 resource_scheduling_filter_ = resource_scheduling_filter; |
| 806 } | 815 } |
| 807 | 816 |
| 808 } // namespace content | 817 } // namespace content |
| OLD | NEW |