| 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/proxy/dhcp_proxy_script_adapter_fetcher_win.h" | 5 #include "net/proxy/dhcp_proxy_script_adapter_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/logging.h" |
| 9 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 11 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
| 12 #include "base/threading/worker_pool.h" | 13 #include "base/threading/worker_pool.h" |
| 13 #include "base/time.h" | 14 #include "base/time.h" |
| 14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 15 #include "net/proxy/dhcpcsvc_init_win.h" | 16 #include "net/proxy/dhcpcsvc_init_win.h" |
| 16 #include "net/proxy/proxy_script_fetcher_impl.h" | 17 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 17 #include "net/url_request/url_request_context.h" | 18 #include "net/url_request/url_request_context.h" |
| 18 | 19 |
| 19 #include <windows.h> | 20 #include <windows.h> |
| 20 #include <winsock2.h> | 21 #include <winsock2.h> |
| 21 #include <dhcpcsdk.h> | 22 #include <dhcpcsdk.h> |
| 22 #pragma comment(lib, "dhcpcsvc.lib") | 23 #pragma comment(lib, "dhcpcsvc.lib") |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // Maximum amount of time to wait for response from the Win32 DHCP API. | 27 // Maximum amount of time to wait for response from the Win32 DHCP API. |
| 27 const int kTimeoutMs = 2000; | 28 const int kTimeoutMs = 2000; |
| 28 | 29 |
| 29 } // namespace | 30 } // namespace |
| 30 | 31 |
| 31 namespace net { | 32 namespace net { |
| 32 | 33 |
| 33 DhcpProxyScriptAdapterFetcher::DhcpProxyScriptAdapterFetcher( | 34 DhcpProxyScriptAdapterFetcher::DhcpProxyScriptAdapterFetcher( |
| 34 URLRequestContext* url_request_context) | 35 URLRequestContext* url_request_context) |
| 35 : state_(STATE_START), | 36 : state_(STATE_START), |
| 36 result_(ERR_IO_PENDING), | 37 result_(ERR_IO_PENDING), |
| 37 url_request_context_(url_request_context) { | 38 url_request_context_(url_request_context) { |
| 39 DCHECK(url_request_context_); |
| 38 } | 40 } |
| 39 | 41 |
| 40 DhcpProxyScriptAdapterFetcher::~DhcpProxyScriptAdapterFetcher() { | 42 DhcpProxyScriptAdapterFetcher::~DhcpProxyScriptAdapterFetcher() { |
| 41 Cancel(); | 43 Cancel(); |
| 42 | 44 |
| 43 // The WeakPtr we passed to the worker thread may be destroyed on the | 45 // The WeakPtr we passed to the worker thread may be destroyed on the |
| 44 // worker thread. This detaches any outstanding WeakPtr state from | 46 // worker thread. This detaches any outstanding WeakPtr state from |
| 45 // the current thread. | 47 // the current thread. |
| 46 base::SupportsWeakPtr<DhcpProxyScriptAdapterFetcher>::DetachFromThread(); | 48 base::SupportsWeakPtr<DhcpProxyScriptAdapterFetcher>::DetachFromThread(); |
| 47 } | 49 } |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // back a buffer with embedded NULLs, something is broken anyway. | 284 // back a buffer with embedded NULLs, something is broken anyway. |
| 283 return std::string( | 285 return std::string( |
| 284 std::string(reinterpret_cast<const char *>(wpad_params.Data), | 286 std::string(reinterpret_cast<const char *>(wpad_params.Data), |
| 285 wpad_params.nBytesData).c_str()); | 287 wpad_params.nBytesData).c_str()); |
| 286 } | 288 } |
| 287 | 289 |
| 288 return ""; | 290 return ""; |
| 289 } | 291 } |
| 290 | 292 |
| 291 } // namespace net | 293 } // namespace net |
| OLD | NEW |