| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/net/predictor.h" | 5 #include "chrome/browser/net/predictor.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 it != referrers_.end(); ++it) | 1029 it != referrers_.end(); ++it) |
| 1030 urls_being_trimmed_.push_back(it->first); | 1030 urls_being_trimmed_.push_back(it->first); |
| 1031 UMA_HISTOGRAM_COUNTS("Net.PredictionTrimSize", urls_being_trimmed_.size()); | 1031 UMA_HISTOGRAM_COUNTS("Net.PredictionTrimSize", urls_being_trimmed_.size()); |
| 1032 } | 1032 } |
| 1033 | 1033 |
| 1034 void Predictor::PostIncrementalTrimTask() { | 1034 void Predictor::PostIncrementalTrimTask() { |
| 1035 if (urls_being_trimmed_.empty()) | 1035 if (urls_being_trimmed_.empty()) |
| 1036 return; | 1036 return; |
| 1037 const TimeDelta kDurationBetweenTrimmingIncrements = | 1037 const TimeDelta kDurationBetweenTrimmingIncrements = |
| 1038 TimeDelta::FromSeconds(kDurationBetweenTrimmingIncrementsSeconds); | 1038 TimeDelta::FromSeconds(kDurationBetweenTrimmingIncrementsSeconds); |
| 1039 MessageLoop::current()->PostDelayedTask( | 1039 base::MessageLoop::current()->PostDelayedTask( |
| 1040 FROM_HERE, | 1040 FROM_HERE, |
| 1041 base::Bind(&Predictor::IncrementalTrimReferrers, | 1041 base::Bind(&Predictor::IncrementalTrimReferrers, |
| 1042 weak_factory_->GetWeakPtr(), false), | 1042 weak_factory_->GetWeakPtr(), false), |
| 1043 kDurationBetweenTrimmingIncrements); | 1043 kDurationBetweenTrimmingIncrements); |
| 1044 } | 1044 } |
| 1045 | 1045 |
| 1046 void Predictor::IncrementalTrimReferrers(bool trim_all_now) { | 1046 void Predictor::IncrementalTrimReferrers(bool trim_all_now) { |
| 1047 size_t trim_count = urls_being_trimmed_.size(); | 1047 size_t trim_count = urls_being_trimmed_.size(); |
| 1048 if (!trim_all_now) | 1048 if (!trim_all_now) |
| 1049 trim_count = std::min(trim_count, kUrlsTrimmedPerIncrement); | 1049 trim_count = std::min(trim_count, kUrlsTrimmedPerIncrement); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 IOThread* io_thread, | 1190 IOThread* io_thread, |
| 1191 net::URLRequestContextGetter* getter) { | 1191 net::URLRequestContextGetter* getter) { |
| 1192 // Empty function for unittests. | 1192 // Empty function for unittests. |
| 1193 } | 1193 } |
| 1194 | 1194 |
| 1195 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) { | 1195 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) { |
| 1196 SetShutdown(true); | 1196 SetShutdown(true); |
| 1197 } | 1197 } |
| 1198 | 1198 |
| 1199 } // namespace chrome_browser_net | 1199 } // namespace chrome_browser_net |
| OLD | NEW |