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> |
11 | 11 |
12 #include "base/basictypes.h" | |
13 #include "base/bind.h" | 12 #include "base/bind.h" |
14 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
15 #include "base/containers/mru_cache.h" | 14 #include "base/containers/mru_cache.h" |
16 #include "base/location.h" | 15 #include "base/location.h" |
17 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
20 #include "base/prefs/scoped_user_pref_update.h" | 20 #include "base/prefs/scoped_user_pref_update.h" |
21 #include "base/profiler/scoped_tracker.h" | 21 #include "base/profiler/scoped_tracker.h" |
22 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
23 #include "base/stl_util.h" | 23 #include "base/stl_util.h" |
24 #include "base/strings/string_split.h" | 24 #include "base/strings/string_split.h" |
25 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
26 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
27 #include "base/synchronization/waitable_event.h" | 27 #include "base/synchronization/waitable_event.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // subresources needed) by a factor of 2 after about 24 hours of uptime. We will | 66 // subresources needed) by a factor of 2 after about 24 hours of uptime. We will |
67 // trim roughly once-an-hour of uptime. The ratio to use in each trim operation | 67 // trim roughly once-an-hour of uptime. The ratio to use in each trim operation |
68 // is then the 24th root of 0.5. If a user only surfs for 4 hours a day, then | 68 // is then the 24th root of 0.5. If a user only surfs for 4 hours a day, then |
69 // after about 6 days they will have halved all their estimates of subresource | 69 // after about 6 days they will have halved all their estimates of subresource |
70 // connections. Once this falls below kDiscardableExpectedValue the referrer | 70 // connections. Once this falls below kDiscardableExpectedValue the referrer |
71 // will be discarded. | 71 // will be discarded. |
72 // TODO(jar): Measure size of referrer lists in the field. Consider an adaptive | 72 // TODO(jar): Measure size of referrer lists in the field. Consider an adaptive |
73 // system that uses a higher trim ratio when the list is large. | 73 // system that uses a higher trim ratio when the list is large. |
74 // static | 74 // static |
75 const double Predictor::kReferrerTrimRatio = 0.97153; | 75 const double Predictor::kReferrerTrimRatio = 0.97153; |
76 const int64 Predictor::kDurationBetweenTrimmingsHours = 1; | 76 const int64_t Predictor::kDurationBetweenTrimmingsHours = 1; |
77 const int64 Predictor::kDurationBetweenTrimmingIncrementsSeconds = 15; | 77 const int64_t Predictor::kDurationBetweenTrimmingIncrementsSeconds = 15; |
78 const size_t Predictor::kUrlsTrimmedPerIncrement = 5u; | 78 const size_t Predictor::kUrlsTrimmedPerIncrement = 5u; |
79 const size_t Predictor::kMaxSpeculativeParallelResolves = 3; | 79 const size_t Predictor::kMaxSpeculativeParallelResolves = 3; |
80 const int Predictor::kMaxUnusedSocketLifetimeSecondsWithoutAGet = 10; | 80 const int Predictor::kMaxUnusedSocketLifetimeSecondsWithoutAGet = 10; |
81 // To control our congestion avoidance system, which discards a queue when | 81 // To control our congestion avoidance system, which discards a queue when |
82 // resolutions are "taking too long," we need an expected resolution time. | 82 // resolutions are "taking too long," we need an expected resolution time. |
83 // Common average is in the range of 300-500ms. | 83 // Common average is in the range of 300-500ms. |
84 const int kExpectedResolutionTimeMs = 500; | 84 const int kExpectedResolutionTimeMs = 500; |
85 const int Predictor::kTypicalSpeculativeGroupSize = 8; | 85 const int Predictor::kTypicalSpeculativeGroupSize = 8; |
86 const int Predictor::kMaxSpeculativeResolveQueueDelayMs = | 86 const int Predictor::kMaxSpeculativeResolveQueueDelayMs = |
87 (kExpectedResolutionTimeMs * Predictor::kTypicalSpeculativeGroupSize) / | 87 (kExpectedResolutionTimeMs * Predictor::kTypicalSpeculativeGroupSize) / |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 } | 1307 } |
1308 | 1308 |
1309 void SimplePredictor::ShutdownOnUIThread() { | 1309 void SimplePredictor::ShutdownOnUIThread() { |
1310 SetShutdown(true); | 1310 SetShutdown(true); |
1311 } | 1311 } |
1312 | 1312 |
1313 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } | 1313 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } |
1314 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } | 1314 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } |
1315 | 1315 |
1316 } // namespace chrome_browser_net | 1316 } // namespace chrome_browser_net |
OLD | NEW |