Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: net/base/host_resolver_impl.cc

Issue 10066045: RefCounted types should not have public destructors, net/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Deprecated cookiestore fix Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/file_stream_net_log_parameters.cc ('k') | net/base/host_resolver_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/host_resolver_impl.h" 5 #include "net/base/host_resolver_impl.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <Winsock2.h> 8 #include <Winsock2.h>
9 #elif defined(OS_POSIX) 9 #elif defined(OS_POSIX)
10 #include <netdb.h> 10 #include <netdb.h>
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 AddressFamily address_family, 168 AddressFamily address_family,
169 HostResolverFlags host_resolver_flags, 169 HostResolverFlags host_resolver_flags,
170 AddressList* addr_list, 170 AddressList* addr_list,
171 int* os_error) OVERRIDE { 171 int* os_error) OVERRIDE {
172 return SystemHostResolverProc(hostname, 172 return SystemHostResolverProc(hostname,
173 address_family, 173 address_family,
174 host_resolver_flags, 174 host_resolver_flags,
175 addr_list, 175 addr_list,
176 os_error); 176 os_error);
177 } 177 }
178
179 protected:
180 virtual ~CallSystemHostResolverProc() {}
178 }; 181 };
179 182
180 // Extra parameters to attach to the NetLog when the resolve failed. 183 // Extra parameters to attach to the NetLog when the resolve failed.
181 class ProcTaskFailedParams : public NetLog::EventParameters { 184 class ProcTaskFailedParams : public NetLog::EventParameters {
182 public: 185 public:
183 ProcTaskFailedParams(uint32 attempt_number, int net_error, int os_error) 186 ProcTaskFailedParams(uint32 attempt_number, int net_error, int os_error)
184 : attempt_number_(attempt_number), 187 : attempt_number_(attempt_number),
185 net_error_(net_error), 188 net_error_(net_error),
186 os_error_(os_error) { 189 os_error_(os_error) {
187 } 190 }
(...skipping 21 matching lines...) Expand all
209 0, // Buffer size. 212 0, // Buffer size.
210 0); // Arguments (unused). 213 0); // Arguments (unused).
211 dict->SetString("os_error_string", WideToUTF8(error_string)); 214 dict->SetString("os_error_string", WideToUTF8(error_string));
212 LocalFree(error_string); 215 LocalFree(error_string);
213 #endif 216 #endif
214 } 217 }
215 218
216 return dict; 219 return dict;
217 } 220 }
218 221
222 protected:
223 virtual ~ProcTaskFailedParams() {}
224
219 private: 225 private:
220 const uint32 attempt_number_; 226 const uint32 attempt_number_;
221 const int net_error_; 227 const int net_error_;
222 const int os_error_; 228 const int os_error_;
223 }; 229 };
224 230
225 // Extra parameters to attach to the NetLog when the DnsTask failed. 231 // Extra parameters to attach to the NetLog when the DnsTask failed.
226 class DnsTaskFailedParams : public NetLog::EventParameters { 232 class DnsTaskFailedParams : public NetLog::EventParameters {
227 public: 233 public:
228 DnsTaskFailedParams(int net_error, int dns_error) 234 DnsTaskFailedParams(int net_error, int dns_error)
229 : net_error_(net_error), dns_error_(dns_error) { 235 : net_error_(net_error), dns_error_(dns_error) {
230 } 236 }
231 237
232 virtual Value* ToValue() const OVERRIDE { 238 virtual Value* ToValue() const OVERRIDE {
233 DictionaryValue* dict = new DictionaryValue(); 239 DictionaryValue* dict = new DictionaryValue();
234 dict->SetInteger("net_error", net_error_); 240 dict->SetInteger("net_error", net_error_);
235 if (dns_error_) 241 if (dns_error_)
236 dict->SetInteger("dns_error", dns_error_); 242 dict->SetInteger("dns_error", dns_error_);
237 return dict; 243 return dict;
238 } 244 }
239 245
246 protected:
247 virtual ~DnsTaskFailedParams() {}
248
240 private: 249 private:
241 const int net_error_; 250 const int net_error_;
242 const int dns_error_; 251 const int dns_error_;
243 }; 252 };
244 253
245 // Parameters representing the information in a RequestInfo object, along with 254 // Parameters representing the information in a RequestInfo object, along with
246 // the associated NetLog::Source. 255 // the associated NetLog::Source.
247 class RequestInfoParameters : public NetLog::EventParameters { 256 class RequestInfoParameters : public NetLog::EventParameters {
248 public: 257 public:
249 RequestInfoParameters(const HostResolver::RequestInfo& info, 258 RequestInfoParameters(const HostResolver::RequestInfo& info,
250 const NetLog::Source& source) 259 const NetLog::Source& source)
251 : info_(info), source_(source) {} 260 : info_(info), source_(source) {}
252 261
253 virtual Value* ToValue() const OVERRIDE { 262 virtual Value* ToValue() const OVERRIDE {
254 DictionaryValue* dict = new DictionaryValue(); 263 DictionaryValue* dict = new DictionaryValue();
255 dict->SetString("host", info_.host_port_pair().ToString()); 264 dict->SetString("host", info_.host_port_pair().ToString());
256 dict->SetInteger("address_family", 265 dict->SetInteger("address_family",
257 static_cast<int>(info_.address_family())); 266 static_cast<int>(info_.address_family()));
258 dict->SetBoolean("allow_cached_response", info_.allow_cached_response()); 267 dict->SetBoolean("allow_cached_response", info_.allow_cached_response());
259 dict->SetBoolean("is_speculative", info_.is_speculative()); 268 dict->SetBoolean("is_speculative", info_.is_speculative());
260 dict->SetInteger("priority", info_.priority()); 269 dict->SetInteger("priority", info_.priority());
261 270
262 if (source_.is_valid()) 271 if (source_.is_valid())
263 dict->Set("source_dependency", source_.ToValue()); 272 dict->Set("source_dependency", source_.ToValue());
264 273
265 return dict; 274 return dict;
266 } 275 }
267 276
277 protected:
278 virtual ~RequestInfoParameters() {}
279
268 private: 280 private:
269 const HostResolver::RequestInfo info_; 281 const HostResolver::RequestInfo info_;
270 const NetLog::Source source_; 282 const NetLog::Source source_;
271 }; 283 };
272 284
273 // Parameters associated with the creation of a HostResolverImpl::Job. 285 // Parameters associated with the creation of a HostResolverImpl::Job.
274 class JobCreationParameters : public NetLog::EventParameters { 286 class JobCreationParameters : public NetLog::EventParameters {
275 public: 287 public:
276 JobCreationParameters(const std::string& host, 288 JobCreationParameters(const std::string& host,
277 const NetLog::Source& source) 289 const NetLog::Source& source)
278 : host_(host), source_(source) {} 290 : host_(host), source_(source) {}
279 291
280 virtual Value* ToValue() const OVERRIDE { 292 virtual Value* ToValue() const OVERRIDE {
281 DictionaryValue* dict = new DictionaryValue(); 293 DictionaryValue* dict = new DictionaryValue();
282 dict->SetString("host", host_); 294 dict->SetString("host", host_);
283 dict->Set("source_dependency", source_.ToValue()); 295 dict->Set("source_dependency", source_.ToValue());
284 return dict; 296 return dict;
285 } 297 }
286 298
299 protected:
300 virtual ~JobCreationParameters() {}
301
287 private: 302 private:
288 const std::string host_; 303 const std::string host_;
289 const NetLog::Source source_; 304 const NetLog::Source source_;
290 }; 305 };
291 306
292 // Parameters of the HOST_RESOLVER_IMPL_JOB_ATTACH/DETACH event. 307 // Parameters of the HOST_RESOLVER_IMPL_JOB_ATTACH/DETACH event.
293 class JobAttachParameters : public NetLog::EventParameters { 308 class JobAttachParameters : public NetLog::EventParameters {
294 public: 309 public:
295 JobAttachParameters(const NetLog::Source& source, 310 JobAttachParameters(const NetLog::Source& source,
296 RequestPriority priority) 311 RequestPriority priority)
297 : source_(source), priority_(priority) {} 312 : source_(source), priority_(priority) {}
298 313
299 virtual Value* ToValue() const OVERRIDE { 314 virtual Value* ToValue() const OVERRIDE {
300 DictionaryValue* dict = new DictionaryValue(); 315 DictionaryValue* dict = new DictionaryValue();
301 dict->Set("source_dependency", source_.ToValue()); 316 dict->Set("source_dependency", source_.ToValue());
302 dict->SetInteger("priority", priority_); 317 dict->SetInteger("priority", priority_);
303 return dict; 318 return dict;
304 } 319 }
305 320
321 protected:
322 virtual ~JobAttachParameters() {}
323
306 private: 324 private:
307 const NetLog::Source source_; 325 const NetLog::Source source_;
308 const RequestPriority priority_; 326 const RequestPriority priority_;
309 }; 327 };
310 328
311 // Parameters of the DNS_CONFIG_CHANGED event. 329 // Parameters of the DNS_CONFIG_CHANGED event.
312 class DnsConfigParameters : public NetLog::EventParameters { 330 class DnsConfigParameters : public NetLog::EventParameters {
313 public: 331 public:
314 explicit DnsConfigParameters(const DnsConfig& config) 332 explicit DnsConfigParameters(const DnsConfig& config)
315 : num_hosts_(config.hosts.size()) { 333 : num_hosts_(config.hosts.size()) {
316 config_.CopyIgnoreHosts(config); 334 config_.CopyIgnoreHosts(config);
317 } 335 }
318 336
319 virtual Value* ToValue() const OVERRIDE { 337 virtual Value* ToValue() const OVERRIDE {
320 Value* value = config_.ToValue(); 338 Value* value = config_.ToValue();
321 if (!value) 339 if (!value)
322 return NULL; 340 return NULL;
323 DictionaryValue* dict; 341 DictionaryValue* dict;
324 if (value->GetAsDictionary(&dict)) 342 if (value->GetAsDictionary(&dict))
325 dict->SetInteger("num_hosts", num_hosts_); 343 dict->SetInteger("num_hosts", num_hosts_);
326 return value; 344 return value;
327 } 345 }
328 346
347 protected:
348 virtual ~DnsConfigParameters() {}
349
329 private: 350 private:
330 DnsConfig config_; // Does not include DnsHosts to save memory and work. 351 DnsConfig config_; // Does not include DnsHosts to save memory and work.
331 const size_t num_hosts_; 352 const size_t num_hosts_;
332 }; 353 };
333 354
334 // The logging routines are defined here because some requests are resolved 355 // The logging routines are defined here because some requests are resolved
335 // without a Request object. 356 // without a Request object.
336 357
337 // Logs when a request has just been started. 358 // Logs when a request has just been started.
338 void LogStartRequest(const BoundNetLog& source_net_log, 359 void LogStartRequest(const BoundNetLog& source_net_log,
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 DCHECK(origin_loop_->BelongsToCurrentThread()); 649 DCHECK(origin_loop_->BelongsToCurrentThread());
629 return callback_.is_null(); 650 return callback_.is_null();
630 } 651 }
631 652
632 bool was_completed() const { 653 bool was_completed() const {
633 DCHECK(origin_loop_->BelongsToCurrentThread()); 654 DCHECK(origin_loop_->BelongsToCurrentThread());
634 return completed_attempt_number_ > 0; 655 return completed_attempt_number_ > 0;
635 } 656 }
636 657
637 private: 658 private:
659 friend class base::RefCountedThreadSafe<ProcTask>;
660 ~ProcTask() {}
661
638 void StartLookupAttempt() { 662 void StartLookupAttempt() {
639 DCHECK(origin_loop_->BelongsToCurrentThread()); 663 DCHECK(origin_loop_->BelongsToCurrentThread());
640 base::TimeTicks start_time = base::TimeTicks::Now(); 664 base::TimeTicks start_time = base::TimeTicks::Now();
641 ++attempt_number_; 665 ++attempt_number_;
642 // Dispatch the lookup attempt to a worker thread. 666 // Dispatch the lookup attempt to a worker thread.
643 if (!base::WorkerPool::PostTask( 667 if (!base::WorkerPool::PostTask(
644 FROM_HERE, 668 FROM_HERE,
645 base::Bind(&ProcTask::DoLookup, this, start_time, attempt_number_), 669 base::Bind(&ProcTask::DoLookup, this, start_time, attempt_number_),
646 true)) { 670 true)) {
647 NOTREACHED(); 671 NOTREACHED();
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 1975
1952 if (self && dns_config.IsValid()) 1976 if (self && dns_config.IsValid())
1953 TryServingAllJobsFromHosts(); 1977 TryServingAllJobsFromHosts();
1954 } 1978 }
1955 1979
1956 bool HostResolverImpl::HaveDnsConfig() const { 1980 bool HostResolverImpl::HaveDnsConfig() const {
1957 return (dns_client_.get() != NULL) && (dns_client_->GetConfig() != NULL); 1981 return (dns_client_.get() != NULL) && (dns_client_->GetConfig() != NULL);
1958 } 1982 }
1959 1983
1960 } // namespace net 1984 } // namespace net
OLDNEW
« no previous file with comments | « net/base/file_stream_net_log_parameters.cc ('k') | net/base/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698