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

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

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « net/dns/mdns_client.cc ('k') | net/dns/mock_mdns_socket_factory.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 #include <utility>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/location.h" 12 #include "base/location.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/stl_util.h" 14 #include "base/stl_util.h"
14 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
15 #include "base/time/clock.h" 16 #include "base/time/clock.h"
16 #include "base/time/default_clock.h" 17 #include "base/time/default_clock.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "base/timer/timer.h" 19 #include "base/timer/timer.h"
(...skipping 26 matching lines...) Expand all
45 46
46 void MDnsSocketFactoryImpl::CreateSockets( 47 void MDnsSocketFactoryImpl::CreateSockets(
47 std::vector<scoped_ptr<DatagramServerSocket>>* sockets) { 48 std::vector<scoped_ptr<DatagramServerSocket>>* sockets) {
48 InterfaceIndexFamilyList interfaces(GetMDnsInterfacesToBind()); 49 InterfaceIndexFamilyList interfaces(GetMDnsInterfacesToBind());
49 for (size_t i = 0; i < interfaces.size(); ++i) { 50 for (size_t i = 0; i < interfaces.size(); ++i) {
50 DCHECK(interfaces[i].second == ADDRESS_FAMILY_IPV4 || 51 DCHECK(interfaces[i].second == ADDRESS_FAMILY_IPV4 ||
51 interfaces[i].second == ADDRESS_FAMILY_IPV6); 52 interfaces[i].second == ADDRESS_FAMILY_IPV6);
52 scoped_ptr<DatagramServerSocket> socket( 53 scoped_ptr<DatagramServerSocket> socket(
53 CreateAndBindMDnsSocket(interfaces[i].second, interfaces[i].first)); 54 CreateAndBindMDnsSocket(interfaces[i].second, interfaces[i].first));
54 if (socket) 55 if (socket)
55 sockets->push_back(socket.Pass()); 56 sockets->push_back(std::move(socket));
56 } 57 }
57 } 58 }
58 59
59 MDnsConnection::SocketHandler::SocketHandler( 60 MDnsConnection::SocketHandler::SocketHandler(
60 scoped_ptr<DatagramServerSocket> socket, 61 scoped_ptr<DatagramServerSocket> socket,
61 MDnsConnection* connection) 62 MDnsConnection* connection)
62 : socket_(socket.Pass()), 63 : socket_(std::move(socket)),
63 connection_(connection), 64 connection_(connection),
64 response_(dns_protocol::kMaxMulticastSize), 65 response_(dns_protocol::kMaxMulticastSize),
65 send_in_progress_(false) { 66 send_in_progress_(false) {}
66 }
67 67
68 MDnsConnection::SocketHandler::~SocketHandler() { 68 MDnsConnection::SocketHandler::~SocketHandler() {
69 } 69 }
70 70
71 int MDnsConnection::SocketHandler::Start() { 71 int MDnsConnection::SocketHandler::Start() {
72 IPEndPoint end_point; 72 IPEndPoint end_point;
73 int rv = socket_->GetLocalAddress(&end_point); 73 int rv = socket_->GetLocalAddress(&end_point);
74 if (rv != OK) 74 if (rv != OK)
75 return rv; 75 return rv;
76 DCHECK(end_point.GetFamily() == ADDRESS_FAMILY_IPV4 || 76 DCHECK(end_point.GetFamily() == ADDRESS_FAMILY_IPV4 ||
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 } 264 }
265 } 265 }
266 266
267 if ((record->klass() & dns_protocol::kMDnsClassMask) != 267 if ((record->klass() & dns_protocol::kMDnsClassMask) !=
268 dns_protocol::kClassIN) { 268 dns_protocol::kClassIN) {
269 DVLOG(1) << "Received an mDNS record with non-IN class. Ignoring."; 269 DVLOG(1) << "Received an mDNS record with non-IN class. Ignoring.";
270 continue; // Ignore all records not in the IN class. 270 continue; // Ignore all records not in the IN class.
271 } 271 }
272 272
273 MDnsCache::Key update_key = MDnsCache::Key::CreateFor(record.get()); 273 MDnsCache::Key update_key = MDnsCache::Key::CreateFor(record.get());
274 MDnsCache::UpdateType update = cache_.UpdateDnsRecord(record.Pass()); 274 MDnsCache::UpdateType update = cache_.UpdateDnsRecord(std::move(record));
275 275
276 // Cleanup time may have changed. 276 // Cleanup time may have changed.
277 ScheduleCleanup(cache_.next_expiration()); 277 ScheduleCleanup(cache_.next_expiration());
278 278
279 update_keys.insert(std::make_pair(update_key, update)); 279 update_keys.insert(std::make_pair(update_key, update));
280 } 280 }
281 281
282 for (std::map<MDnsCache::Key, MDnsCache::UpdateType>::iterator i = 282 for (std::map<MDnsCache::Key, MDnsCache::UpdateType>::iterator i =
283 update_keys.begin(); i != update_keys.end(); i++) { 283 update_keys.begin(); i != update_keys.end(); i++) {
284 const RecordParsed* record = cache_.LookupKey(i->first); 284 const RecordParsed* record = cache_.LookupKey(i->first);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 cache_.FindDnsRecords(rrtype, name, records, clock_->Now()); 427 cache_.FindDnsRecords(rrtype, name, records, clock_->Now());
428 } 428 }
429 429
430 MDnsClientImpl::MDnsClientImpl() 430 MDnsClientImpl::MDnsClientImpl()
431 : clock_(new base::DefaultClock), 431 : clock_(new base::DefaultClock),
432 cleanup_timer_(new base::Timer(false, false)) { 432 cleanup_timer_(new base::Timer(false, false)) {
433 } 433 }
434 434
435 MDnsClientImpl::MDnsClientImpl(scoped_ptr<base::Clock> clock, 435 MDnsClientImpl::MDnsClientImpl(scoped_ptr<base::Clock> clock,
436 scoped_ptr<base::Timer> timer) 436 scoped_ptr<base::Timer> timer)
437 : clock_(clock.Pass()), cleanup_timer_(timer.Pass()) { 437 : clock_(std::move(clock)), cleanup_timer_(std::move(timer)) {}
438 }
439 438
440 MDnsClientImpl::~MDnsClientImpl() { 439 MDnsClientImpl::~MDnsClientImpl() {
441 } 440 }
442 441
443 bool MDnsClientImpl::StartListening(MDnsSocketFactory* socket_factory) { 442 bool MDnsClientImpl::StartListening(MDnsSocketFactory* socket_factory) {
444 DCHECK(!core_.get()); 443 DCHECK(!core_.get());
445 core_.reset(new Core(clock_.get(), cleanup_timer_.get())); 444 core_.reset(new Core(clock_.get(), cleanup_timer_.get()));
446 if (!core_->Init(socket_factory)) { 445 if (!core_->Init(socket_factory)) {
447 core_.reset(); 446 core_.reset();
448 return false; 447 return false;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 747
749 void MDnsTransactionImpl::OnNsecRecord(const std::string& name, unsigned type) { 748 void MDnsTransactionImpl::OnNsecRecord(const std::string& name, unsigned type) {
750 TriggerCallback(RESULT_NSEC, NULL); 749 TriggerCallback(RESULT_NSEC, NULL);
751 } 750 }
752 751
753 void MDnsTransactionImpl::OnCachePurged() { 752 void MDnsTransactionImpl::OnCachePurged() {
754 // TODO(noamsml): Cache purge situations not yet implemented 753 // TODO(noamsml): Cache purge situations not yet implemented
755 } 754 }
756 755
757 } // namespace net 756 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/mdns_client.cc ('k') | net/dns/mock_mdns_socket_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698