| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "net/nqe/throughput_analyzer.h" | 5 #include "net/nqe/throughput_analyzer.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // |accuracy_degrading_requests_|. | 224 // |accuracy_degrading_requests_|. |
| 225 for (const URLRequest* request : requests_) | 225 for (const URLRequest* request : requests_) |
| 226 accuracy_degrading_requests_.insert(request); | 226 accuracy_degrading_requests_.insert(request); |
| 227 requests_.clear(); | 227 requests_.clear(); |
| 228 BoundRequestsSize(); | 228 BoundRequestsSize(); |
| 229 EndThroughputObservationWindow(); | 229 EndThroughputObservationWindow(); |
| 230 | 230 |
| 231 last_connection_change_ = base::TimeTicks::Now(); | 231 last_connection_change_ = base::TimeTicks::Now(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void ThroughputAnalyzer::SetUseLocalHostRequestsForTesting( |
| 235 bool use_local_host_requests_for_tests) { |
| 236 DCHECK(thread_checker_.CalledOnValidThread()); |
| 237 use_localhost_requests_for_tests_ = use_local_host_requests_for_tests; |
| 238 } |
| 239 |
| 240 void ThroughputAnalyzer::SetUseSmallResponsesForTesting( |
| 241 bool use_small_responses) { |
| 242 DCHECK(thread_checker_.CalledOnValidThread()); |
| 243 use_small_responses_for_tests_ = use_small_responses; |
| 244 } |
| 245 |
| 234 int64_t ThroughputAnalyzer::GetBitsReceived() const { | 246 int64_t ThroughputAnalyzer::GetBitsReceived() const { |
| 235 DCHECK(thread_checker_.CalledOnValidThread()); | 247 DCHECK(thread_checker_.CalledOnValidThread()); |
| 236 | 248 |
| 237 #if defined(OS_ANDROID) | 249 #if defined(OS_ANDROID) |
| 238 int64_t rx_bytes; | 250 int64_t rx_bytes; |
| 239 if (android::traffic_stats::GetCurrentUidRxBytes(&rx_bytes)) | 251 if (android::traffic_stats::GetCurrentUidRxBytes(&rx_bytes)) |
| 240 return static_cast<uint64_t>(rx_bytes * 8); | 252 return static_cast<uint64_t>(rx_bytes * 8); |
| 241 #endif | 253 #endif |
| 242 return NetworkActivityMonitor::GetInstance()->GetBytesReceived() * 8; | 254 return NetworkActivityMonitor::GetInstance()->GetBytesReceived() * 8; |
| 243 } | 255 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 // TODO(tbansal): crbug.com/609174 Add UMA to record how frequently this | 290 // TODO(tbansal): crbug.com/609174 Add UMA to record how frequently this |
| 279 // happens. | 291 // happens. |
| 280 } | 292 } |
| 281 } | 293 } |
| 282 | 294 |
| 283 } // namespace internal | 295 } // namespace internal |
| 284 | 296 |
| 285 } // namespace nqe | 297 } // namespace nqe |
| 286 | 298 |
| 287 } // namespace net | 299 } // namespace net |
| OLD | NEW |