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

Unified Diff: net/test/embedded_test_server/embedded_test_server.cc

Issue 2341393002: Remove stl_util's STLDeleteContainerPairSecondPointers from net/. (Closed)
Patch Set: fix Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/test/embedded_test_server/embedded_test_server.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/embedded_test_server/embedded_test_server.cc
diff --git a/net/test/embedded_test_server/embedded_test_server.cc b/net/test/embedded_test_server/embedded_test_server.cc
index 83f15f36357f460eaa549b4b667fc95345e15266..d9aeeeefd663c73440ecac096700ba30283163de 100644
--- a/net/test/embedded_test_server/embedded_test_server.cc
+++ b/net/test/embedded_test_server/embedded_test_server.cc
@@ -11,11 +11,11 @@
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/process/process_metrics.h"
#include "base/run_loop.h"
-#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_restrictions.h"
@@ -170,8 +170,6 @@ void EmbeddedTestServer::ShutdownOnIOThread() {
DCHECK(io_thread_->task_runner()->BelongsToCurrentThread());
weak_factory_.InvalidateWeakPtrs();
listen_socket_.reset();
- base::STLDeleteContainerPairSecondPointers(connections_.begin(),
- connections_.end());
connections_.clear();
}
@@ -343,8 +341,6 @@ bool EmbeddedTestServer::FlushAllSocketsAndConnectionsOnUIThread() {
}
void EmbeddedTestServer::FlushAllSocketsAndConnections() {
- base::STLDeleteContainerPairSecondPointers(connections_.begin(),
- connections_.end());
connections_.clear();
}
@@ -370,10 +366,12 @@ void EmbeddedTestServer::HandleAcceptResult(
if (is_using_ssl_)
socket = DoSSLUpgrade(std::move(socket));
- HttpConnection* http_connection = new HttpConnection(
- std::move(socket),
- base::Bind(&EmbeddedTestServer::HandleRequest, base::Unretained(this)));
- connections_[http_connection->socket_.get()] = http_connection;
+ std::unique_ptr<HttpConnection> http_connection_ptr =
+ base::MakeUnique<HttpConnection>(
+ std::move(socket), base::Bind(&EmbeddedTestServer::HandleRequest,
+ base::Unretained(this)));
+ HttpConnection* http_connection = http_connection_ptr.get();
+ connections_[http_connection->socket_.get()] = std::move(http_connection_ptr);
if (is_using_ssl_) {
SSLServerSocket* ssl_socket =
@@ -429,18 +427,16 @@ void EmbeddedTestServer::DidClose(HttpConnection* connection) {
DCHECK_EQ(1u, connections_.count(connection->socket_.get()));
connections_.erase(connection->socket_.get());
- delete connection;
}
HttpConnection* EmbeddedTestServer::FindConnection(StreamSocket* socket) {
DCHECK(io_thread_->task_runner()->BelongsToCurrentThread());
- std::map<StreamSocket*, HttpConnection*>::iterator it =
- connections_.find(socket);
+ auto it = connections_.find(socket);
if (it == connections_.end()) {
- return NULL;
+ return nullptr;
}
- return it->second;
+ return it->second.get();
}
bool EmbeddedTestServer::PostTaskToIOThreadAndWait(
« no previous file with comments | « net/test/embedded_test_server/embedded_test_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698