| OLD | NEW |
| 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 <set> | 5 #include <set> |
| 6 | 6 |
| 7 #include "content/browser/loader/resource_scheduler.h" | 7 #include "content/browser/loader/resource_scheduler.h" |
| 8 | 8 |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 ready_(false), | 127 ready_(false), |
| 128 deferred_(false), | 128 deferred_(false), |
| 129 classification_(NORMAL_REQUEST), | 129 classification_(NORMAL_REQUEST), |
| 130 scheduler_(scheduler), | 130 scheduler_(scheduler), |
| 131 priority_(priority), | 131 priority_(priority), |
| 132 fifo_ordering_(0) { | 132 fifo_ordering_(0) { |
| 133 TRACE_EVENT_ASYNC_BEGIN1("net", "URLRequest", request_, | 133 TRACE_EVENT_ASYNC_BEGIN1("net", "URLRequest", request_, |
| 134 "url", request->url().spec()); | 134 "url", request->url().spec()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 virtual ~ScheduledResourceRequest() { | 137 ~ScheduledResourceRequest() override { scheduler_->RemoveRequest(this); } |
| 138 scheduler_->RemoveRequest(this); | |
| 139 } | |
| 140 | 138 |
| 141 void Start() { | 139 void Start() { |
| 142 TRACE_EVENT_ASYNC_STEP_PAST0("net", "URLRequest", request_, "Queued"); | 140 TRACE_EVENT_ASYNC_STEP_PAST0("net", "URLRequest", request_, "Queued"); |
| 143 ready_ = true; | 141 ready_ = true; |
| 144 if (deferred_ && request_->status().is_success()) { | 142 if (deferred_ && request_->status().is_success()) { |
| 145 deferred_ = false; | 143 deferred_ = false; |
| 146 controller()->Resume(); | 144 controller()->Resume(); |
| 147 } | 145 } |
| 148 } | 146 } |
| 149 | 147 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 162 } | 160 } |
| 163 RequestClassification classification() const { | 161 RequestClassification classification() const { |
| 164 return classification_; | 162 return classification_; |
| 165 } | 163 } |
| 166 void set_classification(RequestClassification classification) { | 164 void set_classification(RequestClassification classification) { |
| 167 classification_ = classification; | 165 classification_ = classification; |
| 168 } | 166 } |
| 169 | 167 |
| 170 private: | 168 private: |
| 171 // ResourceMessageDelegate interface: | 169 // ResourceMessageDelegate interface: |
| 172 virtual bool OnMessageReceived(const IPC::Message& message) override { | 170 bool OnMessageReceived(const IPC::Message& message) override { |
| 173 bool handled = true; | 171 bool handled = true; |
| 174 IPC_BEGIN_MESSAGE_MAP(ScheduledResourceRequest, message) | 172 IPC_BEGIN_MESSAGE_MAP(ScheduledResourceRequest, message) |
| 175 IPC_MESSAGE_HANDLER(ResourceHostMsg_DidChangePriority, DidChangePriority) | 173 IPC_MESSAGE_HANDLER(ResourceHostMsg_DidChangePriority, DidChangePriority) |
| 176 IPC_MESSAGE_UNHANDLED(handled = false) | 174 IPC_MESSAGE_UNHANDLED(handled = false) |
| 177 IPC_END_MESSAGE_MAP() | 175 IPC_END_MESSAGE_MAP() |
| 178 return handled; | 176 return handled; |
| 179 } | 177 } |
| 180 | 178 |
| 181 // ResourceThrottle interface: | 179 // ResourceThrottle interface: |
| 182 virtual void WillStartRequest(bool* defer) override { | 180 void WillStartRequest(bool* defer) override { deferred_ = *defer = !ready_; } |
| 183 deferred_ = *defer = !ready_; | |
| 184 } | |
| 185 | 181 |
| 186 virtual const char* GetNameForLogging() const override { | 182 const char* GetNameForLogging() const override { return "ResourceScheduler"; } |
| 187 return "ResourceScheduler"; | |
| 188 } | |
| 189 | 183 |
| 190 void DidChangePriority(int request_id, net::RequestPriority new_priority, | 184 void DidChangePriority(int request_id, net::RequestPriority new_priority, |
| 191 int intra_priority_value) { | 185 int intra_priority_value) { |
| 192 scheduler_->ReprioritizeRequest(this, new_priority, intra_priority_value); | 186 scheduler_->ReprioritizeRequest(this, new_priority, intra_priority_value); |
| 193 } | 187 } |
| 194 | 188 |
| 195 ClientId client_id_; | 189 ClientId client_id_; |
| 196 net::URLRequest* request_; | 190 net::URLRequest* request_; |
| 197 bool ready_; | 191 bool ready_; |
| 198 bool deferred_; | 192 bool deferred_; |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 client->ReprioritizeRequest( | 1029 client->ReprioritizeRequest( |
| 1036 request, old_priority_params, new_priority_params); | 1030 request, old_priority_params, new_priority_params); |
| 1037 } | 1031 } |
| 1038 | 1032 |
| 1039 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( | 1033 ResourceScheduler::ClientId ResourceScheduler::MakeClientId( |
| 1040 int child_id, int route_id) { | 1034 int child_id, int route_id) { |
| 1041 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; | 1035 return (static_cast<ResourceScheduler::ClientId>(child_id) << 32) | route_id; |
| 1042 } | 1036 } |
| 1043 | 1037 |
| 1044 } // namespace content | 1038 } // namespace content |
| OLD | NEW |