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

Side by Side Diff: content/browser/loader/resource_scheduler.cc

Issue 2807163002: [Prerender] Restore request priorities when swapped in (Closed)
Patch Set: Fix test: default image priority can be LOWEST or MEDIUM Created 3 years, 8 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 #include "content/browser/loader/resource_scheduler.h" 5 #include "content/browser/loader/resource_scheduler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 DCHECK(!request_->GetUserData(kUserDataKey)); 230 DCHECK(!request_->GetUserData(kUserDataKey));
231 request_->SetUserData(kUserDataKey, new UnownedPointer(this)); 231 request_->SetUserData(kUserDataKey, new UnownedPointer(this));
232 } 232 }
233 233
234 ~ScheduledResourceRequest() override { 234 ~ScheduledResourceRequest() override {
235 request_->RemoveUserData(kUserDataKey); 235 request_->RemoveUserData(kUserDataKey);
236 scheduler_->RemoveRequest(this); 236 scheduler_->RemoveRequest(this);
237 } 237 }
238 238
239 static ScheduledResourceRequest* ForRequest(net::URLRequest* request) { 239 static ScheduledResourceRequest* ForRequest(net::URLRequest* request) {
240 return static_cast<UnownedPointer*>(request->GetUserData(kUserDataKey)) 240 UnownedPointer* pointer =
241 ->get(); 241 static_cast<UnownedPointer*>(request->GetUserData(kUserDataKey));
242 return pointer ? pointer->get() : nullptr;
242 } 243 }
243 244
244 // Starts the request. If |start_mode| is START_ASYNC, the request will not 245 // Starts the request. If |start_mode| is START_ASYNC, the request will not
245 // be started immediately. 246 // be started immediately.
246 void Start(StartMode start_mode) { 247 void Start(StartMode start_mode) {
247 DCHECK(!ready_); 248 DCHECK(!ready_);
248 249
249 // If the request was cancelled, do nothing. 250 // If the request was cancelled, do nothing.
250 if (!request_->status().is_success()) 251 if (!request_->status().is_success())
251 return; 252 return;
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 scheduled_resource_request->set_request_priority_params( 1074 scheduled_resource_request->set_request_priority_params(
1074 new_priority_params); 1075 new_priority_params);
1075 return; 1076 return;
1076 } 1077 }
1077 1078
1078 Client* client = client_it->second; 1079 Client* client = client_it->second;
1079 client->ReprioritizeRequest(scheduled_resource_request, old_priority_params, 1080 client->ReprioritizeRequest(scheduled_resource_request, old_priority_params,
1080 new_priority_params); 1081 new_priority_params);
1081 } 1082 }
1082 1083
1084 void ResourceScheduler::ReprioritizeRequest(net::URLRequest* request,
1085 net::RequestPriority new_priority) {
1086 int current_intra_priority = 0;
1087 auto* existing_request = ScheduledResourceRequest::ForRequest(request);
1088 if (existing_request) {
1089 current_intra_priority =
1090 existing_request->get_request_priority_params().intra_priority;
1091 }
1092 ReprioritizeRequest(request, new_priority, current_intra_priority);
1093 }
1094
1083 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( 1095 ResourceScheduler::ClientId ResourceScheduler::MakeClientId(
1084 int child_id, int route_id) { 1096 int child_id, int route_id) {
1085 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; 1097 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id;
1086 } 1098 }
1087 1099
1088 } // namespace content 1100 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_scheduler.h ('k') | content/public/browser/resource_dispatcher_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698