| 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> | 7 #include <stddef.h> |
| 8 | |
| 9 #include <algorithm> | 8 #include <algorithm> |
| 10 #include <limits> | 9 #include <limits> |
| 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "chrome/browser/devtools/devtools_network_conditions.h" | 13 #include "chrome/browser/devtools/devtools_network_conditions.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 int64_t kPacketSize = 1500; | 18 int64_t kPacketSize = 1500; |
| 19 | 19 |
| 20 base::TimeDelta CalculateTickLength(double throughput) { | 20 base::TimeDelta CalculateTickLength(double throughput) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 void DevToolsNetworkInterceptor::UpdateConditions( | 65 void DevToolsNetworkInterceptor::UpdateConditions( |
| 66 scoped_ptr<DevToolsNetworkConditions> conditions) { | 66 scoped_ptr<DevToolsNetworkConditions> conditions) { |
| 67 DCHECK(conditions); | 67 DCHECK(conditions); |
| 68 base::TimeTicks now = base::TimeTicks::Now(); | 68 base::TimeTicks now = base::TimeTicks::Now(); |
| 69 if (conditions_->IsThrottling()) | 69 if (conditions_->IsThrottling()) |
| 70 UpdateThrottled(now); | 70 UpdateThrottled(now); |
| 71 | 71 |
| 72 conditions_ = conditions.Pass(); | 72 conditions_ = std::move(conditions); |
| 73 | 73 |
| 74 bool offline = conditions_->offline(); | 74 bool offline = conditions_->offline(); |
| 75 if (offline || !conditions_->IsThrottling()) { | 75 if (offline || !conditions_->IsThrottling()) { |
| 76 timer_.Stop(); | 76 timer_.Stop(); |
| 77 FinishRecords(&download_, offline); | 77 FinishRecords(&download_, offline); |
| 78 FinishRecords(&upload_, offline); | 78 FinishRecords(&upload_, offline); |
| 79 FinishRecords(&suspended_, offline); | 79 FinishRecords(&suspended_, offline); |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 | 82 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 std::remove_if(records->begin(), records->end(), | 278 std::remove_if(records->begin(), records->end(), |
| 279 [&callback](const ThrottleRecord& record){ | 279 [&callback](const ThrottleRecord& record){ |
| 280 return record.callback.Equals(callback); | 280 return record.callback.Equals(callback); |
| 281 }), | 281 }), |
| 282 records->end()); | 282 records->end()); |
| 283 } | 283 } |
| 284 | 284 |
| 285 bool DevToolsNetworkInterceptor::IsOffline() { | 285 bool DevToolsNetworkInterceptor::IsOffline() { |
| 286 return conditions_->offline(); | 286 return conditions_->offline(); |
| 287 } | 287 } |
| OLD | NEW |