| 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/dns_probe_service.h" | 5 #include "chrome/browser/net/dns_probe_service.h" |
| 6 | 6 |
| 7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // Do nothing; probe is already running, and will call the callback. | 113 // Do nothing; probe is already running, and will call the callback. |
| 114 break; | 114 break; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 void DnsProbeService::OnDNSChanged() { | 118 void DnsProbeService::OnDNSChanged() { |
| 119 ClearCachedResult(); | 119 ClearCachedResult(); |
| 120 SetSystemClientToCurrentConfig(); | 120 SetSystemClientToCurrentConfig(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void DnsProbeService::OnInitialDNSConfigRead() { |
| 124 OnDNSChanged(); |
| 125 } |
| 126 |
| 123 void DnsProbeService::SetSystemClientForTesting( | 127 void DnsProbeService::SetSystemClientForTesting( |
| 124 scoped_ptr<DnsClient> system_client) { | 128 scoped_ptr<DnsClient> system_client) { |
| 125 system_runner_.SetClient(system_client.Pass()); | 129 system_runner_.SetClient(system_client.Pass()); |
| 126 } | 130 } |
| 127 | 131 |
| 128 void DnsProbeService::SetPublicClientForTesting( | 132 void DnsProbeService::SetPublicClientForTesting( |
| 129 scoped_ptr<DnsClient> public_client) { | 133 scoped_ptr<DnsClient> public_client) { |
| 130 public_runner_.SetClient(public_client.Pass()); | 134 public_runner_.SetClient(public_client.Pass()); |
| 131 } | 135 } |
| 132 | 136 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 bool DnsProbeService::CachedResultIsExpired() const { | 220 bool DnsProbeService::CachedResultIsExpired() const { |
| 217 if (state_ != STATE_RESULT_CACHED) | 221 if (state_ != STATE_RESULT_CACHED) |
| 218 return false; | 222 return false; |
| 219 | 223 |
| 220 const base::TimeDelta kMaxResultAge = | 224 const base::TimeDelta kMaxResultAge = |
| 221 base::TimeDelta::FromMilliseconds(kMaxResultAgeMs); | 225 base::TimeDelta::FromMilliseconds(kMaxResultAgeMs); |
| 222 return base::Time::Now() - probe_start_time_ > kMaxResultAge; | 226 return base::Time::Now() - probe_start_time_ > kMaxResultAge; |
| 223 } | 227 } |
| 224 | 228 |
| 225 } // namespace chrome_browser_net | 229 } // namespace chrome_browser_net |
| OLD | NEW |