| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 delegate_(NULL), | 73 delegate_(NULL), |
| 74 io_timestamp_(base::TimeTicks()), | 74 io_timestamp_(base::TimeTicks()), |
| 75 main_thread_task_runner_(main_thread_task_runner), | 75 main_thread_task_runner_(main_thread_task_runner), |
| 76 weak_factory_(this) { | 76 weak_factory_(this) { |
| 77 } | 77 } |
| 78 | 78 |
| 79 ResourceDispatcher::~ResourceDispatcher() { | 79 ResourceDispatcher::~ResourceDispatcher() { |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { | 82 bool ResourceDispatcher::OnMessageReceived(const IPC::Message& message) { |
| 83 // TODO(erikchen): Temporary code to help track http://crbug.com/527588. | |
| 84 content::CheckContentsOfDataReceivedMessage(&message); | |
| 85 | |
| 86 if (!IsResourceDispatcherMessage(message)) { | 83 if (!IsResourceDispatcherMessage(message)) { |
| 87 return false; | 84 return false; |
| 88 } | 85 } |
| 89 | 86 |
| 90 int request_id; | 87 int request_id; |
| 91 | 88 |
| 92 base::PickleIterator iter(message); | 89 base::PickleIterator iter(message); |
| 93 if (!iter.ReadInt(&request_id)) { | 90 if (!iter.ReadInt(&request_id)) { |
| 94 NOTREACHED() << "malformed resource message"; | 91 NOTREACHED() << "malformed resource message"; |
| 95 return true; | 92 return true; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 212 |
| 216 void ResourceDispatcher::OnReceivedData(int request_id, | 213 void ResourceDispatcher::OnReceivedData(int request_id, |
| 217 int data_offset, | 214 int data_offset, |
| 218 int data_length, | 215 int data_length, |
| 219 int encoded_data_length) { | 216 int encoded_data_length) { |
| 220 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedData"); | 217 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedData"); |
| 221 DCHECK_GT(data_length, 0); | 218 DCHECK_GT(data_length, 0); |
| 222 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 219 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 223 bool send_ack = true; | 220 bool send_ack = true; |
| 224 if (request_info && data_length > 0) { | 221 if (request_info && data_length > 0) { |
| 225 // TODO(erikchen): Temporary code to help track http://crbug.com/527588. | |
| 226 int buffer_size = request_info->buffer_size; | |
| 227 | |
| 228 CHECK(base::SharedMemory::IsHandleValid(request_info->buffer->handle())); | 222 CHECK(base::SharedMemory::IsHandleValid(request_info->buffer->handle())); |
| 229 CHECK_GE(request_info->buffer_size, data_offset + data_length); | 223 CHECK_GE(request_info->buffer_size, data_offset + data_length); |
| 230 | 224 |
| 231 // TODO(erikchen): Temporary code to help track http://crbug.com/527588. | |
| 232 base::debug::Alias(request_info); | |
| 233 base::debug::Alias(&buffer_size); | |
| 234 | |
| 235 // Ensure that the SHM buffer remains valid for the duration of this scope. | 225 // Ensure that the SHM buffer remains valid for the duration of this scope. |
| 236 // It is possible for Cancel() to be called before we exit this scope. | 226 // It is possible for Cancel() to be called before we exit this scope. |
| 237 // SharedMemoryReceivedDataFactory stores the SHM buffer inside it. | 227 // SharedMemoryReceivedDataFactory stores the SHM buffer inside it. |
| 238 scoped_refptr<SharedMemoryReceivedDataFactory> factory( | 228 scoped_refptr<SharedMemoryReceivedDataFactory> factory( |
| 239 request_info->received_data_factory); | 229 request_info->received_data_factory); |
| 240 | 230 |
| 241 base::TimeTicks time_start = base::TimeTicks::Now(); | 231 base::TimeTicks time_start = base::TimeTicks::Now(); |
| 242 | 232 |
| 243 const char* data_start = static_cast<char*>(request_info->buffer->memory()); | 233 const char* data_start = static_cast<char*>(request_info->buffer->memory()); |
| 244 CHECK(data_start); | 234 CHECK(data_start); |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 extra_data->transferred_request_request_id(); | 788 extra_data->transferred_request_request_id(); |
| 799 request->service_worker_provider_id = | 789 request->service_worker_provider_id = |
| 800 extra_data->service_worker_provider_id(); | 790 extra_data->service_worker_provider_id(); |
| 801 request->request_body = request_body; | 791 request->request_body = request_body; |
| 802 if (frame_origin) | 792 if (frame_origin) |
| 803 *frame_origin = extra_data->frame_origin(); | 793 *frame_origin = extra_data->frame_origin(); |
| 804 return request.Pass(); | 794 return request.Pass(); |
| 805 } | 795 } |
| 806 | 796 |
| 807 } // namespace content | 797 } // namespace content |
| OLD | NEW |