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_fetcher_win.h" | 5 #include "net/proxy/dhcp_proxy_script_fetcher_win.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/perftimer.h" | 8 #include "base/perftimer.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/proxy/dhcp_proxy_script_adapter_fetcher_win.h" | 10 #include "net/proxy/dhcp_proxy_script_adapter_fetcher_win.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 base::TimeTicks::Now() - fetch_start_time_); | 92 base::TimeTicks::Now() - fetch_start_time_); |
93 } | 93 } |
94 | 94 |
95 CancelImpl(); | 95 CancelImpl(); |
96 } | 96 } |
97 | 97 |
98 void DhcpProxyScriptFetcherWin::CancelImpl() { | 98 void DhcpProxyScriptFetcherWin::CancelImpl() { |
99 DCHECK(CalledOnValidThread()); | 99 DCHECK(CalledOnValidThread()); |
100 | 100 |
101 if (state_ != STATE_DONE) { | 101 if (state_ != STATE_DONE) { |
| 102 client_callback_ = NULL; |
102 wait_timer_.Stop(); | 103 wait_timer_.Stop(); |
103 state_ = STATE_DONE; | 104 state_ = STATE_DONE; |
104 | 105 |
105 for (FetcherVector::iterator it = fetchers_.begin(); | 106 for (FetcherVector::iterator it = fetchers_.begin(); |
106 it != fetchers_.end(); | 107 it != fetchers_.end(); |
107 ++it) { | 108 ++it) { |
108 (*it)->Cancel(); | 109 (*it)->Cancel(); |
109 } | 110 } |
110 | 111 |
111 fetchers_.reset(); | 112 fetchers_.reset(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 ++it) { | 200 ++it) { |
200 if ((*it)->DidFinish()) { | 201 if ((*it)->DidFinish()) { |
201 result = (*it)->GetResult(); | 202 result = (*it)->GetResult(); |
202 if (result != ERR_PAC_NOT_IN_DHCP) { | 203 if (result != ERR_PAC_NOT_IN_DHCP) { |
203 break; | 204 break; |
204 } | 205 } |
205 } | 206 } |
206 } | 207 } |
207 } | 208 } |
208 | 209 |
| 210 CompletionCallback* callback = client_callback_; |
209 CancelImpl(); | 211 CancelImpl(); |
210 DCHECK_EQ(state_, STATE_DONE); | 212 DCHECK_EQ(state_, STATE_DONE); |
211 DCHECK(fetchers_.empty()); | 213 DCHECK(fetchers_.empty()); |
| 214 DCHECK(!client_callback_); // Invariant of data. |
212 | 215 |
213 UMA_HISTOGRAM_TIMES("Net.DhcpWpadCompletionTime", | 216 UMA_HISTOGRAM_TIMES("Net.DhcpWpadCompletionTime", |
214 base::TimeTicks::Now() - fetch_start_time_); | 217 base::TimeTicks::Now() - fetch_start_time_); |
215 | 218 |
216 if (result != OK) { | 219 if (result != OK) { |
217 UMA_HISTOGRAM_CUSTOM_ENUMERATION( | 220 UMA_HISTOGRAM_CUSTOM_ENUMERATION( |
218 "Net.DhcpWpadFetchError", std::abs(result), GetAllErrorCodesForUma()); | 221 "Net.DhcpWpadFetchError", std::abs(result), GetAllErrorCodesForUma()); |
219 } | 222 } |
220 | 223 |
221 client_callback_->Run(result); | 224 // We may be deleted re-entrantly within this outcall. |
| 225 callback->Run(result); |
222 } | 226 } |
223 | 227 |
224 int DhcpProxyScriptFetcherWin::num_pending_fetchers() const { | 228 int DhcpProxyScriptFetcherWin::num_pending_fetchers() const { |
225 return num_pending_fetchers_; | 229 return num_pending_fetchers_; |
226 } | 230 } |
227 | 231 |
228 URLRequestContext* DhcpProxyScriptFetcherWin::url_request_context() const { | 232 URLRequestContext* DhcpProxyScriptFetcherWin::url_request_context() const { |
229 return url_request_context_; | 233 return url_request_context_; |
230 } | 234 } |
231 | 235 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 continue; | 307 continue; |
304 | 308 |
305 DCHECK(adapter->AdapterName); | 309 DCHECK(adapter->AdapterName); |
306 adapter_names->insert(adapter->AdapterName); | 310 adapter_names->insert(adapter->AdapterName); |
307 } | 311 } |
308 | 312 |
309 return true; | 313 return true; |
310 } | 314 } |
311 | 315 |
312 } // namespace net | 316 } // namespace net |
OLD | NEW |