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

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

Issue 2566943002: Dispatch transfer size update notification on mojo-loading (Closed)
Patch Set: fix 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
« no previous file with comments | « content/child/resource_dispatcher.h ('k') | content/common/url_loader.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 DCHECK(!body_consumer_); 107 DCHECK(!body_consumer_);
108 resource_dispatcher_->OnMessageReceived(ResourceMsg_ReceivedRedirect( 108 resource_dispatcher_->OnMessageReceived(ResourceMsg_ReceivedRedirect(
109 request_id_, redirect_info, response_head)); 109 request_id_, redirect_info, response_head));
110 } 110 }
111 111
112 void OnDataDownloaded(int64_t data_len, int64_t encoded_data_len) override { 112 void OnDataDownloaded(int64_t data_len, int64_t encoded_data_len) override {
113 resource_dispatcher_->OnMessageReceived( 113 resource_dispatcher_->OnMessageReceived(
114 ResourceMsg_DataDownloaded(request_id_, data_len, encoded_data_len)); 114 ResourceMsg_DataDownloaded(request_id_, data_len, encoded_data_len));
115 } 115 }
116 116
117 void OnTransferSizeUpdated(int32_t transfer_size_diff) override {
118 resource_dispatcher_->OnTransferSizeUpdated(request_id_,
119 transfer_size_diff);
120 }
121
117 void OnStartLoadingResponseBody( 122 void OnStartLoadingResponseBody(
118 mojo::ScopedDataPipeConsumerHandle body) override { 123 mojo::ScopedDataPipeConsumerHandle body) override {
119 DCHECK(!body_consumer_); 124 DCHECK(!body_consumer_);
120 body_consumer_ = new URLResponseBodyConsumer( 125 body_consumer_ = new URLResponseBodyConsumer(
121 request_id_, resource_dispatcher_, std::move(body), task_runner_); 126 request_id_, resource_dispatcher_, std::move(body), task_runner_);
122 if (has_received_response_) 127 if (has_received_response_)
123 body_consumer_->Start(); 128 body_consumer_->Start();
124 } 129 }
125 130
126 void OnComplete(const ResourceRequestCompletionStatus& status) override { 131 void OnComplete(const ResourceRequestCompletionStatus& status) override {
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 547 }
543 } 548 }
544 // Cancel the request if it didn't complete, and clean it up so the bridge 549 // Cancel the request if it didn't complete, and clean it up so the bridge
545 // will receive no more messages. 550 // will receive no more messages.
546 if (info.completion_time.is_null()) 551 if (info.completion_time.is_null())
547 message_sender_->Send(new ResourceHostMsg_CancelRequest(request_id)); 552 message_sender_->Send(new ResourceHostMsg_CancelRequest(request_id));
548 RemovePendingRequest(request_id); 553 RemovePendingRequest(request_id);
549 } 554 }
550 555
551 void ResourceDispatcher::SetDefersLoading(int request_id, bool value) { 556 void ResourceDispatcher::SetDefersLoading(int request_id, bool value) {
552 PendingRequestMap::iterator it = pending_requests_.find(request_id); 557 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
553 if (it == pending_requests_.end()) { 558 if (!request_info) {
554 DLOG(ERROR) << "unknown request"; 559 DLOG(ERROR) << "unknown request";
555 return; 560 return;
556 } 561 }
557 PendingRequestInfo* request_info = it->second.get();
558 if (value) { 562 if (value) {
559 request_info->is_deferred = value; 563 request_info->is_deferred = value;
560 } else if (request_info->is_deferred) { 564 } else if (request_info->is_deferred) {
561 request_info->is_deferred = false; 565 request_info->is_deferred = false;
562 566
563 FollowPendingRedirect(request_id, request_info); 567 FollowPendingRedirect(request_id, request_info);
564 568
565 main_thread_task_runner_->PostTask( 569 main_thread_task_runner_->PostTask(
566 FROM_HERE, base::Bind(&ResourceDispatcher::FlushDeferredMessages, 570 FROM_HERE, base::Bind(&ResourceDispatcher::FlushDeferredMessages,
567 weak_factory_.GetWeakPtr(), request_id)); 571 weak_factory_.GetWeakPtr(), request_id));
568 } 572 }
569 } 573 }
570 574
571 void ResourceDispatcher::DidChangePriority(int request_id, 575 void ResourceDispatcher::DidChangePriority(int request_id,
572 net::RequestPriority new_priority, 576 net::RequestPriority new_priority,
573 int intra_priority_value) { 577 int intra_priority_value) {
574 DCHECK(base::ContainsKey(pending_requests_, request_id)); 578 DCHECK(base::ContainsKey(pending_requests_, request_id));
575 message_sender_->Send(new ResourceHostMsg_DidChangePriority( 579 message_sender_->Send(new ResourceHostMsg_DidChangePriority(
576 request_id, new_priority, intra_priority_value)); 580 request_id, new_priority, intra_priority_value));
577 } 581 }
578 582
583 void ResourceDispatcher::OnTransferSizeUpdated(int request_id,
584 int32_t transfer_size_diff) {
585 DCHECK_GT(transfer_size_diff, 0);
586 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
587 if (!request_info)
588 return;
589
590 // TODO(yhirano): Consider using int64_t in
591 // RequestPeer::OnTransferSizeUpdated.
592 request_info->peer->OnTransferSizeUpdated(transfer_size_diff);
593 }
594
579 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo( 595 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo(
580 std::unique_ptr<RequestPeer> peer, 596 std::unique_ptr<RequestPeer> peer,
581 ResourceType resource_type, 597 ResourceType resource_type,
582 int origin_pid, 598 int origin_pid,
583 const url::Origin& frame_origin, 599 const url::Origin& frame_origin,
584 const GURL& request_url, 600 const GURL& request_url,
585 bool download_to_file) 601 bool download_to_file)
586 : peer(std::move(peer)), 602 : peer(std::move(peer)),
587 resource_type(resource_type), 603 resource_type(resource_type),
588 origin_pid(origin_pid), 604 origin_pid(origin_pid),
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 delete message; 877 delete message;
862 } 878 }
863 } 879 }
864 880
865 void ResourceDispatcher::SetResourceSchedulingFilter( 881 void ResourceDispatcher::SetResourceSchedulingFilter(
866 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { 882 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) {
867 resource_scheduling_filter_ = resource_scheduling_filter; 883 resource_scheduling_filter_ = resource_scheduling_filter;
868 } 884 }
869 885
870 } // namespace content 886 } // namespace content
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher.h ('k') | content/common/url_loader.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698