| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/base/host_resolver_impl.h" | 5 #include "net/base/host_resolver_impl.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <Winsock2.h> | 8 #include <Winsock2.h> |
| 9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) |
| 10 #include <netdb.h> | 10 #include <netdb.h> |
| (...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 pool->AdjustNumOutstandingJobs(-1); | 1346 pool->AdjustNumOutstandingJobs(-1); |
| 1347 } | 1347 } |
| 1348 | 1348 |
| 1349 void HostResolverImpl::OnJobComplete(Job* job, | 1349 void HostResolverImpl::OnJobComplete(Job* job, |
| 1350 int net_error, | 1350 int net_error, |
| 1351 int os_error, | 1351 int os_error, |
| 1352 const AddressList& addrlist) { | 1352 const AddressList& addrlist) { |
| 1353 RemoveOutstandingJob(job); | 1353 RemoveOutstandingJob(job); |
| 1354 | 1354 |
| 1355 // Write result to the cache. | 1355 // Write result to the cache. |
| 1356 if (cache_.get()) | 1356 if (cache_.get()) { |
| 1357 cache_->Set(job->key(), net_error, addrlist, base::TimeTicks::Now()); | 1357 base::TimeDelta ttl = base::TimeDelta::FromSeconds(0); |
| 1358 | 1358 if (net_error == OK) |
| 1359 ttl = base::TimeDelta::FromMinutes(1); |
| 1360 cache_->Set(job->key(), net_error, addrlist, |
| 1361 ttl, |
| 1362 base::TimeTicks::Now()); |
| 1363 } |
| 1359 OnJobCompleteInternal(job, net_error, os_error, addrlist); | 1364 OnJobCompleteInternal(job, net_error, os_error, addrlist); |
| 1360 } | 1365 } |
| 1361 | 1366 |
| 1362 void HostResolverImpl::AbortJob(Job* job) { | 1367 void HostResolverImpl::AbortJob(Job* job) { |
| 1363 OnJobCompleteInternal(job, ERR_ABORTED, 0 /* no os_error */, AddressList()); | 1368 OnJobCompleteInternal(job, ERR_ABORTED, 0 /* no os_error */, AddressList()); |
| 1364 } | 1369 } |
| 1365 | 1370 |
| 1366 void HostResolverImpl::OnJobCompleteInternal( | 1371 void HostResolverImpl::OnJobCompleteInternal( |
| 1367 Job* job, | 1372 Job* job, |
| 1368 int net_error, | 1373 int net_error, |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1596 // resolv.conf changes so we don't need to do anything to clear that cache. | 1601 // resolv.conf changes so we don't need to do anything to clear that cache. |
| 1597 if (cache_.get()) | 1602 if (cache_.get()) |
| 1598 cache_->clear(); | 1603 cache_->clear(); |
| 1599 // Existing jobs will have been sent to the original server so they need to | 1604 // Existing jobs will have been sent to the original server so they need to |
| 1600 // be aborted. TODO(Craig): Should these jobs be restarted? | 1605 // be aborted. TODO(Craig): Should these jobs be restarted? |
| 1601 AbortAllInProgressJobs(); | 1606 AbortAllInProgressJobs(); |
| 1602 // |this| may be deleted inside AbortAllInProgressJobs(). | 1607 // |this| may be deleted inside AbortAllInProgressJobs(). |
| 1603 } | 1608 } |
| 1604 | 1609 |
| 1605 } // namespace net | 1610 } // namespace net |
| OLD | NEW |