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 "chrome/browser/net/dns_probe_job.h" | 10 #include "chrome/browser/net/dns_probe_job.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 for (std::vector<CallbackType>::const_iterator i = callbacks.begin(); | 268 for (std::vector<CallbackType>::const_iterator i = callbacks.begin(); |
269 i != callbacks.end(); ++i) { | 269 i != callbacks.end(); ++i) { |
270 i->Run(result_); | 270 i->Run(result_); |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 scoped_ptr<DnsProbeJob> DnsProbeService::CreateProbeJob( | 274 scoped_ptr<DnsProbeJob> DnsProbeService::CreateProbeJob( |
275 const DnsConfig& dns_config, | 275 const DnsConfig& dns_config, |
276 const DnsProbeJob::CallbackType& job_callback) { | 276 const DnsProbeJob::CallbackType& job_callback) { |
277 if (!dns_config.IsValid()) | 277 if (!dns_config.IsValid()) |
278 return scoped_ptr<DnsProbeJob>(NULL); | 278 return scoped_ptr<DnsProbeJob>(); |
279 | 279 |
280 scoped_ptr<DnsClient> dns_client(DnsClient::CreateClient(NULL)); | 280 scoped_ptr<DnsClient> dns_client(DnsClient::CreateClient(NULL)); |
281 dns_client->SetConfig(dns_config); | 281 dns_client->SetConfig(dns_config); |
282 return DnsProbeJob::CreateJob(dns_client.Pass(), job_callback, NULL); | 282 return DnsProbeJob::CreateJob(dns_client.Pass(), job_callback, NULL); |
283 } | 283 } |
284 | 284 |
285 void DnsProbeService::OnProbeJobComplete(DnsProbeJob* job, | 285 void DnsProbeService::OnProbeJobComplete(DnsProbeJob* job, |
286 DnsProbeJob::Result result) { | 286 DnsProbeJob::Result result) { |
287 DCHECK_EQ(STATE_PROBE_RUNNING, state_); | 287 DCHECK_EQ(STATE_PROBE_RUNNING, state_); |
288 | 288 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 config->randomize_ports = false; | 335 config->randomize_ports = false; |
336 } | 336 } |
337 | 337 |
338 bool DnsProbeService::ResultsExpired() { | 338 bool DnsProbeService::ResultsExpired() { |
339 const base::TimeDelta kMaxResultAge = | 339 const base::TimeDelta kMaxResultAge = |
340 base::TimeDelta::FromMilliseconds(kMaxResultAgeMs); | 340 base::TimeDelta::FromMilliseconds(kMaxResultAgeMs); |
341 return base::Time::Now() - probe_start_time_ > kMaxResultAge; | 341 return base::Time::Now() - probe_start_time_ > kMaxResultAge; |
342 } | 342 } |
343 | 343 |
344 } // namespace chrome_browser_net | 344 } // namespace chrome_browser_net |
OLD | NEW |