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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 299 |
300 // TODO(erikchen): Temporary debugging. http://crbug.com/527588. | 300 // TODO(erikchen): Temporary debugging. http://crbug.com/527588. |
301 CHECK_GE(shm_size, 0); | 301 CHECK_GE(shm_size, 0); |
302 CHECK_LE(shm_size, 512 * 1024); | 302 CHECK_LE(shm_size, 512 * 1024); |
303 request_info->buffer_size = shm_size; | 303 request_info->buffer_size = shm_size; |
304 } | 304 } |
305 | 305 |
306 void ResourceDispatcher::OnReceivedInlinedDataChunk( | 306 void ResourceDispatcher::OnReceivedInlinedDataChunk( |
307 int request_id, | 307 int request_id, |
308 const std::vector<char>& data, | 308 const std::vector<char>& data, |
309 int encoded_data_length, | 309 int encoded_data_length) { |
310 int encoded_body_length) { | |
311 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedInlinedDataChunk"); | 310 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedInlinedDataChunk"); |
312 DCHECK(!data.empty()); | 311 DCHECK(!data.empty()); |
313 DCHECK(base::FeatureList::IsEnabled( | 312 DCHECK(base::FeatureList::IsEnabled( |
314 features::kOptimizeLoadingIPCForSmallResources)); | 313 features::kOptimizeLoadingIPCForSmallResources)); |
315 | 314 |
316 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 315 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
317 if (!request_info || data.empty()) | 316 if (!request_info || data.empty()) |
318 return; | 317 return; |
319 | 318 |
320 // Check whether this response data is compliant with our cross-site | 319 // Check whether this response data is compliant with our cross-site |
321 // document blocking policy. We only do this for the first chunk of data. | 320 // document blocking policy. We only do this for the first chunk of data. |
322 if (request_info->site_isolation_metadata.get()) { | 321 if (request_info->site_isolation_metadata.get()) { |
323 SiteIsolationStatsGatherer::OnReceivedFirstChunk( | 322 SiteIsolationStatsGatherer::OnReceivedFirstChunk( |
324 request_info->site_isolation_metadata, data.data(), data.size()); | 323 request_info->site_isolation_metadata, data.data(), data.size()); |
325 request_info->site_isolation_metadata.reset(); | 324 request_info->site_isolation_metadata.reset(); |
326 } | 325 } |
327 | 326 |
328 DCHECK(!request_info->buffer.get()); | 327 DCHECK(!request_info->buffer.get()); |
329 | 328 |
330 request_info->peer->OnReceivedData( | 329 request_info->peer->OnReceivedData( |
331 base::MakeUnique<content::FixedReceivedData>(data, encoded_data_length)); | 330 base::MakeUnique<content::FixedReceivedData>(data, encoded_data_length)); |
332 } | 331 } |
333 | 332 |
334 void ResourceDispatcher::OnReceivedData(int request_id, | 333 void ResourceDispatcher::OnReceivedData(int request_id, |
335 int data_offset, | 334 int data_offset, |
336 int data_length, | 335 int data_length, |
337 int encoded_data_length, | 336 int encoded_data_length) { |
338 int encoded_body_length) { | |
339 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedData"); | 337 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedData"); |
340 DCHECK_GT(data_length, 0); | 338 DCHECK_GT(data_length, 0); |
341 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 339 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
342 bool send_ack = true; | 340 bool send_ack = true; |
343 if (request_info && data_length > 0) { | 341 if (request_info && data_length > 0) { |
344 CHECK(base::SharedMemory::IsHandleValid(request_info->buffer->handle())); | 342 CHECK(base::SharedMemory::IsHandleValid(request_info->buffer->handle())); |
345 CHECK_GE(request_info->buffer_size, data_offset + data_length); | 343 CHECK_GE(request_info->buffer_size, data_offset + data_length); |
346 | 344 |
347 const char* data_start = static_cast<char*>(request_info->buffer->memory()); | 345 const char* data_start = static_cast<char*>(request_info->buffer->memory()); |
348 CHECK(data_start); | 346 CHECK(data_start); |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 delete message; | 848 delete message; |
851 } | 849 } |
852 } | 850 } |
853 | 851 |
854 void ResourceDispatcher::SetResourceSchedulingFilter( | 852 void ResourceDispatcher::SetResourceSchedulingFilter( |
855 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { | 853 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { |
856 resource_scheduling_filter_ = resource_scheduling_filter; | 854 resource_scheduling_filter_ = resource_scheduling_filter; |
857 } | 855 } |
858 | 856 |
859 } // namespace content | 857 } // namespace content |
OLD | NEW |