| 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 "net/dns/mock_host_resolver.h" | 5 #include "net/dns/mock_host_resolver.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 const unsigned kMaxCacheEntries = 100; | 34 const unsigned kMaxCacheEntries = 100; |
| 35 // TTL for the successful resolutions. Failures are not cached. | 35 // TTL for the successful resolutions. Failures are not cached. |
| 36 const unsigned kCacheEntryTTLSeconds = 60; | 36 const unsigned kCacheEntryTTLSeconds = 60; |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 int ParseAddressList(const std::string& host_list, | 40 int ParseAddressList(const std::string& host_list, |
| 41 const std::string& canonical_name, | 41 const std::string& canonical_name, |
| 42 AddressList* addrlist) { | 42 AddressList* addrlist) { |
| 43 *addrlist = AddressList(); | 43 *addrlist = AddressList(); |
| 44 std::vector<std::string> addresses; | |
| 45 base::SplitString(host_list, ',', &addresses); | |
| 46 addrlist->set_canonical_name(canonical_name); | 44 addrlist->set_canonical_name(canonical_name); |
| 47 for (size_t index = 0; index < addresses.size(); ++index) { | 45 for (const base::StringPiece& address : base::SplitStringPiece( |
| 46 host_list, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
| 48 IPAddressNumber ip_number; | 47 IPAddressNumber ip_number; |
| 49 if (!ParseIPLiteralToNumber(addresses[index], &ip_number)) { | 48 if (!ParseIPLiteralToNumber(address, &ip_number)) { |
| 50 LOG(WARNING) << "Not a supported IP literal: " << addresses[index]; | 49 LOG(WARNING) << "Not a supported IP literal: " << address.as_string(); |
| 51 return ERR_UNEXPECTED; | 50 return ERR_UNEXPECTED; |
| 52 } | 51 } |
| 53 addrlist->push_back(IPEndPoint(ip_number, 0)); | 52 addrlist->push_back(IPEndPoint(ip_number, 0)); |
| 54 } | 53 } |
| 55 return OK; | 54 return OK; |
| 56 } | 55 } |
| 57 | 56 |
| 58 struct MockHostResolverBase::Request { | 57 struct MockHostResolverBase::Request { |
| 59 Request(const RequestInfo& req_info, | 58 Request(const RequestInfo& req_info, |
| 60 AddressList* addr, | 59 AddressList* addr, |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 CHECK_EQ(old_proc, current_proc_.get()); | 444 CHECK_EQ(old_proc, current_proc_.get()); |
| 446 } | 445 } |
| 447 | 446 |
| 448 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { | 447 void ScopedDefaultHostResolverProc::Init(HostResolverProc* proc) { |
| 449 current_proc_ = proc; | 448 current_proc_ = proc; |
| 450 previous_proc_ = HostResolverProc::SetDefault(current_proc_.get()); | 449 previous_proc_ = HostResolverProc::SetDefault(current_proc_.get()); |
| 451 current_proc_->SetLastProc(previous_proc_.get()); | 450 current_proc_->SetLastProc(previous_proc_.get()); |
| 452 } | 451 } |
| 453 | 452 |
| 454 } // namespace net | 453 } // namespace net |
| OLD | NEW |