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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 // TODO(erikchen): Temporary debugging. http://crbug.com/527588. | 220 // TODO(erikchen): Temporary debugging. http://crbug.com/527588. |
221 CHECK_GE(shm_size, 0); | 221 CHECK_GE(shm_size, 0); |
222 CHECK_LE(shm_size, 512 * 1024); | 222 CHECK_LE(shm_size, 512 * 1024); |
223 request_info->buffer_size = shm_size; | 223 request_info->buffer_size = shm_size; |
224 } | 224 } |
225 | 225 |
226 void ResourceDispatcher::OnReceivedInlinedDataChunk( | 226 void ResourceDispatcher::OnReceivedInlinedDataChunk( |
227 int request_id, | 227 int request_id, |
228 const std::vector<char>& data, | 228 const std::vector<char>& data, |
229 int encoded_data_length) { | 229 int encoded_data_length, |
| 230 int encoded_body_length) { |
230 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedInlinedDataChunk"); | 231 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedInlinedDataChunk"); |
231 DCHECK(!data.empty()); | 232 DCHECK(!data.empty()); |
232 DCHECK(base::FeatureList::IsEnabled( | 233 DCHECK(base::FeatureList::IsEnabled( |
233 features::kOptimizeLoadingIPCForSmallResources)); | 234 features::kOptimizeLoadingIPCForSmallResources)); |
234 | 235 |
235 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 236 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
236 if (!request_info || data.empty()) | 237 if (!request_info || data.empty()) |
237 return; | 238 return; |
238 | 239 |
239 // Check whether this response data is compliant with our cross-site | 240 // Check whether this response data is compliant with our cross-site |
240 // document blocking policy. We only do this for the first chunk of data. | 241 // document blocking policy. We only do this for the first chunk of data. |
241 if (request_info->site_isolation_metadata.get()) { | 242 if (request_info->site_isolation_metadata.get()) { |
242 SiteIsolationStatsGatherer::OnReceivedFirstChunk( | 243 SiteIsolationStatsGatherer::OnReceivedFirstChunk( |
243 request_info->site_isolation_metadata, data.data(), data.size()); | 244 request_info->site_isolation_metadata, data.data(), data.size()); |
244 request_info->site_isolation_metadata.reset(); | 245 request_info->site_isolation_metadata.reset(); |
245 } | 246 } |
246 | 247 |
247 DCHECK(!request_info->buffer.get()); | 248 DCHECK(!request_info->buffer.get()); |
248 | 249 |
249 std::unique_ptr<RequestPeer::ReceivedData> received_data( | 250 std::unique_ptr<RequestPeer::ReceivedData> received_data( |
250 new content::FixedReceivedData(data, encoded_data_length)); | 251 new content::FixedReceivedData(data, encoded_data_length)); |
251 request_info->peer->OnReceivedData(std::move(received_data)); | 252 request_info->peer->OnReceivedData(std::move(received_data)); |
252 } | 253 } |
253 | 254 |
254 void ResourceDispatcher::OnReceivedData(int request_id, | 255 void ResourceDispatcher::OnReceivedData(int request_id, |
255 int data_offset, | 256 int data_offset, |
256 int data_length, | 257 int data_length, |
257 int encoded_data_length) { | 258 int encoded_data_length, |
| 259 int encoded_body_length) { |
258 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedData"); | 260 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedData"); |
259 DCHECK_GT(data_length, 0); | 261 DCHECK_GT(data_length, 0); |
260 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 262 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
261 bool send_ack = true; | 263 bool send_ack = true; |
262 if (request_info && data_length > 0) { | 264 if (request_info && data_length > 0) { |
263 CHECK(base::SharedMemory::IsHandleValid(request_info->buffer->handle())); | 265 CHECK(base::SharedMemory::IsHandleValid(request_info->buffer->handle())); |
264 CHECK_GE(request_info->buffer_size, data_offset + data_length); | 266 CHECK_GE(request_info->buffer_size, data_offset + data_length); |
265 | 267 |
266 const char* data_start = static_cast<char*>(request_info->buffer->memory()); | 268 const char* data_start = static_cast<char*>(request_info->buffer->memory()); |
267 CHECK(data_start); | 269 CHECK(data_start); |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 *frame_origin = extra_data->frame_origin(); | 810 *frame_origin = extra_data->frame_origin(); |
809 return request; | 811 return request; |
810 } | 812 } |
811 | 813 |
812 void ResourceDispatcher::SetResourceSchedulingFilter( | 814 void ResourceDispatcher::SetResourceSchedulingFilter( |
813 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { | 815 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { |
814 resource_scheduling_filter_ = resource_scheduling_filter; | 816 resource_scheduling_filter_ = resource_scheduling_filter; |
815 } | 817 } |
816 | 818 |
817 } // namespace content | 819 } // namespace content |
OLD | NEW |