OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // A DnsHostInfo object is used to store status of a Dns lookup of a specific | 5 // A DnsHostInfo object is used to store status of a Dns lookup of a specific |
6 // hostname. | 6 // hostname. |
7 // It includes progress, from placement in the DnsMaster's queue, to resolution | 7 // It includes progress, from placement in the DnsMaster's queue, to resolution |
8 // by the DNS service as either FOUND or NO_SUCH_NAME. | 8 // by the DNS service as either FOUND or NO_SUCH_NAME. |
9 | 9 |
10 #ifndef CHROME_BROWSER_NET_DNS_HOST_INFO_H_ | 10 #ifndef CHROME_BROWSER_NET_DNS_HOST_INFO_H_ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // The following involve predictive prefetching, triggered by a navigation. | 45 // The following involve predictive prefetching, triggered by a navigation. |
46 // The referring_hostname_ is also set when these are used. | 46 // The referring_hostname_ is also set when these are used. |
47 // TODO(jar): Support STATIC_REFERAL_MOTIVATED API and integration. | 47 // TODO(jar): Support STATIC_REFERAL_MOTIVATED API and integration. |
48 STATIC_REFERAL_MOTIVATED, // External database suggested this resolution. | 48 STATIC_REFERAL_MOTIVATED, // External database suggested this resolution. |
49 LEARNED_REFERAL_MOTIVATED, // Prior navigation taught us this resolution. | 49 LEARNED_REFERAL_MOTIVATED, // Prior navigation taught us this resolution. |
50 }; | 50 }; |
51 | 51 |
52 enum DnsProcessingState { | 52 enum DnsProcessingState { |
53 // When processed by our prefetching system, the states are: | 53 // When processed by our prefetching system, the states are: |
54 PENDING, // Constructor has completed. | 54 PENDING, // Constructor has completed. |
55 QUEUED, // In name queue but not yet being resolved. | 55 QUEUED, // In prefetch queue but not yet being resolved. |
56 ASSIGNED, // Being resolved (or being reset to earlier state) | 56 ASSIGNED, // Currently being processed. |
57 ASSIGNED_BUT_MARKED, // Needs to be deleted as soon as it's resolved. | 57 ASSIGNED_BUT_MARKED, // Needs to be deleted as soon as it's resolved. |
58 FOUND, // DNS resolution completed. | 58 FOUND, // DNS prefetch search completed. |
59 NO_SUCH_NAME, // DNS resolution completed. | 59 NO_SUCH_NAME, // DNS prefetch search completed. |
60 // When processed by the network stack during navigation, the states are: | 60 // When processed by the network stack during navigation, the states are: |
61 STARTED, // Resolution has begun for a navigation. | 61 STARTED, // Resolution has begun for a navigation. |
62 FINISHED, // Resolution has completed for a navigation. | 62 FINISHED, // Resolution has completed for a navigation. |
63 FINISHED_UNRESOLVED}; // No resolution found, so navigation will fail. | 63 FINISHED_UNRESOLVED}; // No resolution found, so navigation will fail. |
64 static const base::TimeDelta kMaxNonNetworkDnsLookupDuration; | 64 static const base::TimeDelta kMaxNonNetworkDnsLookupDuration; |
65 // The number of OS cache entries we can guarantee(?) before cache eviction | 65 // The number of OS cache entries we can guarantee(?) before cache eviction |
66 // might likely take place. | 66 // might likely take place. |
67 static const int kMaxGuaranteedCacheSize = 50; | 67 static const int kMaxGuaranteedCacheSize = 50; |
68 | 68 |
69 typedef std::vector<DnsHostInfo> DnsInfoTable; | 69 typedef std::vector<DnsHostInfo> DnsInfoTable; |
70 | 70 |
71 static const base::TimeDelta kNullDuration; | 71 static const base::TimeDelta kNullDuration; |
72 | 72 |
73 // DnsHostInfo are usually made by the default constructor during | 73 // DnsHostInfo are usually made by the default constructor during |
74 // initializing of the DnsMaster's map (of info for Hostnames). | 74 // initializing of the DnsMaster's map (of info for Hostnames). |
75 DnsHostInfo() | 75 DnsHostInfo() |
76 : state_(PENDING), | 76 : state_(PENDING), |
77 old_prequeue_state_(state_), | |
78 resolve_duration_(kNullDuration), | 77 resolve_duration_(kNullDuration), |
79 queue_duration_(kNullDuration), | 78 queue_duration_(kNullDuration), |
80 benefits_remaining_(), | 79 benefits_remaining_(), |
81 sequence_number_(0), | 80 sequence_number_(0), |
82 motivation_(NO_PREFETCH_MOTIVATION), | 81 motivation_(NO_PREFETCH_MOTIVATION), |
83 was_linked_(false) { | 82 was_linked_(false) { |
84 } | 83 } |
85 | 84 |
86 ~DnsHostInfo() {} | 85 ~DnsHostInfo() {} |
87 | 86 |
88 // NeedDnsUpdate decides, based on our internal info, | 87 // NeedDnsUpdate decides, based on our internal info, |
89 // if it would be valuable to attempt to update (prefectch) | 88 // if it would be valuable to attempt to update (prefectch) |
90 // DNS data for hostname. This decision is based | 89 // DNS data for hostname. This decision is based |
91 // on how recently we've done DNS prefetching for hostname. | 90 // on how recently we've done DNS prefetching for hostname. |
92 bool NeedsDnsUpdate(const std::string& hostname); | 91 bool NeedsDnsUpdate(const std::string& hostname); |
93 | 92 |
94 static void set_cache_expiration(base::TimeDelta time); | 93 static void set_cache_expiration(base::TimeDelta time); |
95 | 94 |
96 // The prefetching lifecycle. | 95 // The prefetching lifecycle. |
97 void SetQueuedState(ResolutionMotivation motivation); | 96 void SetQueuedState(ResolutionMotivation motivation); |
98 void SetAssignedState(); | 97 void SetAssignedState(); |
99 void RemoveFromQueue(); | |
100 void SetPendingDeleteState(); | 98 void SetPendingDeleteState(); |
101 void SetFoundState(); | 99 void SetFoundState(); |
102 void SetNoSuchNameState(); | 100 void SetNoSuchNameState(); |
103 // The actual browsing resolution lifecycle. | 101 // The actual browsing resolution lifecycle. |
104 void SetStartedState(); | 102 void SetStartedState(); |
105 void SetFinishedState(bool was_resolved); | 103 void SetFinishedState(bool was_resolved); |
106 | 104 |
107 // Finish initialization. Must only be called once. | 105 // Finish initialization. Must only be called once. |
108 void SetHostname(const std::string& hostname); | 106 void SetHostname(const std::string& hostname); |
109 | 107 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // Record why we created, or have updated (reqested pre-resolution) of this | 150 // Record why we created, or have updated (reqested pre-resolution) of this |
153 // instance. | 151 // instance. |
154 void SetMotivation(ResolutionMotivation motivation); | 152 void SetMotivation(ResolutionMotivation motivation); |
155 | 153 |
156 // Helper function for about:dns printing. | 154 // Helper function for about:dns printing. |
157 std::string GetAsciiMotivation() const; | 155 std::string GetAsciiMotivation() const; |
158 | 156 |
159 // The next declaration is non-const to facilitate testing. | 157 // The next declaration is non-const to facilitate testing. |
160 static base::TimeDelta kCacheExpirationDuration; | 158 static base::TimeDelta kCacheExpirationDuration; |
161 | 159 |
162 // The current state of this instance. | |
163 DnsProcessingState state_; | 160 DnsProcessingState state_; |
164 | |
165 // Record the state prior to going to a queued state, in case we have to back | |
166 // out of the queue. | |
167 DnsProcessingState old_prequeue_state_; | |
168 | |
169 std::string hostname_; // Hostname for this info. | 161 std::string hostname_; // Hostname for this info. |
170 | 162 |
171 // When was last state changed (usually lookup completed). | 163 // When was last state changed (usually lookup completed). |
172 base::TimeTicks time_; | 164 base::TimeTicks time_; |
173 // Time needed for DNS to resolve. | 165 // Time needed for DNS to resolve. |
174 base::TimeDelta resolve_duration_; | 166 base::TimeDelta resolve_duration_; |
175 // Time spent in queue. | 167 // Time spent in queue. |
176 base::TimeDelta queue_duration_; | 168 base::TimeDelta queue_duration_; |
177 // Unused potential benefits of a prefetch. | 169 // Unused potential benefits of a prefetch. |
178 base::TimeDelta benefits_remaining_; | 170 base::TimeDelta benefits_remaining_; |
(...skipping 13 matching lines...) Expand all Loading... |
192 std::string referring_hostname_; | 184 std::string referring_hostname_; |
193 | 185 |
194 // We put these objects into a std::map, and hence we | 186 // We put these objects into a std::map, and hence we |
195 // need some "evil" constructors. | 187 // need some "evil" constructors. |
196 // DISALLOW_COPY_AND_ASSIGN(DnsHostInfo); | 188 // DISALLOW_COPY_AND_ASSIGN(DnsHostInfo); |
197 }; | 189 }; |
198 | 190 |
199 } // namespace chrome_browser_net | 191 } // namespace chrome_browser_net |
200 | 192 |
201 #endif // CHROME_BROWSER_NET_DNS_HOST_INFO_H_ | 193 #endif // CHROME_BROWSER_NET_DNS_HOST_INFO_H_ |
OLD | NEW |