OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/disk_cache/backend_impl.h" | 5 #include "net/disk_cache/backend_impl.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 if (cache_type() != net::DISK_CACHE) | 1134 if (cache_type() != net::DISK_CACHE) |
1135 return; | 1135 return; |
1136 | 1136 |
1137 UMA_HISTOGRAM_TIMES(base::FieldTrial::MakeName("DiskCache.TotalIOTime", | 1137 UMA_HISTOGRAM_TIMES(base::FieldTrial::MakeName("DiskCache.TotalIOTime", |
1138 "CacheThrottle").data(), | 1138 "CacheThrottle").data(), |
1139 elapsed_time); | 1139 elapsed_time); |
1140 | 1140 |
1141 if (!throttle_requests_) | 1141 if (!throttle_requests_) |
1142 return; | 1142 return; |
1143 | 1143 |
1144 const int kMaxNormalDelayMS = 100; | 1144 const int kMaxNormalDelayMS = 460; |
1145 | 1145 |
1146 bool throttling = io_delay_ > kMaxNormalDelayMS; | 1146 bool throttling = io_delay_ > kMaxNormalDelayMS; |
1147 | 1147 |
1148 // We keep a simple exponential average of elapsed_time. | 1148 // We keep a simple exponential average of elapsed_time. |
1149 io_delay_ = (io_delay_ + static_cast<int>(elapsed_time.InMilliseconds())) / 2; | 1149 io_delay_ = (io_delay_ + static_cast<int>(elapsed_time.InMilliseconds())) / 2; |
1150 if (io_delay_ > kMaxNormalDelayMS && !throttling) | 1150 if (io_delay_ > kMaxNormalDelayMS && !throttling) |
1151 background_queue_.StartQueingOperations(); | 1151 background_queue_.StartQueingOperations(); |
1152 else if (io_delay_ <= kMaxNormalDelayMS && throttling) | 1152 else if (io_delay_ <= kMaxNormalDelayMS && throttling) |
1153 background_queue_.StopQueingOperations(); | 1153 background_queue_.StopQueingOperations(); |
1154 } | 1154 } |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 if (total_memory > kMaxBuffersSize || total_memory <= 0) | 2095 if (total_memory > kMaxBuffersSize || total_memory <= 0) |
2096 total_memory = kMaxBuffersSize; | 2096 total_memory = kMaxBuffersSize; |
2097 | 2097 |
2098 done = true; | 2098 done = true; |
2099 } | 2099 } |
2100 | 2100 |
2101 return static_cast<int>(total_memory); | 2101 return static_cast<int>(total_memory); |
2102 } | 2102 } |
2103 | 2103 |
2104 } // namespace disk_cache | 2104 } // namespace disk_cache |
OLD | NEW |