| 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/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 <netinet/in.h> | 8 #include <netinet/in.h> |
| 9 #include <resolv.h> | 9 #include <resolv.h> |
| 10 #endif | 10 #endif |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // Cancel is called from the origin loop when the DnsRRResolver is getting | 169 // Cancel is called from the origin loop when the DnsRRResolver is getting |
| 170 // deleted. | 170 // deleted. |
| 171 void Cancel() { | 171 void Cancel() { |
| 172 DCHECK_EQ(MessageLoop::current(), origin_loop_); | 172 DCHECK_EQ(MessageLoop::current(), origin_loop_); |
| 173 base::AutoLock locked(lock_); | 173 base::AutoLock locked(lock_); |
| 174 canceled_ = true; | 174 canceled_ = true; |
| 175 } | 175 } |
| 176 | 176 |
| 177 private: | 177 private: |
| 178 | 178 |
| 179 #if defined(OS_POSIX) | 179 #if defined(OS_ANDROID) |
| 180 |
| 181 void Run() { |
| 182 NOTIMPLEMENTED(); |
| 183 } |
| 184 |
| 185 #elif defined(OS_POSIX) |
| 180 | 186 |
| 181 void Run() { | 187 void Run() { |
| 182 // Runs on a worker thread. | 188 // Runs on a worker thread. |
| 183 | 189 |
| 184 if (HandleTestCases()) { | 190 if (HandleTestCases()) { |
| 185 Finish(); | 191 Finish(); |
| 186 return; | 192 return; |
| 187 } | 193 } |
| 188 | 194 |
| 189 bool r = true; | 195 bool r = true; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 403 |
| 398 DISALLOW_COPY_AND_ASSIGN(RRResolverWorker); | 404 DISALLOW_COPY_AND_ASSIGN(RRResolverWorker); |
| 399 }; | 405 }; |
| 400 | 406 |
| 401 bool RRResponse::HasExpired(const base::Time current_time) const { | 407 bool RRResponse::HasExpired(const base::Time current_time) const { |
| 402 const base::TimeDelta delta(base::TimeDelta::FromSeconds(ttl)); | 408 const base::TimeDelta delta(base::TimeDelta::FromSeconds(ttl)); |
| 403 const base::Time expiry = fetch_time + delta; | 409 const base::Time expiry = fetch_time + delta; |
| 404 return current_time >= expiry; | 410 return current_time >= expiry; |
| 405 } | 411 } |
| 406 | 412 |
| 413 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 407 bool RRResponse::ParseFromResponse(const uint8* p, unsigned len, | 414 bool RRResponse::ParseFromResponse(const uint8* p, unsigned len, |
| 408 uint16 rrtype_requested) { | 415 uint16 rrtype_requested) { |
| 409 #if defined(OS_POSIX) | |
| 410 name.clear(); | 416 name.clear(); |
| 411 ttl = 0; | 417 ttl = 0; |
| 412 dnssec = false; | 418 dnssec = false; |
| 413 negative = false; | 419 negative = false; |
| 414 rrdatas.clear(); | 420 rrdatas.clear(); |
| 415 signatures.clear(); | 421 signatures.clear(); |
| 416 | 422 |
| 417 // RFC 1035 section 4.4.1 | 423 // RFC 1035 section 4.4.1 |
| 418 uint8 flags2; | 424 uint8 flags2; |
| 419 DnsResponseBuffer buf(p, len); | 425 DnsResponseBuffer buf(p, len); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 return false; | 484 return false; |
| 479 | 485 |
| 480 if (klass == kClassIN && type == rrtype_requested) { | 486 if (klass == kClassIN && type == rrtype_requested) { |
| 481 if (i == 0) | 487 if (i == 0) |
| 482 this->ttl = ttl; | 488 this->ttl = ttl; |
| 483 rrdatas.push_back(std::string(rrdata.data(), rrdata.size())); | 489 rrdatas.push_back(std::string(rrdata.data(), rrdata.size())); |
| 484 } else if (klass == kClassIN && type == kDNS_RRSIG) { | 490 } else if (klass == kClassIN && type == kDNS_RRSIG) { |
| 485 signatures.push_back(std::string(rrdata.data(), rrdata.size())); | 491 signatures.push_back(std::string(rrdata.data(), rrdata.size())); |
| 486 } | 492 } |
| 487 } | 493 } |
| 488 #endif // defined(OS_POSIX) | |
| 489 | 494 |
| 490 return true; | 495 return true; |
| 491 } | 496 } |
| 497 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) |
| 492 | 498 |
| 493 | 499 |
| 494 // An RRResolverJob is a one-to-one counterpart of an RRResolverWorker. It | 500 // An RRResolverJob is a one-to-one counterpart of an RRResolverWorker. It |
| 495 // lives only on the DnsRRResolver's origin message loop. | 501 // lives only on the DnsRRResolver's origin message loop. |
| 496 class RRResolverJob { | 502 class RRResolverJob { |
| 497 public: | 503 public: |
| 498 explicit RRResolverJob(RRResolverWorker* worker) | 504 explicit RRResolverJob(RRResolverWorker* worker) |
| 499 : worker_(worker) { | 505 : worker_(worker) { |
| 500 } | 506 } |
| 501 | 507 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 return; | 677 return; |
| 672 } | 678 } |
| 673 RRResolverJob* job = j->second; | 679 RRResolverJob* job = j->second; |
| 674 inflight_.erase(j); | 680 inflight_.erase(j); |
| 675 | 681 |
| 676 job->HandleResult(result, response); | 682 job->HandleResult(result, response); |
| 677 delete job; | 683 delete job; |
| 678 } | 684 } |
| 679 | 685 |
| 680 } // namespace net | 686 } // namespace net |
| OLD | NEW |