Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: net/base/host_resolver_impl.cc

Issue 3023048: Don't resolve IP literals. (Closed)
Patch Set: Rebase again Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/base/address_list_unittest.cc ('k') | net/base/host_resolver_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 if (cur_completing_job_) 747 if (cur_completing_job_)
748 cur_completing_job_->Cancel(); 748 cur_completing_job_->Cancel();
749 749
750 NetworkChangeNotifier::RemoveObserver(this); 750 NetworkChangeNotifier::RemoveObserver(this);
751 751
752 // Delete the job pools. 752 // Delete the job pools.
753 for (size_t i = 0u; i < arraysize(job_pools_); ++i) 753 for (size_t i = 0u; i < arraysize(job_pools_); ++i)
754 delete job_pools_[i]; 754 delete job_pools_[i];
755 } 755 }
756 756
757 // TODO(eroman): Don't create cache entries for hostnames which are simply IP
758 // address literals.
759 int HostResolverImpl::Resolve(const RequestInfo& info, 757 int HostResolverImpl::Resolve(const RequestInfo& info,
760 AddressList* addresses, 758 AddressList* addresses,
761 CompletionCallback* callback, 759 CompletionCallback* callback,
762 RequestHandle* out_req, 760 RequestHandle* out_req,
763 const BoundNetLog& net_log) { 761 const BoundNetLog& net_log) {
764 DCHECK(CalledOnValidThread()); 762 DCHECK(CalledOnValidThread());
765 763
766 if (shutdown_) 764 if (shutdown_)
767 return ERR_UNEXPECTED; 765 return ERR_UNEXPECTED;
768 766
769 // Choose a unique ID number for observers to see. 767 // Choose a unique ID number for observers to see.
770 int request_id = next_request_id_++; 768 int request_id = next_request_id_++;
771 769
772 // Update the net log and notify registered observers. 770 // Update the net log and notify registered observers.
773 OnStartRequest(net_log, request_id, info); 771 OnStartRequest(net_log, request_id, info);
774 772
773 // Check for IP literal.
774 IPAddressNumber ip_number;
775 if (ParseIPLiteralToNumber(info.hostname(), &ip_number)) {
776 DCHECK_EQ((info.host_resolver_flags() &
777 ~(HOST_RESOLVER_CANONNAME | HOST_RESOLVER_LOOPBACK_ONLY)), 0)
778 << " Unhandled flag";
779 AddressList result(ip_number, info.port(),
780 (info.host_resolver_flags() & HOST_RESOLVER_CANONNAME));
781
782 *addresses = result;
783 // Update the net log and notify registered observers.
784 OnFinishRequest(net_log, request_id, info, OK,
785 0, /* os_error (unknown since from cache) */
786 false /* was_from_cache */);
787 return OK;
788 }
789
775 // Build a key that identifies the request in the cache and in the 790 // Build a key that identifies the request in the cache and in the
776 // outstanding jobs map. 791 // outstanding jobs map.
777 Key key = GetEffectiveKeyForRequest(info); 792 Key key = GetEffectiveKeyForRequest(info);
778 793
779 // If we have an unexpired cache entry, use it. 794 // If we have an unexpired cache entry, use it.
780 if (info.allow_cached_response() && cache_.get()) { 795 if (info.allow_cached_response() && cache_.get()) {
781 const HostCache::Entry* cache_entry = cache_->Lookup( 796 const HostCache::Entry* cache_entry = cache_->Lookup(
782 key, base::TimeTicks::Now()); 797 key, base::TimeTicks::Now());
783 if (cache_entry) { 798 if (cache_entry) {
784 int net_error = cache_entry->error; 799 int net_error = cache_entry->error;
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 if (r == req) 1183 if (r == req)
1169 return error; 1184 return error;
1170 1185
1171 r->OnComplete(error, AddressList()); 1186 r->OnComplete(error, AddressList());
1172 } 1187 }
1173 1188
1174 return ERR_IO_PENDING; 1189 return ERR_IO_PENDING;
1175 } 1190 }
1176 1191
1177 } // namespace net 1192 } // namespace net
OLDNEW
« no previous file with comments | « net/base/address_list_unittest.cc ('k') | net/base/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698