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

Side by Side Diff: chrome/browser/local_discovery/service_discovery_client_mdns.cc

Issue 1475553002: Remove ScopedVector from CreateSockets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove {} 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 | « no previous file | chrome/utility/local_discovery/service_discovery_message_handler.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/local_discovery/service_discovery_client_mdns.h" 5 #include "chrome/browser/local_discovery/service_discovery_client_mdns.h"
6 6
7 #include <vector>
8
7 #include "base/location.h" 9 #include "base/location.h"
8 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
10 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
12 #include "chrome/common/local_discovery/service_discovery_client_impl.h" 14 #include "chrome/common/local_discovery/service_discovery_client_impl.h"
13 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
14 #include "net/dns/mdns_client.h" 16 #include "net/dns/mdns_client.h"
15 #include "net/udp/datagram_server_socket.h" 17 #include "net/udp/datagram_server_socket.h"
16 18
17 namespace local_discovery { 19 namespace local_discovery {
18 20
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 110
109 typedef base::Callback<void(bool)> MdnsInitCallback; 111 typedef base::Callback<void(bool)> MdnsInitCallback;
110 112
111 class SocketFactory : public net::MDnsSocketFactory { 113 class SocketFactory : public net::MDnsSocketFactory {
112 public: 114 public:
113 explicit SocketFactory(const net::InterfaceIndexFamilyList& interfaces) 115 explicit SocketFactory(const net::InterfaceIndexFamilyList& interfaces)
114 : interfaces_(interfaces) {} 116 : interfaces_(interfaces) {}
115 117
116 // net::MDnsSocketFactory implementation: 118 // net::MDnsSocketFactory implementation:
117 void CreateSockets( 119 void CreateSockets(
118 ScopedVector<net::DatagramServerSocket>* sockets) override { 120 std::vector<scoped_ptr<net::DatagramServerSocket>>* sockets) override {
119 for (size_t i = 0; i < interfaces_.size(); ++i) { 121 for (size_t i = 0; i < interfaces_.size(); ++i) {
120 DCHECK(interfaces_[i].second == net::ADDRESS_FAMILY_IPV4 || 122 DCHECK(interfaces_[i].second == net::ADDRESS_FAMILY_IPV4 ||
121 interfaces_[i].second == net::ADDRESS_FAMILY_IPV6); 123 interfaces_[i].second == net::ADDRESS_FAMILY_IPV6);
122 scoped_ptr<net::DatagramServerSocket> socket( 124 scoped_ptr<net::DatagramServerSocket> socket(
123 CreateAndBindMDnsSocket(interfaces_[i].second, interfaces_[i].first)); 125 CreateAndBindMDnsSocket(interfaces_[i].second, interfaces_[i].first));
124 if (socket) 126 if (socket)
125 sockets->push_back(socket.release()); 127 sockets->push_back(std::move(socket));
126 } 128 }
127 } 129 }
128 130
129 private: 131 private:
130 net::InterfaceIndexFamilyList interfaces_; 132 net::InterfaceIndexFamilyList interfaces_;
131 }; 133 };
132 134
133 void InitMdns(const MdnsInitCallback& on_initialized, 135 void InitMdns(const MdnsInitCallback& on_initialized,
134 const net::InterfaceIndexFamilyList& interfaces, 136 const net::InterfaceIndexFamilyList& interfaces,
135 net::MDnsClient* mdns) { 137 net::MDnsClient* mdns) {
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 OnBeforeMdnsDestroy(); 436 OnBeforeMdnsDestroy();
435 // After calling |Proxy::OnMdnsDestroy| all references to client_ and mdns_ 437 // After calling |Proxy::OnMdnsDestroy| all references to client_ and mdns_
436 // should be destroyed. 438 // should be destroyed.
437 if (client_) 439 if (client_)
438 mdns_runner_->DeleteSoon(FROM_HERE, client_.release()); 440 mdns_runner_->DeleteSoon(FROM_HERE, client_.release());
439 if (mdns_) 441 if (mdns_)
440 mdns_runner_->DeleteSoon(FROM_HERE, mdns_.release()); 442 mdns_runner_->DeleteSoon(FROM_HERE, mdns_.release());
441 } 443 }
442 444
443 } // namespace local_discovery 445 } // namespace local_discovery
OLDNEW
« no previous file with comments | « no previous file | chrome/utility/local_discovery/service_discovery_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698