| 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 "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 545 |
| 546 base::TimeTicks renderer_completion_time = ToRendererCompletionTime( | 546 base::TimeTicks renderer_completion_time = ToRendererCompletionTime( |
| 547 *request_info, browser_completion_time); | 547 *request_info, browser_completion_time); |
| 548 // The request ID will be removed from our pending list in the destructor. | 548 // The request ID will be removed from our pending list in the destructor. |
| 549 // Normally, dispatching this message causes the reference-counted request to | 549 // Normally, dispatching this message causes the reference-counted request to |
| 550 // die immediately. | 550 // die immediately. |
| 551 peer->OnCompletedRequest(error_code, was_ignored_by_handler, security_info, | 551 peer->OnCompletedRequest(error_code, was_ignored_by_handler, security_info, |
| 552 renderer_completion_time); | 552 renderer_completion_time); |
| 553 } | 553 } |
| 554 | 554 |
| 555 void ResourceDispatcher::OnRequestDidStartForFrame(int request_id) { |
| 556 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 557 if (!request_info) |
| 558 return; |
| 559 request_info->peer->OnStartedRequestForFrame(); |
| 560 } |
| 561 |
| 555 int ResourceDispatcher::AddPendingRequest( | 562 int ResourceDispatcher::AddPendingRequest( |
| 556 ResourceLoaderBridge::Peer* callback, | 563 ResourceLoaderBridge::Peer* callback, |
| 557 ResourceType::Type resource_type, | 564 ResourceType::Type resource_type, |
| 558 int origin_pid, | 565 int origin_pid, |
| 559 const GURL& frame_origin, | 566 const GURL& frame_origin, |
| 560 const GURL& request_url) { | 567 const GURL& request_url) { |
| 561 // Compute a unique request_id for this renderer process. | 568 // Compute a unique request_id for this renderer process. |
| 562 int id = MakeRequestID(); | 569 int id = MakeRequestID(); |
| 563 pending_requests_[id] = PendingRequestInfo( | 570 pending_requests_[id] = PendingRequestInfo( |
| 564 callback, resource_type, origin_pid, frame_origin, request_url); | 571 callback, resource_type, origin_pid, frame_origin, request_url); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcher, message) | 655 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcher, message) |
| 649 IPC_MESSAGE_HANDLER(ResourceMsg_UploadProgress, OnUploadProgress) | 656 IPC_MESSAGE_HANDLER(ResourceMsg_UploadProgress, OnUploadProgress) |
| 650 IPC_MESSAGE_HANDLER(ResourceMsg_ReceivedResponse, OnReceivedResponse) | 657 IPC_MESSAGE_HANDLER(ResourceMsg_ReceivedResponse, OnReceivedResponse) |
| 651 IPC_MESSAGE_HANDLER(ResourceMsg_ReceivedCachedMetadata, | 658 IPC_MESSAGE_HANDLER(ResourceMsg_ReceivedCachedMetadata, |
| 652 OnReceivedCachedMetadata) | 659 OnReceivedCachedMetadata) |
| 653 IPC_MESSAGE_HANDLER(ResourceMsg_ReceivedRedirect, OnReceivedRedirect) | 660 IPC_MESSAGE_HANDLER(ResourceMsg_ReceivedRedirect, OnReceivedRedirect) |
| 654 IPC_MESSAGE_HANDLER(ResourceMsg_SetDataBuffer, OnSetDataBuffer) | 661 IPC_MESSAGE_HANDLER(ResourceMsg_SetDataBuffer, OnSetDataBuffer) |
| 655 IPC_MESSAGE_HANDLER(ResourceMsg_DataReceived, OnReceivedData) | 662 IPC_MESSAGE_HANDLER(ResourceMsg_DataReceived, OnReceivedData) |
| 656 IPC_MESSAGE_HANDLER(ResourceMsg_DataDownloaded, OnDownloadedData) | 663 IPC_MESSAGE_HANDLER(ResourceMsg_DataDownloaded, OnDownloadedData) |
| 657 IPC_MESSAGE_HANDLER(ResourceMsg_RequestComplete, OnRequestComplete) | 664 IPC_MESSAGE_HANDLER(ResourceMsg_RequestComplete, OnRequestComplete) |
| 665 IPC_MESSAGE_HANDLER(ResourceMsg_RequestDidStartForFrame, |
| 666 OnRequestDidStartForFrame) |
| 658 IPC_END_MESSAGE_MAP() | 667 IPC_END_MESSAGE_MAP() |
| 659 } | 668 } |
| 660 | 669 |
| 661 void ResourceDispatcher::FlushDeferredMessages(int request_id) { | 670 void ResourceDispatcher::FlushDeferredMessages(int request_id) { |
| 662 PendingRequestList::iterator it = pending_requests_.find(request_id); | 671 PendingRequestList::iterator it = pending_requests_.find(request_id); |
| 663 if (it == pending_requests_.end()) // The request could have become invalid. | 672 if (it == pending_requests_.end()) // The request could have become invalid. |
| 664 return; | 673 return; |
| 665 PendingRequestInfo& request_info = it->second; | 674 PendingRequestInfo& request_info = it->second; |
| 666 if (request_info.is_deferred) | 675 if (request_info.is_deferred) |
| 667 return; | 676 return; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 const IPC::Message& message) { | 766 const IPC::Message& message) { |
| 758 switch (message.type()) { | 767 switch (message.type()) { |
| 759 case ResourceMsg_UploadProgress::ID: | 768 case ResourceMsg_UploadProgress::ID: |
| 760 case ResourceMsg_ReceivedResponse::ID: | 769 case ResourceMsg_ReceivedResponse::ID: |
| 761 case ResourceMsg_ReceivedCachedMetadata::ID: | 770 case ResourceMsg_ReceivedCachedMetadata::ID: |
| 762 case ResourceMsg_ReceivedRedirect::ID: | 771 case ResourceMsg_ReceivedRedirect::ID: |
| 763 case ResourceMsg_SetDataBuffer::ID: | 772 case ResourceMsg_SetDataBuffer::ID: |
| 764 case ResourceMsg_DataReceived::ID: | 773 case ResourceMsg_DataReceived::ID: |
| 765 case ResourceMsg_DataDownloaded::ID: | 774 case ResourceMsg_DataDownloaded::ID: |
| 766 case ResourceMsg_RequestComplete::ID: | 775 case ResourceMsg_RequestComplete::ID: |
| 776 case ResourceMsg_RequestDidStartForFrame::ID: |
| 767 return true; | 777 return true; |
| 768 | 778 |
| 769 default: | 779 default: |
| 770 break; | 780 break; |
| 771 } | 781 } |
| 772 | 782 |
| 773 return false; | 783 return false; |
| 774 } | 784 } |
| 775 | 785 |
| 776 // static | 786 // static |
| (...skipping 23 matching lines...) Expand all Loading... |
| 800 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { | 810 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { |
| 801 while (!queue->empty()) { | 811 while (!queue->empty()) { |
| 802 IPC::Message* message = queue->front(); | 812 IPC::Message* message = queue->front(); |
| 803 ReleaseResourcesInDataMessage(*message); | 813 ReleaseResourcesInDataMessage(*message); |
| 804 queue->pop_front(); | 814 queue->pop_front(); |
| 805 delete message; | 815 delete message; |
| 806 } | 816 } |
| 807 } | 817 } |
| 808 | 818 |
| 809 } // namespace content | 819 } // namespace content |
| OLD | NEW |