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_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/logging.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 | 111 |
112 GURL DhcpProxyScriptAdapterFetcher::GetPacURL() const { | 112 GURL DhcpProxyScriptAdapterFetcher::GetPacURL() const { |
113 DCHECK(CalledOnValidThread()); | 113 DCHECK(CalledOnValidThread()); |
114 return pac_url_; | 114 return pac_url_; |
115 } | 115 } |
116 | 116 |
117 DhcpProxyScriptAdapterFetcher::DhcpQuery::DhcpQuery() { | 117 DhcpProxyScriptAdapterFetcher::DhcpQuery::DhcpQuery() { |
118 } | 118 } |
119 | 119 |
120 DhcpProxyScriptAdapterFetcher::DhcpQuery::~DhcpQuery() { | |
121 } | |
122 | |
123 void DhcpProxyScriptAdapterFetcher::DhcpQuery::GetPacURLForAdapter( | 120 void DhcpProxyScriptAdapterFetcher::DhcpQuery::GetPacURLForAdapter( |
124 const std::string& adapter_name) { | 121 const std::string& adapter_name) { |
125 url_ = ImplGetPacURLFromDhcp(adapter_name); | 122 url_ = ImplGetPacURLFromDhcp(adapter_name); |
126 } | 123 } |
127 | 124 |
128 const std::string& DhcpProxyScriptAdapterFetcher::DhcpQuery::url() const { | 125 const std::string& DhcpProxyScriptAdapterFetcher::DhcpQuery::url() const { |
129 return url_; | 126 return url_; |
130 } | 127 } |
131 | 128 |
132 std::string | 129 std::string |
133 DhcpProxyScriptAdapterFetcher::DhcpQuery::ImplGetPacURLFromDhcp( | 130 DhcpProxyScriptAdapterFetcher::DhcpQuery::ImplGetPacURLFromDhcp( |
134 const std::string& adapter_name) { | 131 const std::string& adapter_name) { |
135 return DhcpProxyScriptAdapterFetcher::GetPacURLFromDhcp(adapter_name); | 132 return DhcpProxyScriptAdapterFetcher::GetPacURLFromDhcp(adapter_name); |
136 } | 133 } |
137 | 134 |
| 135 DhcpProxyScriptAdapterFetcher::DhcpQuery::~DhcpQuery() { |
| 136 } |
| 137 |
138 void DhcpProxyScriptAdapterFetcher::OnDhcpQueryDone( | 138 void DhcpProxyScriptAdapterFetcher::OnDhcpQueryDone( |
139 scoped_refptr<DhcpQuery> dhcp_query) { | 139 scoped_refptr<DhcpQuery> dhcp_query) { |
140 DCHECK(CalledOnValidThread()); | 140 DCHECK(CalledOnValidThread()); |
141 // Because we can't cancel the call to the Win32 API, we can expect | 141 // Because we can't cancel the call to the Win32 API, we can expect |
142 // it to finish while we are in a few different states. The expected | 142 // it to finish while we are in a few different states. The expected |
143 // one is WAIT_DHCP, but it could be in CANCEL if Cancel() was called, | 143 // one is WAIT_DHCP, but it could be in CANCEL if Cancel() was called, |
144 // or FINISH if timeout occurred. | 144 // or FINISH if timeout occurred. |
145 DCHECK(state_ == STATE_WAIT_DHCP || state_ == STATE_CANCEL || | 145 DCHECK(state_ == STATE_WAIT_DHCP || state_ == STATE_CANCEL || |
146 state_ == STATE_FINISH); | 146 state_ == STATE_FINISH); |
147 if (state_ != STATE_WAIT_DHCP) | 147 if (state_ != STATE_WAIT_DHCP) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 // first null in case of embedded NULLs; this is the outer | 283 // first null in case of embedded NULLs; this is the outer |
284 // constructor that takes the result of c_str() on the inner. If | 284 // constructor that takes the result of c_str() on the inner. If |
285 // the server is giving us back a buffer with embedded NULLs, | 285 // the server is giving us back a buffer with embedded NULLs, |
286 // something is broken anyway. Finally, trim trailing whitespace. | 286 // something is broken anyway. Finally, trim trailing whitespace. |
287 std::string result(std::string(data, count_bytes).c_str()); | 287 std::string result(std::string(data, count_bytes).c_str()); |
288 base::TrimWhitespaceASCII(result, base::TRIM_TRAILING, &result); | 288 base::TrimWhitespaceASCII(result, base::TRIM_TRAILING, &result); |
289 return result; | 289 return result; |
290 } | 290 } |
291 | 291 |
292 } // namespace net | 292 } // namespace net |
OLD | NEW |