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

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

Issue 2646343007: [Mojo-Loading] Implement URLLoader::SetPriority (Closed)
Patch Set: fix Created 3 years, 11 months 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 blink::WebReferrerPolicyNoReferrerWhenDowngrade) && 80 blink::WebReferrerPolicyNoReferrerWhenDowngrade) &&
81 request.referrer.SchemeIsCryptographic() && 81 request.referrer.SchemeIsCryptographic() &&
82 !request.url.SchemeIsCryptographic()) { 82 !request.url.SchemeIsCryptographic()) {
83 LOG(FATAL) << "Trying to send secure referrer for insecure request " 83 LOG(FATAL) << "Trying to send secure referrer for insecure request "
84 << "without an appropriate referrer policy.\n" 84 << "without an appropriate referrer policy.\n"
85 << "URL = " << request.url << "\n" 85 << "URL = " << request.url << "\n"
86 << "Referrer = " << request.referrer; 86 << "Referrer = " << request.referrer;
87 } 87 }
88 } 88 }
89 89
90 mojom::RequestPriority MojoRequestPriorityForNetRequestPriority(
91 net::RequestPriority priority) {
92 switch (priority) {
93 case net::THROTTLED:
94 return mojom::RequestPriority::kThrottled;
95 case net::IDLE:
96 return mojom::RequestPriority::kIdle;
97 case net::LOWEST:
98 return mojom::RequestPriority::kLowest;
99 case net::LOW:
100 return mojom::RequestPriority::kLow;
101 case net::MEDIUM:
102 return mojom::RequestPriority::kMedium;
103 case net::HIGHEST:
104 return mojom::RequestPriority::kHighest;
105 }
106
107 NOTREACHED();
108 return static_cast<mojom::RequestPriority>(priority);
109 }
110
90 } // namespace 111 } // namespace
91 112
92 ResourceDispatcher::ResourceDispatcher( 113 ResourceDispatcher::ResourceDispatcher(
93 IPC::Sender* sender, 114 IPC::Sender* sender,
94 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) 115 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner)
95 : message_sender_(sender), 116 : message_sender_(sender),
96 delegate_(NULL), 117 delegate_(NULL),
97 io_timestamp_(base::TimeTicks()), 118 io_timestamp_(base::TimeTicks()),
98 main_thread_task_runner_(main_thread_task_runner), 119 main_thread_task_runner_(main_thread_task_runner),
99 weak_factory_(this) { 120 weak_factory_(this) {
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 518
498 main_thread_task_runner_->PostTask( 519 main_thread_task_runner_->PostTask(
499 FROM_HERE, base::Bind(&ResourceDispatcher::FlushDeferredMessages, 520 FROM_HERE, base::Bind(&ResourceDispatcher::FlushDeferredMessages,
500 weak_factory_.GetWeakPtr(), request_id)); 521 weak_factory_.GetWeakPtr(), request_id));
501 } 522 }
502 } 523 }
503 524
504 void ResourceDispatcher::DidChangePriority(int request_id, 525 void ResourceDispatcher::DidChangePriority(int request_id,
505 net::RequestPriority new_priority, 526 net::RequestPriority new_priority,
506 int intra_priority_value) { 527 int intra_priority_value) {
507 DCHECK(base::ContainsKey(pending_requests_, request_id)); 528 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
508 message_sender_->Send(new ResourceHostMsg_DidChangePriority( 529 DCHECK(request_info);
509 request_id, new_priority, intra_priority_value)); 530 if (request_info->url_loader) {
531 request_info->url_loader->SetPriority(
532 MojoRequestPriorityForNetRequestPriority(new_priority),
533 intra_priority_value);
534 } else {
535 message_sender_->Send(new ResourceHostMsg_DidChangePriority(
536 request_id, new_priority, intra_priority_value));
537 }
510 } 538 }
511 539
512 void ResourceDispatcher::OnTransferSizeUpdated(int request_id, 540 void ResourceDispatcher::OnTransferSizeUpdated(int request_id,
513 int32_t transfer_size_diff) { 541 int32_t transfer_size_diff) {
514 DCHECK_GT(transfer_size_diff, 0); 542 DCHECK_GT(transfer_size_diff, 0);
515 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); 543 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
516 if (!request_info) 544 if (!request_info)
517 return; 545 return;
518 546
519 // TODO(yhirano): Consider using int64_t in 547 // TODO(yhirano): Consider using int64_t in
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 delete message; 841 delete message;
814 } 842 }
815 } 843 }
816 844
817 void ResourceDispatcher::SetResourceSchedulingFilter( 845 void ResourceDispatcher::SetResourceSchedulingFilter(
818 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { 846 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) {
819 resource_scheduling_filter_ = resource_scheduling_filter; 847 resource_scheduling_filter_ = resource_scheduling_filter;
820 } 848 }
821 849
822 } // namespace content 850 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698