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

Unified Diff: chrome/utility/local_discovery/service_discovery_message_handler.cc

Issue 185293014: Bind before sandbox lockdown on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | « no previous file | content/browser/renderer_host/p2p/socket_host_udp_unittest.cc » ('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 3a73ad72bcf8d1c90795474b38ad1882040824bf..eb0572d1722a90b45135d8f8c56086e763437752 100644
--- a/chrome/utility/local_discovery/service_discovery_message_handler.cc
+++ b/chrome/utility/local_discovery/service_discovery_message_handler.cc
@@ -66,38 +66,36 @@ class PreCreatedMDnsSocketFactory : public net::MDnsSocketFactory {
public:
PreCreatedMDnsSocketFactory() {}
virtual ~PreCreatedMDnsSocketFactory() {
- Reset();
+ // Not empty if process exits too fast, before starting mDns code. If
+ // happened, destructors may crash accessing destroyed global objects.
+ sockets_.weak_clear();
}
// net::MDnsSocketFactory implementation:
virtual void CreateSockets(
ScopedVector<net::DatagramServerSocket>* sockets) OVERRIDE {
- for (size_t i = 0; i < sockets_.size(); ++i) {
- // Takes ownership of sockets_[i].socket;
- ScopedSocketFactory platform_factory(sockets_[i].socket);
- scoped_ptr<net::DatagramServerSocket> socket(
- net::CreateAndBindMDnsSocket(sockets_[i].address_family,
- sockets_[i].interface_index));
- if (socket)
- sockets->push_back(socket.release());
- }
- sockets_.clear();
+ sockets->swap(sockets_);
+ Reset();
}
- void AddSocket(const SocketInfo& socket) {
- sockets_.push_back(socket);
+ void AddSocket(const SocketInfo& socket_info) {
+ // Takes ownership of socket_info.socket;
+ ScopedSocketFactory platform_factory(socket_info.socket);
+ scoped_ptr<net::DatagramServerSocket> socket(
+ net::CreateAndBindMDnsSocket(socket_info.address_family,
+ socket_info.interface_index));
+ if (socket) {
+ socket->DetachFromThread();
+ sockets_.push_back(socket.release());
+ }
}
void Reset() {
- for (size_t i = 0; i < sockets_.size(); ++i) {
- if (sockets_[i].socket != net::kInvalidSocket)
- ClosePlatformSocket(sockets_[i].socket);
- }
sockets_.clear();
}
private:
- std::vector<SocketInfo> sockets_;
+ ScopedVector<net::DatagramServerSocket> sockets_;
DISALLOW_COPY_AND_ASSIGN(PreCreatedMDnsSocketFactory);
};
« no previous file with comments | « no previous file | content/browser/renderer_host/p2p/socket_host_udp_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698