| 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/proxy/dhcp_proxy_script_fetcher_win.h" | 5 #include "net/proxy/dhcp_proxy_script_fetcher_win.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 } | 313 } |
| 314 | 314 |
| 315 bool DhcpProxyScriptFetcherWin::GetCandidateAdapterNames( | 315 bool DhcpProxyScriptFetcherWin::GetCandidateAdapterNames( |
| 316 std::set<std::string>* adapter_names) { | 316 std::set<std::string>* adapter_names) { |
| 317 DCHECK(adapter_names); | 317 DCHECK(adapter_names); |
| 318 adapter_names->clear(); | 318 adapter_names->clear(); |
| 319 | 319 |
| 320 // The GetAdaptersAddresses MSDN page recommends using a size of 15000 to | 320 // The GetAdaptersAddresses MSDN page recommends using a size of 15000 to |
| 321 // avoid reallocation. | 321 // avoid reallocation. |
| 322 ULONG adapters_size = 15000; | 322 ULONG adapters_size = 15000; |
| 323 scoped_ptr_malloc<IP_ADAPTER_ADDRESSES> adapters; | 323 scoped_ptr<IP_ADAPTER_ADDRESSES, base::FreeDeleter> adapters; |
| 324 ULONG error = ERROR_SUCCESS; | 324 ULONG error = ERROR_SUCCESS; |
| 325 int num_tries = 0; | 325 int num_tries = 0; |
| 326 | 326 |
| 327 base::ElapsedTimer time_api_access; | 327 base::ElapsedTimer time_api_access; |
| 328 do { | 328 do { |
| 329 adapters.reset( | 329 adapters.reset(static_cast<IP_ADAPTER_ADDRESSES*>(malloc(adapters_size))); |
| 330 reinterpret_cast<IP_ADAPTER_ADDRESSES*>(malloc(adapters_size))); | |
| 331 // Return only unicast addresses, and skip information we do not need. | 330 // Return only unicast addresses, and skip information we do not need. |
| 332 error = GetAdaptersAddresses(AF_UNSPEC, | 331 error = GetAdaptersAddresses(AF_UNSPEC, |
| 333 GAA_FLAG_SKIP_ANYCAST | | 332 GAA_FLAG_SKIP_ANYCAST | |
| 334 GAA_FLAG_SKIP_MULTICAST | | 333 GAA_FLAG_SKIP_MULTICAST | |
| 335 GAA_FLAG_SKIP_DNS_SERVER | | 334 GAA_FLAG_SKIP_DNS_SERVER | |
| 336 GAA_FLAG_SKIP_FRIENDLY_NAME, | 335 GAA_FLAG_SKIP_FRIENDLY_NAME, |
| 337 NULL, | 336 NULL, |
| 338 adapters.get(), | 337 adapters.get(), |
| 339 &adapters_size); | 338 &adapters_size); |
| 340 ++num_tries; | 339 ++num_tries; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 DhcpProxyScriptFetcherWin::AdapterQuery::adapter_names() const { | 391 DhcpProxyScriptFetcherWin::AdapterQuery::adapter_names() const { |
| 393 return adapter_names_; | 392 return adapter_names_; |
| 394 } | 393 } |
| 395 | 394 |
| 396 bool DhcpProxyScriptFetcherWin::AdapterQuery::ImplGetCandidateAdapterNames( | 395 bool DhcpProxyScriptFetcherWin::AdapterQuery::ImplGetCandidateAdapterNames( |
| 397 std::set<std::string>* adapter_names) { | 396 std::set<std::string>* adapter_names) { |
| 398 return DhcpProxyScriptFetcherWin::GetCandidateAdapterNames(adapter_names); | 397 return DhcpProxyScriptFetcherWin::GetCandidateAdapterNames(adapter_names); |
| 399 } | 398 } |
| 400 | 399 |
| 401 } // namespace net | 400 } // namespace net |
| OLD | NEW |