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

Side by Side Diff: net/dns/mdns_client_impl.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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
« no previous file with comments | « net/dns/mdns_client_impl.h ('k') | net/dns/mdns_client_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/dns/mdns_client_impl.h" 5 #include "net/dns/mdns_client_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 208 }
209 209
210 MDnsClientImpl::Core::~Core() { 210 MDnsClientImpl::Core::~Core() {
211 STLDeleteValues(&listeners_); 211 STLDeleteValues(&listeners_);
212 } 212 }
213 213
214 bool MDnsClientImpl::Core::Init(MDnsSocketFactory* socket_factory) { 214 bool MDnsClientImpl::Core::Init(MDnsSocketFactory* socket_factory) {
215 return connection_->Init(socket_factory); 215 return connection_->Init(socket_factory);
216 } 216 }
217 217
218 bool MDnsClientImpl::Core::SendQuery(uint16 rrtype, const std::string& name) { 218 bool MDnsClientImpl::Core::SendQuery(uint16_t rrtype, const std::string& name) {
219 std::string name_dns; 219 std::string name_dns;
220 if (!DNSDomainFromDot(name, &name_dns)) 220 if (!DNSDomainFromDot(name, &name_dns))
221 return false; 221 return false;
222 222
223 DnsQuery query(0, name_dns, rrtype); 223 DnsQuery query(0, name_dns, rrtype);
224 query.set_flags(0); // Remove the RD flag from the query. It is unneeded. 224 query.set_flags(0); // Remove the RD flag from the query. It is unneeded.
225 225
226 connection_->Send(query.io_buffer(), query.io_buffer()->size()); 226 connection_->Send(query.io_buffer(), query.io_buffer()->size());
227 return true; 227 return true;
228 } 228 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 ScheduleCleanup(cache_.next_expiration()); 414 ScheduleCleanup(cache_.next_expiration());
415 } 415 }
416 416
417 void MDnsClientImpl::Core::OnRecordRemoved( 417 void MDnsClientImpl::Core::OnRecordRemoved(
418 const RecordParsed* record) { 418 const RecordParsed* record) {
419 AlertListeners(MDnsCache::RecordRemoved, 419 AlertListeners(MDnsCache::RecordRemoved,
420 ListenerKey(record->name(), record->type()), record); 420 ListenerKey(record->name(), record->type()), record);
421 } 421 }
422 422
423 void MDnsClientImpl::Core::QueryCache( 423 void MDnsClientImpl::Core::QueryCache(
424 uint16 rrtype, const std::string& name, 424 uint16_t rrtype,
425 const std::string& name,
425 std::vector<const RecordParsed*>* records) const { 426 std::vector<const RecordParsed*>* records) const {
426 cache_.FindDnsRecords(rrtype, name, records, clock_->Now()); 427 cache_.FindDnsRecords(rrtype, name, records, clock_->Now());
427 } 428 }
428 429
429 MDnsClientImpl::MDnsClientImpl() 430 MDnsClientImpl::MDnsClientImpl()
430 : clock_(new base::DefaultClock), 431 : clock_(new base::DefaultClock),
431 cleanup_timer_(new base::Timer(false, false)) { 432 cleanup_timer_(new base::Timer(false, false)) {
432 } 433 }
433 434
434 MDnsClientImpl::MDnsClientImpl(scoped_ptr<base::Clock> clock, 435 MDnsClientImpl::MDnsClientImpl(scoped_ptr<base::Clock> clock,
(...skipping 16 matching lines...) Expand all
451 452
452 void MDnsClientImpl::StopListening() { 453 void MDnsClientImpl::StopListening() {
453 core_.reset(); 454 core_.reset();
454 } 455 }
455 456
456 bool MDnsClientImpl::IsListening() const { 457 bool MDnsClientImpl::IsListening() const {
457 return core_.get() != NULL; 458 return core_.get() != NULL;
458 } 459 }
459 460
460 scoped_ptr<MDnsListener> MDnsClientImpl::CreateListener( 461 scoped_ptr<MDnsListener> MDnsClientImpl::CreateListener(
461 uint16 rrtype, 462 uint16_t rrtype,
462 const std::string& name, 463 const std::string& name,
463 MDnsListener::Delegate* delegate) { 464 MDnsListener::Delegate* delegate) {
464 return scoped_ptr<MDnsListener>( 465 return scoped_ptr<MDnsListener>(
465 new MDnsListenerImpl(rrtype, name, clock_.get(), delegate, this)); 466 new MDnsListenerImpl(rrtype, name, clock_.get(), delegate, this));
466 } 467 }
467 468
468 scoped_ptr<MDnsTransaction> MDnsClientImpl::CreateTransaction( 469 scoped_ptr<MDnsTransaction> MDnsClientImpl::CreateTransaction(
469 uint16 rrtype, 470 uint16_t rrtype,
470 const std::string& name, 471 const std::string& name,
471 int flags, 472 int flags,
472 const MDnsTransaction::ResultCallback& callback) { 473 const MDnsTransaction::ResultCallback& callback) {
473 return scoped_ptr<MDnsTransaction>( 474 return scoped_ptr<MDnsTransaction>(
474 new MDnsTransactionImpl(rrtype, name, flags, callback, this)); 475 new MDnsTransactionImpl(rrtype, name, flags, callback, this));
475 } 476 }
476 477
477 MDnsListenerImpl::MDnsListenerImpl(uint16 rrtype, 478 MDnsListenerImpl::MDnsListenerImpl(uint16_t rrtype,
478 const std::string& name, 479 const std::string& name,
479 base::Clock* clock, 480 base::Clock* clock,
480 MDnsListener::Delegate* delegate, 481 MDnsListener::Delegate* delegate,
481 MDnsClientImpl* client) 482 MDnsClientImpl* client)
482 : rrtype_(rrtype), 483 : rrtype_(rrtype),
483 name_(name), 484 name_(name),
484 clock_(clock), 485 clock_(clock),
485 client_(client), 486 client_(client),
486 delegate_(delegate), 487 delegate_(delegate),
487 started_(false), 488 started_(false),
488 active_refresh_(false) { 489 active_refresh_(false) {}
489 }
490 490
491 MDnsListenerImpl::~MDnsListenerImpl() { 491 MDnsListenerImpl::~MDnsListenerImpl() {
492 if (started_) { 492 if (started_) {
493 DCHECK(client_->core()); 493 DCHECK(client_->core());
494 client_->core()->RemoveListener(this); 494 client_->core()->RemoveListener(this);
495 } 495 }
496 } 496 }
497 497
498 bool MDnsListenerImpl::Start() { 498 bool MDnsListenerImpl::Start() {
499 DCHECK(!started_); 499 DCHECK(!started_);
(...skipping 15 matching lines...) Expand all
515 } else if (last_update_ != base::Time()) { 515 } else if (last_update_ != base::Time()) {
516 ScheduleNextRefresh(); 516 ScheduleNextRefresh();
517 } 517 }
518 } 518 }
519 } 519 }
520 520
521 const std::string& MDnsListenerImpl::GetName() const { 521 const std::string& MDnsListenerImpl::GetName() const {
522 return name_; 522 return name_;
523 } 523 }
524 524
525 uint16 MDnsListenerImpl::GetType() const { 525 uint16_t MDnsListenerImpl::GetType() const {
526 return rrtype_; 526 return rrtype_;
527 } 527 }
528 528
529 void MDnsListenerImpl::HandleRecordUpdate(MDnsCache::UpdateType update_type, 529 void MDnsListenerImpl::HandleRecordUpdate(MDnsCache::UpdateType update_type,
530 const RecordParsed* record) { 530 const RecordParsed* record) {
531 DCHECK(started_); 531 DCHECK(started_);
532 532
533 if (update_type != MDnsCache::RecordRemoved) { 533 if (update_type != MDnsCache::RecordRemoved) {
534 ttl_ = record->ttl(); 534 ttl_ = record->ttl();
535 last_update_ = record->time_created(); 535 last_update_ = record->time_created();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 598
599 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 599 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
600 FROM_HERE, next_refresh_.callback(), next_refresh2 - clock_->Now()); 600 FROM_HERE, next_refresh_.callback(), next_refresh2 - clock_->Now());
601 } 601 }
602 602
603 void MDnsListenerImpl::DoRefresh() { 603 void MDnsListenerImpl::DoRefresh() {
604 client_->core()->SendQuery(rrtype_, name_); 604 client_->core()->SendQuery(rrtype_, name_);
605 } 605 }
606 606
607 MDnsTransactionImpl::MDnsTransactionImpl( 607 MDnsTransactionImpl::MDnsTransactionImpl(
608 uint16 rrtype, 608 uint16_t rrtype,
609 const std::string& name, 609 const std::string& name,
610 int flags, 610 int flags,
611 const MDnsTransaction::ResultCallback& callback, 611 const MDnsTransaction::ResultCallback& callback,
612 MDnsClientImpl* client) 612 MDnsClientImpl* client)
613 : rrtype_(rrtype), name_(name), callback_(callback), client_(client), 613 : rrtype_(rrtype),
614 started_(false), flags_(flags) { 614 name_(name),
615 callback_(callback),
616 client_(client),
617 started_(false),
618 flags_(flags) {
615 DCHECK((flags_ & MDnsTransaction::FLAG_MASK) == flags_); 619 DCHECK((flags_ & MDnsTransaction::FLAG_MASK) == flags_);
616 DCHECK(flags_ & MDnsTransaction::QUERY_CACHE || 620 DCHECK(flags_ & MDnsTransaction::QUERY_CACHE ||
617 flags_ & MDnsTransaction::QUERY_NETWORK); 621 flags_ & MDnsTransaction::QUERY_NETWORK);
618 } 622 }
619 623
620 MDnsTransactionImpl::~MDnsTransactionImpl() { 624 MDnsTransactionImpl::~MDnsTransactionImpl() {
621 timeout_.Cancel(); 625 timeout_.Cancel();
622 } 626 }
623 627
624 bool MDnsTransactionImpl::Start() { 628 bool MDnsTransactionImpl::Start() {
(...skipping 14 matching lines...) Expand all
639 // If this is a cache only query, signal that the transaction is over 643 // If this is a cache only query, signal that the transaction is over
640 // immediately. 644 // immediately.
641 SignalTransactionOver(); 645 SignalTransactionOver();
642 return true; 646 return true;
643 } 647 }
644 648
645 const std::string& MDnsTransactionImpl::GetName() const { 649 const std::string& MDnsTransactionImpl::GetName() const {
646 return name_; 650 return name_;
647 } 651 }
648 652
649 uint16 MDnsTransactionImpl::GetType() const { 653 uint16_t MDnsTransactionImpl::GetType() const {
650 return rrtype_; 654 return rrtype_;
651 } 655 }
652 656
653 void MDnsTransactionImpl::CacheRecordFound(const RecordParsed* record) { 657 void MDnsTransactionImpl::CacheRecordFound(const RecordParsed* record) {
654 DCHECK(started_); 658 DCHECK(started_);
655 OnRecordUpdate(MDnsListener::RECORD_ADDED, record); 659 OnRecordUpdate(MDnsListener::RECORD_ADDED, record);
656 } 660 }
657 661
658 void MDnsTransactionImpl::TriggerCallback(MDnsTransaction::Result result, 662 void MDnsTransactionImpl::TriggerCallback(MDnsTransaction::Result result,
659 const RecordParsed* record) { 663 const RecordParsed* record) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 748
745 void MDnsTransactionImpl::OnNsecRecord(const std::string& name, unsigned type) { 749 void MDnsTransactionImpl::OnNsecRecord(const std::string& name, unsigned type) {
746 TriggerCallback(RESULT_NSEC, NULL); 750 TriggerCallback(RESULT_NSEC, NULL);
747 } 751 }
748 752
749 void MDnsTransactionImpl::OnCachePurged() { 753 void MDnsTransactionImpl::OnCachePurged() {
750 // TODO(noamsml): Cache purge situations not yet implemented 754 // TODO(noamsml): Cache purge situations not yet implemented
751 } 755 }
752 756
753 } // namespace net 757 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/mdns_client_impl.h ('k') | net/dns/mdns_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698