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

Unified Diff: chrome/utility/local_discovery/service_discovery_message_handler.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/local_discovery/service_discovery_client_mdns.cc ('k') | net/dns/mdns_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/utility/local_discovery/service_discovery_message_handler.cc
diff --git a/chrome/utility/local_discovery/service_discovery_message_handler.cc b/chrome/utility/local_discovery/service_discovery_message_handler.cc
index 681e18bb824531c4610bf7ba32b3a2fca4e09b7f..957d6190e2ded1d9ed1b4b36deacb952b23003cd 100644
--- a/chrome/utility/local_discovery/service_discovery_message_handler.cc
+++ b/chrome/utility/local_discovery/service_discovery_message_handler.cc
@@ -5,9 +5,11 @@
#include "chrome/utility/local_discovery/service_discovery_message_handler.h"
#include <algorithm>
+#include <vector>
#include "base/lazy_instance.h"
#include "base/location.h"
+#include "base/memory/scoped_ptr.h"
#include "base/single_thread_task_runner.h"
#include "chrome/common/local_discovery/local_discovery_messages.h"
#include "chrome/common/local_discovery/service_discovery_client_impl.h"
@@ -72,12 +74,15 @@ class PreCreatedMDnsSocketFactory : public net::MDnsSocketFactory {
~PreCreatedMDnsSocketFactory() override {
// Not empty if process exits too fast, before starting mDns code. If
// happened, destructors may crash accessing destroyed global objects.
- sockets_.weak_clear();
+ // TODO This sounds memory leak, check and do better if possible
+ for (scoped_ptr<net::DatagramServerSocket>& it : sockets_)
+ base::IgnoreResult(it.release());
+ sockets_.clear();
}
// net::MDnsSocketFactory implementation:
void CreateSockets(
- ScopedVector<net::DatagramServerSocket>* sockets) override {
+ std::vector<scoped_ptr<net::DatagramServerSocket>>* sockets) override {
sockets->swap(sockets_);
Reset();
}
@@ -90,7 +95,7 @@ class PreCreatedMDnsSocketFactory : public net::MDnsSocketFactory {
socket_info.interface_index));
if (socket) {
socket->DetachFromThread();
- sockets_.push_back(socket.release());
+ sockets_.push_back(std::move(socket));
}
}
@@ -99,7 +104,7 @@ class PreCreatedMDnsSocketFactory : public net::MDnsSocketFactory {
}
private:
- ScopedVector<net::DatagramServerSocket> sockets_;
+ std::vector<scoped_ptr<net::DatagramServerSocket>> sockets_;
DISALLOW_COPY_AND_ASSIGN(PreCreatedMDnsSocketFactory);
};
« no previous file with comments | « chrome/browser/local_discovery/service_discovery_client_mdns.cc ('k') | net/dns/mdns_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698