Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: content/child/resource_dispatcher.cc

Issue 2510333002: Send encoded_body_length to renderer when response completed (2/3) (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // Check whether this response data is compliant with our cross-site 320 // 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. 321 // document blocking policy. We only do this for the first chunk of data.
322 if (request_info->site_isolation_metadata.get()) { 322 if (request_info->site_isolation_metadata.get()) {
323 SiteIsolationStatsGatherer::OnReceivedFirstChunk( 323 SiteIsolationStatsGatherer::OnReceivedFirstChunk(
324 request_info->site_isolation_metadata, data.data(), data.size()); 324 request_info->site_isolation_metadata, data.data(), data.size());
325 request_info->site_isolation_metadata.reset(); 325 request_info->site_isolation_metadata.reset();
326 } 326 }
327 327
328 DCHECK(!request_info->buffer.get()); 328 DCHECK(!request_info->buffer.get());
329 329
330 std::unique_ptr<RequestPeer::ReceivedData> received_data( 330 request_info->peer->OnReceivedData(
331 new content::FixedReceivedData(data, encoded_data_length, 331 base::MakeUnique<content::FixedReceivedData>(data, encoded_data_length));
332 encoded_body_length));
333 request_info->peer->OnReceivedData(std::move(received_data));
334 } 332 }
335 333
336 void ResourceDispatcher::OnReceivedData(int request_id, 334 void ResourceDispatcher::OnReceivedData(int request_id,
337 int data_offset, 335 int data_offset,
338 int data_length, 336 int data_length,
339 int encoded_data_length, 337 int encoded_data_length,
340 int encoded_body_length) { 338 int encoded_body_length) {
341 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedData"); 339 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedData");
342 DCHECK_GT(data_length, 0); 340 DCHECK_GT(data_length, 0);
343 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); 341 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
344 bool send_ack = true; 342 bool send_ack = true;
345 if (request_info && data_length > 0) { 343 if (request_info && data_length > 0) {
346 CHECK(base::SharedMemory::IsHandleValid(request_info->buffer->handle())); 344 CHECK(base::SharedMemory::IsHandleValid(request_info->buffer->handle()));
347 CHECK_GE(request_info->buffer_size, data_offset + data_length); 345 CHECK_GE(request_info->buffer_size, data_offset + data_length);
348 346
349 const char* data_start = static_cast<char*>(request_info->buffer->memory()); 347 const char* data_start = static_cast<char*>(request_info->buffer->memory());
350 CHECK(data_start); 348 CHECK(data_start);
351 CHECK(data_start + data_offset); 349 CHECK(data_start + data_offset);
352 const char* data_ptr = data_start + data_offset; 350 const char* data_ptr = data_start + data_offset;
353 351
354 // Check whether this response data is compliant with our cross-site 352 // Check whether this response data is compliant with our cross-site
355 // document blocking policy. We only do this for the first chunk of data. 353 // document blocking policy. We only do this for the first chunk of data.
356 if (request_info->site_isolation_metadata.get()) { 354 if (request_info->site_isolation_metadata.get()) {
357 SiteIsolationStatsGatherer::OnReceivedFirstChunk( 355 SiteIsolationStatsGatherer::OnReceivedFirstChunk(
358 request_info->site_isolation_metadata, data_ptr, data_length); 356 request_info->site_isolation_metadata, data_ptr, data_length);
359 request_info->site_isolation_metadata.reset(); 357 request_info->site_isolation_metadata.reset();
360 } 358 }
361 359
362 std::unique_ptr<RequestPeer::ReceivedData> data = 360 std::unique_ptr<RequestPeer::ReceivedData> data =
363 request_info->received_data_factory->Create( 361 request_info->received_data_factory->Create(data_offset, data_length,
364 data_offset, data_length, encoded_data_length, encoded_body_length); 362 encoded_data_length);
365 // |data| takes care of ACKing. 363 // |data| takes care of ACKing.
366 send_ack = false; 364 send_ack = false;
367 request_info->peer->OnReceivedData(std::move(data)); 365 request_info->peer->OnReceivedData(std::move(data));
368 } 366 }
369 367
370 // Acknowledge the reception of this data. 368 // Acknowledge the reception of this data.
371 if (send_ack) 369 if (send_ack)
372 message_sender_->Send(new ResourceHostMsg_DataReceived_ACK(request_id)); 370 message_sender_->Send(new ResourceHostMsg_DataReceived_ACK(request_id));
373 } 371 }
374 372
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 // The request ID will be removed from our pending list in the destructor. 457 // The request ID will be removed from our pending list in the destructor.
460 // Normally, dispatching this message causes the reference-counted request to 458 // Normally, dispatching this message causes the reference-counted request to
461 // die immediately. 459 // die immediately.
462 // TODO(kinuko): Revisit here. This probably needs to call request_info->peer 460 // TODO(kinuko): Revisit here. This probably needs to call request_info->peer
463 // but the past attempt to change it seems to have caused crashes. 461 // but the past attempt to change it seems to have caused crashes.
464 // (crbug.com/547047) 462 // (crbug.com/547047)
465 peer->OnCompletedRequest(request_complete_data.error_code, 463 peer->OnCompletedRequest(request_complete_data.error_code,
466 request_complete_data.was_ignored_by_handler, 464 request_complete_data.was_ignored_by_handler,
467 request_complete_data.exists_in_cache, 465 request_complete_data.exists_in_cache,
468 renderer_completion_time, 466 renderer_completion_time,
469 request_complete_data.encoded_data_length); 467 request_complete_data.encoded_data_length,
468 request_complete_data.encoded_body_length);
470 } 469 }
471 470
472 bool ResourceDispatcher::RemovePendingRequest(int request_id) { 471 bool ResourceDispatcher::RemovePendingRequest(int request_id) {
473 PendingRequestMap::iterator it = pending_requests_.find(request_id); 472 PendingRequestMap::iterator it = pending_requests_.find(request_id);
474 if (it == pending_requests_.end()) 473 if (it == pending_requests_.end())
475 return false; 474 return false;
476 475
477 PendingRequestInfo* request_info = it->second.get(); 476 PendingRequestInfo* request_info = it->second.get();
478 477
479 bool release_downloaded_file = request_info->download_to_file; 478 bool release_downloaded_file = request_info->download_to_file;
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 delete message; 850 delete message;
852 } 851 }
853 } 852 }
854 853
855 void ResourceDispatcher::SetResourceSchedulingFilter( 854 void ResourceDispatcher::SetResourceSchedulingFilter(
856 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { 855 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) {
857 resource_scheduling_filter_ = resource_scheduling_filter; 856 resource_scheduling_filter_ = resource_scheduling_filter;
858 } 857 }
859 858
860 } // namespace content 859 } // namespace content
OLDNEW
« no previous file with comments | « content/child/ftp_directory_listing_response_delegate.cc ('k') | content/child/resource_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698