| 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_conditions.h" | 5 #include "chrome/browser/devtools/devtools_network_conditions.h" |
| 6 | 6 |
| 7 #include "url/gurl.h" | 7 #include "url/gurl.h" |
| 8 | 8 |
| 9 DevToolsNetworkConditions::DevToolsNetworkConditions() |
| 10 : offline_(false), |
| 11 latency_(0), |
| 12 download_throughput_(0), |
| 13 upload_throughput_(0) { |
| 14 } |
| 15 |
| 16 DevToolsNetworkConditions::DevToolsNetworkConditions(bool offline) |
| 17 : offline_(offline), |
| 18 latency_(0), |
| 19 download_throughput_(0), |
| 20 upload_throughput_(0) { |
| 21 } |
| 22 |
| 9 DevToolsNetworkConditions::DevToolsNetworkConditions( | 23 DevToolsNetworkConditions::DevToolsNetworkConditions( |
| 10 const std::vector<std::string>& domains, | 24 bool offline, |
| 11 double maximal_throughput) | 25 double latency, |
| 12 : domains_(domains), | 26 double download_throughput, |
| 13 maximal_throughput_(maximal_throughput) { | 27 double upload_throughput) |
| 28 : offline_(offline), |
| 29 latency_(latency), |
| 30 download_throughput_(download_throughput), |
| 31 upload_throughput_(upload_throughput) { |
| 14 } | 32 } |
| 15 | 33 |
| 16 DevToolsNetworkConditions::~DevToolsNetworkConditions() { | 34 DevToolsNetworkConditions::~DevToolsNetworkConditions() { |
| 17 } | 35 } |
| 18 | 36 |
| 19 bool DevToolsNetworkConditions::HasMatchingDomain(const GURL& url) const { | 37 bool DevToolsNetworkConditions::IsThrottling() const { |
| 20 Domains::const_iterator domain = domains_.begin(); | 38 return (latency_ != 0) || (download_throughput_ != 0.0) || |
| 21 if (domain == domains_.end()) | 39 (upload_throughput_ != 0); |
| 22 return true; | |
| 23 for (; domain != domains_.end(); ++domain) { | |
| 24 if (url.DomainIs(domain->data())) | |
| 25 return true; | |
| 26 } | |
| 27 return false; | |
| 28 } | 40 } |
| 29 | |
| 30 bool DevToolsNetworkConditions::IsOffline() const { | |
| 31 return maximal_throughput_ == 0.0; | |
| 32 } | |
| 33 | |
| 34 bool DevToolsNetworkConditions::IsThrottling() const { | |
| 35 return maximal_throughput_ != 0.0; | |
| 36 } | |
| OLD | NEW |