| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1364 JobPool* pool = job_pools_[i]; | 1364 JobPool* pool = job_pools_[i]; |
| 1365 if (pool->HasPendingRequests() && CanCreateJobForPool(*pool)) { | 1365 if (pool->HasPendingRequests() && CanCreateJobForPool(*pool)) { |
| 1366 top_req = pool->RemoveTopPendingRequest(); | 1366 top_req = pool->RemoveTopPendingRequest(); |
| 1367 break; | 1367 break; |
| 1368 } | 1368 } |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 if (!top_req) | 1371 if (!top_req) |
| 1372 return; | 1372 return; |
| 1373 | 1373 |
| 1374 scoped_refptr<Job> job = CreateAndStartJob(top_req); | 1374 scoped_refptr<Job> job(CreateAndStartJob(top_req)); |
| 1375 | 1375 |
| 1376 // Search for any other pending request which can piggy-back off this job. | 1376 // Search for any other pending request which can piggy-back off this job. |
| 1377 for (size_t pool_i = 0; pool_i < POOL_COUNT; ++pool_i) { | 1377 for (size_t pool_i = 0; pool_i < POOL_COUNT; ++pool_i) { |
| 1378 JobPool* pool = job_pools_[pool_i]; | 1378 JobPool* pool = job_pools_[pool_i]; |
| 1379 pool->MoveRequestsToJob(job); | 1379 pool->MoveRequestsToJob(job); |
| 1380 } | 1380 } |
| 1381 } | 1381 } |
| 1382 | 1382 |
| 1383 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( | 1383 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( |
| 1384 const RequestInfo& info) const { | 1384 const RequestInfo& info) const { |
| 1385 HostResolverFlags effective_flags = | 1385 HostResolverFlags effective_flags = |
| 1386 info.host_resolver_flags() | additional_resolver_flags_; | 1386 info.host_resolver_flags() | additional_resolver_flags_; |
| 1387 AddressFamily effective_address_family = info.address_family(); | 1387 AddressFamily effective_address_family = info.address_family(); |
| 1388 if (effective_address_family == ADDRESS_FAMILY_UNSPECIFIED && | 1388 if (effective_address_family == ADDRESS_FAMILY_UNSPECIFIED && |
| 1389 default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED) { | 1389 default_address_family_ != ADDRESS_FAMILY_UNSPECIFIED) { |
| 1390 effective_address_family = default_address_family_; | 1390 effective_address_family = default_address_family_; |
| 1391 if (ipv6_probe_monitoring_) | 1391 if (ipv6_probe_monitoring_) |
| 1392 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; | 1392 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; |
| 1393 } | 1393 } |
| 1394 return Key(info.hostname(), effective_address_family, effective_flags); | 1394 return Key(info.hostname(), effective_address_family, effective_flags); |
| 1395 } | 1395 } |
| 1396 | 1396 |
| 1397 HostResolverImpl::Job* HostResolverImpl::CreateAndStartJob(Request* req) { | 1397 HostResolverImpl::Job* HostResolverImpl::CreateAndStartJob(Request* req) { |
| 1398 DCHECK(CanCreateJobForPool(*GetPoolForRequest(req))); | 1398 DCHECK(CanCreateJobForPool(*GetPoolForRequest(req))); |
| 1399 Key key = GetEffectiveKeyForRequest(req->info()); | 1399 Key key = GetEffectiveKeyForRequest(req->info()); |
| 1400 | 1400 |
| 1401 req->request_net_log().AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_CREATE_JOB, | 1401 req->request_net_log().AddEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_CREATE_JOB, |
| 1402 NULL); | 1402 NULL); |
| 1403 | 1403 |
| 1404 scoped_refptr<Job> job = new Job(next_job_id_++, this, key, | 1404 scoped_refptr<Job> job(new Job(next_job_id_++, this, key, |
| 1405 req->request_net_log(), net_log_); | 1405 req->request_net_log(), net_log_)); |
| 1406 job->AddRequest(req); | 1406 job->AddRequest(req); |
| 1407 AddOutstandingJob(job); | 1407 AddOutstandingJob(job); |
| 1408 job->Start(); | 1408 job->Start(); |
| 1409 | 1409 |
| 1410 return job.get(); | 1410 return job.get(); |
| 1411 } | 1411 } |
| 1412 | 1412 |
| 1413 int HostResolverImpl::EnqueueRequest(JobPool* pool, Request* req) { | 1413 int HostResolverImpl::EnqueueRequest(JobPool* pool, Request* req) { |
| 1414 scoped_ptr<Request> req_evicted_from_queue( | 1414 scoped_ptr<Request> req_evicted_from_queue( |
| 1415 pool->InsertPendingRequest(req)); | 1415 pool->InsertPendingRequest(req)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1444 job_pools_[i]->ResetNumOutstandingJobs(); | 1444 job_pools_[i]->ResetNumOutstandingJobs(); |
| 1445 JobMap jobs; | 1445 JobMap jobs; |
| 1446 jobs.swap(jobs_); | 1446 jobs.swap(jobs_); |
| 1447 for (JobMap::iterator it = jobs.begin(); it != jobs.end(); ++it) { | 1447 for (JobMap::iterator it = jobs.begin(); it != jobs.end(); ++it) { |
| 1448 AbortJob(it->second); | 1448 AbortJob(it->second); |
| 1449 it->second->Cancel(); | 1449 it->second->Cancel(); |
| 1450 } | 1450 } |
| 1451 } | 1451 } |
| 1452 | 1452 |
| 1453 } // namespace net | 1453 } // namespace net |
| OLD | NEW |