| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dnsrr_resolver.h" | 5 #include "net/base/dnsrr_resolver.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
| 8 #include <resolv.h> | 8 #include <resolv.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "base/lock.h" | 11 #include "base/lock.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "base/singleton.h" | 14 #include "base/singleton.h" |
| 15 #include "base/stl_util-inl.h" | 15 #include "base/stl_util-inl.h" |
| 16 #include "base/string_piece.h" | 16 #include "base/string_piece.h" |
| 17 #include "base/task.h" | 17 #include "base/task.h" |
| 18 #include "base/worker_pool.h" | 18 #include "base/threading/worker_pool.h" |
| 19 #include "net/base/dns_reload_timer.h" | 19 #include "net/base/dns_reload_timer.h" |
| 20 #include "net/base/dns_util.h" | 20 #include "net/base/dns_util.h" |
| 21 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 22 | 22 |
| 23 // Life of a query: | 23 // Life of a query: |
| 24 // | 24 // |
| 25 // DnsRRResolver RRResolverJob RRResolverWorker ... Handle | 25 // DnsRRResolver RRResolverJob RRResolverWorker ... Handle |
| 26 // | (origin loop) (worker loop) | 26 // | (origin loop) (worker loop) |
| 27 // | | 27 // | |
| 28 // Resolve() | 28 // Resolve() |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 flags_(flags), | 132 flags_(flags), |
| 133 origin_loop_(MessageLoop::current()), | 133 origin_loop_(MessageLoop::current()), |
| 134 dnsrr_resolver_(dnsrr_resolver), | 134 dnsrr_resolver_(dnsrr_resolver), |
| 135 canceled_(false), | 135 canceled_(false), |
| 136 result_(ERR_UNEXPECTED) { | 136 result_(ERR_UNEXPECTED) { |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool Start() { | 139 bool Start() { |
| 140 DCHECK_EQ(MessageLoop::current(), origin_loop_); | 140 DCHECK_EQ(MessageLoop::current(), origin_loop_); |
| 141 | 141 |
| 142 return WorkerPool::PostTask( | 142 return base::WorkerPool::PostTask( |
| 143 FROM_HERE, NewRunnableMethod(this, &RRResolverWorker::Run), | 143 FROM_HERE, NewRunnableMethod(this, &RRResolverWorker::Run), |
| 144 true /* task is slow */); | 144 true /* task is slow */); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Cancel is called from the origin loop when the DnsRRResolver is getting | 147 // Cancel is called from the origin loop when the DnsRRResolver is getting |
| 148 // deleted. | 148 // deleted. |
| 149 void Cancel() { | 149 void Cancel() { |
| 150 DCHECK_EQ(MessageLoop::current(), origin_loop_); | 150 DCHECK_EQ(MessageLoop::current(), origin_loop_); |
| 151 AutoLock locked(lock_); | 151 AutoLock locked(lock_); |
| 152 canceled_ = true; | 152 canceled_ = true; |
| 153 } | 153 } |
| 154 | 154 |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 inflight_.erase(j); | 734 inflight_.erase(j); |
| 735 | 735 |
| 736 job->HandleResult(result, response); | 736 job->HandleResult(result, response); |
| 737 delete job; | 737 delete job; |
| 738 } | 738 } |
| 739 | 739 |
| 740 } // namespace net | 740 } // namespace net |
| 741 | 741 |
| 742 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::RRResolverHandle); | 742 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::RRResolverHandle); |
| 743 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::RRResolverWorker); | 743 DISABLE_RUNNABLE_METHOD_REFCOUNT(net::RRResolverWorker); |
| OLD | NEW |