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 // |url_loader_client| releases the downloaded file. Otherwise, we should |
| 420 // release it here. | |
|
dcheng
2017/03/01 01:44:24
I think it would be good if this comment also ment
yhirano
2017/03/01 01:53:04
Fixed. Is it clear now?
| |
| 421 bool release_downloaded_file = | |
| 422 request_info->download_to_file && !it->second->url_loader_client; | |
| 420 | 423 |
| 421 ReleaseResourcesInMessageQueue(&request_info->deferred_message_queue); | 424 ReleaseResourcesInMessageQueue(&request_info->deferred_message_queue); |
| 422 | 425 |
| 423 // Cancel loading. | 426 // Cancel loading. |
| 424 it->second->url_loader = nullptr; | 427 it->second->url_loader = nullptr; |
| 425 // Clear URLLoaderClient to stop receiving further Mojo IPC from the browser | 428 // Clear URLLoaderClient to stop receiving further Mojo IPC from the browser |
| 426 // process. | 429 // process. |
| 427 it->second->url_loader_client = nullptr; | 430 it->second->url_loader_client = nullptr; |
| 428 | 431 |
| 429 // Always delete the pending_request asyncly so that cancelling the request | 432 // 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, | 669 resource_scheduling_filter_->SetRequestIdTaskRunner(request_id, |
| 667 loading_task_runner); | 670 loading_task_runner); |
| 668 } | 671 } |
| 669 | 672 |
| 670 if (ipc_type == blink::WebURLRequest::LoadingIPCType::Mojo) { | 673 if (ipc_type == blink::WebURLRequest::LoadingIPCType::Mojo) { |
| 671 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 674 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 672 loading_task_runner ? loading_task_runner : main_thread_task_runner_; | 675 loading_task_runner ? loading_task_runner : main_thread_task_runner_; |
| 673 std::unique_ptr<URLLoaderClientImpl> client( | 676 std::unique_ptr<URLLoaderClientImpl> client( |
| 674 new URLLoaderClientImpl(request_id, this, std::move(task_runner))); | 677 new URLLoaderClientImpl(request_id, this, std::move(task_runner))); |
| 675 mojom::URLLoaderAssociatedPtr url_loader; | 678 mojom::URLLoaderAssociatedPtr url_loader; |
| 676 mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info; | 679 mojom::URLLoaderClientPtr client_ptr; |
| 677 client->Bind(&client_ptr_info); | 680 client->Bind(&client_ptr); |
| 678 url_loader_factory->CreateLoaderAndStart(MakeRequest(&url_loader), | 681 url_loader_factory->CreateLoaderAndStart(MakeRequest(&url_loader), |
| 679 routing_id, request_id, *request, | 682 routing_id, request_id, *request, |
| 680 std::move(client_ptr_info)); | 683 std::move(client_ptr)); |
| 681 pending_requests_[request_id]->url_loader = std::move(url_loader); | 684 pending_requests_[request_id]->url_loader = std::move(url_loader); |
| 682 pending_requests_[request_id]->url_loader_client = std::move(client); | 685 pending_requests_[request_id]->url_loader_client = std::move(client); |
| 683 } else { | 686 } else { |
| 684 message_sender_->Send( | 687 message_sender_->Send( |
| 685 new ResourceHostMsg_RequestResource(routing_id, request_id, *request)); | 688 new ResourceHostMsg_RequestResource(routing_id, request_id, *request)); |
| 686 } | 689 } |
| 687 | 690 |
| 688 return request_id; | 691 return request_id; |
| 689 } | 692 } |
| 690 | 693 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 822 delete message; | 825 delete message; |
| 823 } | 826 } |
| 824 } | 827 } |
| 825 | 828 |
| 826 void ResourceDispatcher::SetResourceSchedulingFilter( | 829 void ResourceDispatcher::SetResourceSchedulingFilter( |
| 827 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { | 830 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { |
| 828 resource_scheduling_filter_ = resource_scheduling_filter; | 831 resource_scheduling_filter_ = resource_scheduling_filter; |
| 829 } | 832 } |
| 830 | 833 |
| 831 } // namespace content | 834 } // namespace content |
| OLD | NEW |