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

Unified Diff: net/dns/dns_socket_pool.cc

Issue 2389613002: Remove stl_util's deletion functions from net/dns/. (Closed)
Patch Set: fix Created 4 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 side-by-side diff with in-line comments
Download patch
Index: net/dns/dns_socket_pool.cc
diff --git a/net/dns/dns_socket_pool.cc b/net/dns/dns_socket_pool.cc
index 0ad53ff022bd69503868a9981a30338605eb9d29..6eed753a20dd6fed0f986df64f3b31c35966ac59 100644
--- a/net/dns/dns_socket_pool.cc
+++ b/net/dns/dns_socket_pool.cc
@@ -6,8 +6,8 @@
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/rand_util.h"
-#include "base/stl_util.h"
#include "net/base/address_list.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
@@ -146,7 +146,7 @@ class DefaultDnsSocketPool : public DnsSocketPool {
private:
void FillPool(unsigned server_index, unsigned size);
- typedef std::vector<DatagramClientSocket*> SocketVector;
+ typedef std::vector<std::unique_ptr<DatagramClientSocket>> SocketVector;
std::vector<SocketVector> pools_;
@@ -174,11 +174,6 @@ void DefaultDnsSocketPool::Initialize(
}
DefaultDnsSocketPool::~DefaultDnsSocketPool() {
- unsigned num_servers = pools_.size();
- for (unsigned server_index = 0; server_index < num_servers; ++server_index) {
- SocketVector& pool = pools_[server_index];
- base::STLDeleteElements(&pool);
- }
}
std::unique_ptr<DatagramClientSocket> DefaultDnsSocketPool::AllocateSocket(
@@ -199,11 +194,11 @@ std::unique_ptr<DatagramClientSocket> DefaultDnsSocketPool::AllocateSocket(
}
unsigned socket_index = GetRandomInt(0, pool.size() - 1);
- DatagramClientSocket* socket = pool[socket_index];
- pool[socket_index] = pool.back();
+ std::unique_ptr<DatagramClientSocket> socket = std::move(pool[socket_index]);
+ pool[socket_index] = std::move(pool.back());
pool.pop_back();
- return std::unique_ptr<DatagramClientSocket>(socket);
+ return socket;
}
void DefaultDnsSocketPool::FreeSocket(
@@ -216,11 +211,11 @@ void DefaultDnsSocketPool::FillPool(unsigned server_index, unsigned size) {
SocketVector& pool = pools_[server_index];
for (unsigned pool_index = pool.size(); pool_index < size; ++pool_index) {
- DatagramClientSocket* socket =
- CreateConnectedSocket(server_index).release();
+ std::unique_ptr<DatagramClientSocket> socket =
+ CreateConnectedSocket(server_index);
if (!socket)
break;
- pool.push_back(socket);
+ pool.push_back(std::move(socket));
}
}

Powered by Google App Engine
This is Rietveld 408576698