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

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

Issue 8429034: Upstream: Build net_unittests for Android. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 1 month 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
OLDNEW
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
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
407 bool RRResponse::ParseFromResponse(const uint8* p, unsigned len, 413 bool RRResponse::ParseFromResponse(const uint8* p, unsigned len,
408 uint16 rrtype_requested) { 414 uint16 rrtype_requested) {
409 #if defined(OS_POSIX) 415 #if defined(OS_POSIX) && !defined(OS_ANDROID)
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
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) 494 #endif // defined(OS_POSIX) && !defined(OS_ANDROID)
489 495
490 return true; 496 return true;
491 } 497 }
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)
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698