OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/devtools/devtools_network_interceptor.h" | 5 #include "chrome/browser/devtools/devtools_network_interceptor.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 #include <limits> | 10 #include <limits> |
9 | 11 |
10 #include "base/time/time.h" | 12 #include "base/time/time.h" |
11 #include "chrome/browser/devtools/devtools_network_conditions.h" | 13 #include "chrome/browser/devtools/devtools_network_conditions.h" |
12 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
13 | 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 int64_t kPacketSize = 1500; | 18 int64_t kPacketSize = 1500; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 return; | 196 return; |
195 | 197 |
196 base::TimeTicks desired_time = CalculateDesiredTime( | 198 base::TimeTicks desired_time = CalculateDesiredTime( |
197 download_, download_last_tick_, download_tick_length_); | 199 download_, download_last_tick_, download_tick_length_); |
198 | 200 |
199 base::TimeTicks upload_time = CalculateDesiredTime( | 201 base::TimeTicks upload_time = CalculateDesiredTime( |
200 upload_, upload_last_tick_, upload_tick_length_); | 202 upload_, upload_last_tick_, upload_tick_length_); |
201 if (upload_time < desired_time) | 203 if (upload_time < desired_time) |
202 desired_time = upload_time; | 204 desired_time = upload_time; |
203 | 205 |
204 int64_t min_baseline = std::numeric_limits<int64>::max(); | 206 int64_t min_baseline = std::numeric_limits<int64_t>::max(); |
205 for (size_t i = 0; i < suspend_count; ++i) { | 207 for (size_t i = 0; i < suspend_count; ++i) { |
206 if (suspended_[i].send_end < min_baseline) | 208 if (suspended_[i].send_end < min_baseline) |
207 min_baseline = suspended_[i].send_end; | 209 min_baseline = suspended_[i].send_end; |
208 } | 210 } |
209 if (suspend_count) { | 211 if (suspend_count) { |
210 base::TimeTicks activation_time = base::TimeTicks() + | 212 base::TimeTicks activation_time = base::TimeTicks() + |
211 base::TimeDelta::FromMicroseconds(min_baseline) + latency_length_; | 213 base::TimeDelta::FromMicroseconds(min_baseline) + latency_length_; |
212 if (activation_time < desired_time) | 214 if (activation_time < desired_time) |
213 desired_time = activation_time; | 215 desired_time = activation_time; |
214 } | 216 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 std::remove_if(records->begin(), records->end(), | 278 std::remove_if(records->begin(), records->end(), |
277 [&callback](const ThrottleRecord& record){ | 279 [&callback](const ThrottleRecord& record){ |
278 return record.callback.Equals(callback); | 280 return record.callback.Equals(callback); |
279 }), | 281 }), |
280 records->end()); | 282 records->end()); |
281 } | 283 } |
282 | 284 |
283 bool DevToolsNetworkInterceptor::IsOffline() { | 285 bool DevToolsNetworkInterceptor::IsOffline() { |
284 return conditions_->offline(); | 286 return conditions_->offline(); |
285 } | 287 } |
OLD | NEW |