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

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

Issue 2646343007: [Mojo-Loading] Implement URLLoader::SetPriority (Closed)
Patch Set: rebase 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 }
kinuko 2017/01/25 03:48:31 Could these use enum traits?
yhirano 2017/01/27 07:53:55 Done.
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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 522
502 main_thread_task_runner_->PostTask( 523 main_thread_task_runner_->PostTask(
503 FROM_HERE, base::Bind(&ResourceDispatcher::FlushDeferredMessages, 524 FROM_HERE, base::Bind(&ResourceDispatcher::FlushDeferredMessages,
504 weak_factory_.GetWeakPtr(), request_id)); 525 weak_factory_.GetWeakPtr(), request_id));
505 } 526 }
506 } 527 }
507 528
508 void ResourceDispatcher::DidChangePriority(int request_id, 529 void ResourceDispatcher::DidChangePriority(int request_id,
509 net::RequestPriority new_priority, 530 net::RequestPriority new_priority,
510 int intra_priority_value) { 531 int intra_priority_value) {
511 DCHECK(base::ContainsKey(pending_requests_, request_id)); 532 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
512 message_sender_->Send(new ResourceHostMsg_DidChangePriority( 533 DCHECK(request_info);
513 request_id, new_priority, intra_priority_value)); 534 if (request_info->url_loader) {
535 request_info->url_loader->SetPriority(
536 MojoRequestPriorityForNetRequestPriority(new_priority),
537 intra_priority_value);
538 } else {
539 message_sender_->Send(new ResourceHostMsg_DidChangePriority(
540 request_id, new_priority, intra_priority_value));
541 }
514 } 542 }
515 543
516 void ResourceDispatcher::OnTransferSizeUpdated(int request_id, 544 void ResourceDispatcher::OnTransferSizeUpdated(int request_id,
517 int32_t transfer_size_diff) { 545 int32_t transfer_size_diff) {
518 DCHECK_GT(transfer_size_diff, 0); 546 DCHECK_GT(transfer_size_diff, 0);
519 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); 547 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
520 if (!request_info) 548 if (!request_info)
521 return; 549 return;
522 550
523 // TODO(yhirano): Consider using int64_t in 551 // TODO(yhirano): Consider using int64_t in
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 delete message; 845 delete message;
818 } 846 }
819 } 847 }
820 848
821 void ResourceDispatcher::SetResourceSchedulingFilter( 849 void ResourceDispatcher::SetResourceSchedulingFilter(
822 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { 850 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) {
823 resource_scheduling_filter_ = resource_scheduling_filter; 851 resource_scheduling_filter_ = resource_scheduling_filter;
824 } 852 }
825 853
826 } // namespace content 854 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_fetch_dispatcher.cc ('k') | content/common/url_loader.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698