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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 request_complete_data.encoded_body_length); | 409 request_complete_data.encoded_body_length); |
| 410 } | 410 } |
| 411 | 411 |
| 412 bool ResourceDispatcher::RemovePendingRequest(int request_id) { | 412 bool ResourceDispatcher::RemovePendingRequest(int request_id) { |
| 413 PendingRequestMap::iterator it = pending_requests_.find(request_id); | 413 PendingRequestMap::iterator it = pending_requests_.find(request_id); |
| 414 if (it == pending_requests_.end()) | 414 if (it == pending_requests_.end()) |
| 415 return false; | 415 return false; |
| 416 | 416 |
| 417 PendingRequestInfo* request_info = it->second.get(); | 417 PendingRequestInfo* request_info = it->second.get(); |
| 418 | 418 |
| 419 bool release_downloaded_file = request_info->download_to_file; | 419 bool release_downloaded_file = |
| 420 request_info->download_to_file && !it->second->url_loader; | |
|
dcheng
2017/03/01 01:29:13
I think a comment here would be useful: I'm not ac
yhirano
2017/03/01 01:39:20
Done.
| |
| 420 | 421 |
| 421 ReleaseResourcesInMessageQueue(&request_info->deferred_message_queue); | 422 ReleaseResourcesInMessageQueue(&request_info->deferred_message_queue); |
| 422 | 423 |
| 423 // Cancel loading. | 424 // Cancel loading. |
| 424 it->second->url_loader = nullptr; | 425 it->second->url_loader = nullptr; |
| 425 // Clear URLLoaderClient to stop receiving further Mojo IPC from the browser | 426 // Clear URLLoaderClient to stop receiving further Mojo IPC from the browser |
| 426 // process. | 427 // process. |
| 427 it->second->url_loader_client = nullptr; | 428 it->second->url_loader_client = nullptr; |
| 428 | 429 |
| 429 // Always delete the pending_request asyncly so that cancelling the request | 430 // Always delete the pending_request asyncly so that cancelling the request |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 666 resource_scheduling_filter_->SetRequestIdTaskRunner(request_id, | 667 resource_scheduling_filter_->SetRequestIdTaskRunner(request_id, |
| 667 loading_task_runner); | 668 loading_task_runner); |
| 668 } | 669 } |
| 669 | 670 |
| 670 if (ipc_type == blink::WebURLRequest::LoadingIPCType::Mojo) { | 671 if (ipc_type == blink::WebURLRequest::LoadingIPCType::Mojo) { |
| 671 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 672 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 672 loading_task_runner ? loading_task_runner : main_thread_task_runner_; | 673 loading_task_runner ? loading_task_runner : main_thread_task_runner_; |
| 673 std::unique_ptr<URLLoaderClientImpl> client( | 674 std::unique_ptr<URLLoaderClientImpl> client( |
| 674 new URLLoaderClientImpl(request_id, this, std::move(task_runner))); | 675 new URLLoaderClientImpl(request_id, this, std::move(task_runner))); |
| 675 mojom::URLLoaderAssociatedPtr url_loader; | 676 mojom::URLLoaderAssociatedPtr url_loader; |
| 676 mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info; | 677 mojom::URLLoaderClientPtr client_ptr; |
| 677 client->Bind(&client_ptr_info); | 678 client->Bind(&client_ptr); |
| 678 url_loader_factory->CreateLoaderAndStart(MakeRequest(&url_loader), | 679 url_loader_factory->CreateLoaderAndStart(MakeRequest(&url_loader), |
| 679 routing_id, request_id, *request, | 680 routing_id, request_id, *request, |
| 680 std::move(client_ptr_info)); | 681 std::move(client_ptr)); |
| 681 pending_requests_[request_id]->url_loader = std::move(url_loader); | 682 pending_requests_[request_id]->url_loader = std::move(url_loader); |
| 682 pending_requests_[request_id]->url_loader_client = std::move(client); | 683 pending_requests_[request_id]->url_loader_client = std::move(client); |
| 683 } else { | 684 } else { |
| 684 message_sender_->Send( | 685 message_sender_->Send( |
| 685 new ResourceHostMsg_RequestResource(routing_id, request_id, *request)); | 686 new ResourceHostMsg_RequestResource(routing_id, request_id, *request)); |
| 686 } | 687 } |
| 687 | 688 |
| 688 return request_id; | 689 return request_id; |
| 689 } | 690 } |
| 690 | 691 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 822 delete message; | 823 delete message; |
| 823 } | 824 } |
| 824 } | 825 } |
| 825 | 826 |
| 826 void ResourceDispatcher::SetResourceSchedulingFilter( | 827 void ResourceDispatcher::SetResourceSchedulingFilter( |
| 827 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { | 828 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { |
| 828 resource_scheduling_filter_ = resource_scheduling_filter; | 829 resource_scheduling_filter_ = resource_scheduling_filter; |
| 829 } | 830 } |
| 830 | 831 |
| 831 } // namespace content | 832 } // namespace content |
| OLD | NEW |