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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 ResourceDispatcher::~ResourceDispatcher() { | 77 ResourceDispatcher::~ResourceDispatcher() { |
78 } | 78 } |
79 | 79 |
80 bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { | 80 bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { |
81 if (!IsResourceDispatcherMessage(message)) { | 81 if (!IsResourceDispatcherMessage(message)) { |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 int request_id; | 85 int request_id; |
86 | 86 |
87 PickleIterator iter(message); | 87 base::PickleIterator iter(message); |
88 if (!iter.ReadInt(&request_id)) { | 88 if (!iter.ReadInt(&request_id)) { |
89 NOTREACHED() << "malformed resource message"; | 89 NOTREACHED() << "malformed resource message"; |
90 return true; | 90 return true; |
91 } | 91 } |
92 | 92 |
93 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 93 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
94 if (!request_info) { | 94 if (!request_info) { |
95 // Release resources in the message if it is a data message. | 95 // Release resources in the message if it is a data message. |
96 ReleaseResourcesInDataMessage(message); | 96 ReleaseResourcesInDataMessage(message); |
97 return true; | 97 return true; |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 default: | 692 default: |
693 break; | 693 break; |
694 } | 694 } |
695 | 695 |
696 return false; | 696 return false; |
697 } | 697 } |
698 | 698 |
699 // static | 699 // static |
700 void ResourceDispatcher::ReleaseResourcesInDataMessage( | 700 void ResourceDispatcher::ReleaseResourcesInDataMessage( |
701 const IPC::Message& message) { | 701 const IPC::Message& message) { |
702 PickleIterator iter(message); | 702 base::PickleIterator iter(message); |
703 int request_id; | 703 int request_id; |
704 if (!iter.ReadInt(&request_id)) { | 704 if (!iter.ReadInt(&request_id)) { |
705 NOTREACHED() << "malformed resource message"; | 705 NOTREACHED() << "malformed resource message"; |
706 return; | 706 return; |
707 } | 707 } |
708 | 708 |
709 // If the message contains a shared memory handle, we should close the handle | 709 // If the message contains a shared memory handle, we should close the handle |
710 // or there will be a memory leak. | 710 // or there will be a memory leak. |
711 if (message.type() == ResourceMsg_SetDataBuffer::ID) { | 711 if (message.type() == ResourceMsg_SetDataBuffer::ID) { |
712 base::SharedMemoryHandle shm_handle; | 712 base::SharedMemoryHandle shm_handle; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 extra_data->transferred_request_request_id(); | 790 extra_data->transferred_request_request_id(); |
791 request->service_worker_provider_id = | 791 request->service_worker_provider_id = |
792 extra_data->service_worker_provider_id(); | 792 extra_data->service_worker_provider_id(); |
793 request->request_body = request_body; | 793 request->request_body = request_body; |
794 if (frame_origin) | 794 if (frame_origin) |
795 *frame_origin = extra_data->frame_origin(); | 795 *frame_origin = extra_data->frame_origin(); |
796 return request.Pass(); | 796 return request.Pass(); |
797 } | 797 } |
798 | 798 |
799 } // namespace content | 799 } // namespace content |
OLD | NEW |