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

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

Issue 2815913005: Switch to using scoped_ptr with UserData (Closed)
Patch Set: fixes 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
8 #include <set> 9 #include <set>
9 #include <string> 10 #include <string>
10 #include <utility> 11 #include <utility>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/feature_list.h" 14 #include "base/feature_list.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h"
15 #include "base/metrics/field_trial.h" 17 #include "base/metrics/field_trial.h"
16 #include "base/metrics/field_trial_params.h" 18 #include "base/metrics/field_trial_params.h"
17 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
18 #include "base/stl_util.h" 20 #include "base/stl_util.h"
19 #include "base/supports_user_data.h" 21 #include "base/supports_user_data.h"
20 #include "base/threading/thread_task_runner_handle.h" 22 #include "base/threading/thread_task_runner_handle.h"
21 #include "base/trace_event/trace_event.h" 23 #include "base/trace_event/trace_event.h"
22 #include "content/common/resource_messages.h" 24 #include "content/common/resource_messages.h"
23 #include "content/public/browser/resource_request_info.h" 25 #include "content/public/browser/resource_request_info.h"
24 #include "content/public/browser/resource_throttle.h" 26 #include "content/public/browser/resource_throttle.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 ready_(false), 223 ready_(false),
222 deferred_(false), 224 deferred_(false),
223 is_async_(is_async), 225 is_async_(is_async),
224 attributes_(kAttributeNone), 226 attributes_(kAttributeNone),
225 scheduler_(scheduler), 227 scheduler_(scheduler),
226 priority_(priority), 228 priority_(priority),
227 fifo_ordering_(0), 229 fifo_ordering_(0),
228 host_port_pair_(net::HostPortPair::FromURL(request->url())), 230 host_port_pair_(net::HostPortPair::FromURL(request->url())),
229 weak_ptr_factory_(this) { 231 weak_ptr_factory_(this) {
230 DCHECK(!request_->GetUserData(kUserDataKey)); 232 DCHECK(!request_->GetUserData(kUserDataKey));
231 request_->SetUserData(kUserDataKey, new UnownedPointer(this)); 233 request_->SetUserData(kUserDataKey, base::MakeUnique<UnownedPointer>(this));
232 } 234 }
233 235
234 ~ScheduledResourceRequest() override { 236 ~ScheduledResourceRequest() override {
235 request_->RemoveUserData(kUserDataKey); 237 request_->RemoveUserData(kUserDataKey);
236 scheduler_->RemoveRequest(this); 238 scheduler_->RemoveRequest(this);
237 } 239 }
238 240
239 static ScheduledResourceRequest* ForRequest(net::URLRequest* request) { 241 static ScheduledResourceRequest* ForRequest(net::URLRequest* request) {
240 return static_cast<UnownedPointer*>(request->GetUserData(kUserDataKey)) 242 return static_cast<UnownedPointer*>(request->GetUserData(kUserDataKey))
241 ->get(); 243 ->get();
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 client->ReprioritizeRequest(scheduled_resource_request, old_priority_params, 1081 client->ReprioritizeRequest(scheduled_resource_request, old_priority_params,
1080 new_priority_params); 1082 new_priority_params);
1081 } 1083 }
1082 1084
1083 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( 1085 ResourceScheduler::ClientId ResourceScheduler::MakeClientId(
1084 int child_id, int route_id) { 1086 int child_id, int route_id) {
1085 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; 1087 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id;
1086 } 1088 }
1087 1089
1088 } // namespace content 1090 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698