Commit 3f5f2a4a authored by Matt Menke's avatar Matt Menke Committed by Commit Bot

Remove use of NetLog by ServiceDiscoveryClientMdns().

The browser process NetLog doesn't work when the network service is
enabled, which is now the default state. This is needed to remove the
useless in-process NetLog from Chrome.

ServiceDiscoveryClientMdns() should presumably be modified to use the
network service to create UDP sockets for it, at some point, which will
make it start using the functional NetLog in the network service,
conveniently.

Bug: 767450
Change-Id: Id101f8046062cb9b9d823aaa89c8c4372eb07258
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1612094Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660061}
parent 2216ff67
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/local_discovery/service_discovery_client_impl.h" #include "chrome/browser/local_discovery/service_discovery_client_impl.h"
#include "components/net_log/chrome_net_log.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/network_service_instance.h" #include "content/public/browser/network_service_instance.h"
...@@ -127,9 +126,8 @@ using MdnsInitCallback = base::Callback<void(int)>; ...@@ -127,9 +126,8 @@ using MdnsInitCallback = base::Callback<void(int)>;
class SocketFactory : public net::MDnsSocketFactory { class SocketFactory : public net::MDnsSocketFactory {
public: public:
SocketFactory(const net::InterfaceIndexFamilyList& interfaces, explicit SocketFactory(const net::InterfaceIndexFamilyList& interfaces)
net::NetLog* net_log) : interfaces_(interfaces) {}
: interfaces_(interfaces), net_log_(net_log) {}
// net::MDnsSocketFactory implementation: // net::MDnsSocketFactory implementation:
void CreateSockets(std::vector<std::unique_ptr<net::DatagramServerSocket>>* void CreateSockets(std::vector<std::unique_ptr<net::DatagramServerSocket>>*
...@@ -138,7 +136,7 @@ class SocketFactory : public net::MDnsSocketFactory { ...@@ -138,7 +136,7 @@ class SocketFactory : public net::MDnsSocketFactory {
DCHECK(interfaces_[i].second == net::ADDRESS_FAMILY_IPV4 || DCHECK(interfaces_[i].second == net::ADDRESS_FAMILY_IPV4 ||
interfaces_[i].second == net::ADDRESS_FAMILY_IPV6); interfaces_[i].second == net::ADDRESS_FAMILY_IPV6);
std::unique_ptr<net::DatagramServerSocket> socket(CreateAndBindMDnsSocket( std::unique_ptr<net::DatagramServerSocket> socket(CreateAndBindMDnsSocket(
interfaces_[i].second, interfaces_[i].first, net_log_)); interfaces_[i].second, interfaces_[i].first, nullptr /* net_log */));
if (socket) if (socket)
sockets->push_back(std::move(socket)); sockets->push_back(std::move(socket));
} }
...@@ -147,15 +145,13 @@ class SocketFactory : public net::MDnsSocketFactory { ...@@ -147,15 +145,13 @@ class SocketFactory : public net::MDnsSocketFactory {
private: private:
net::InterfaceIndexFamilyList interfaces_; net::InterfaceIndexFamilyList interfaces_;
// Owned by |g_browser_process|. DISALLOW_COPY_AND_ASSIGN(SocketFactory);
net::NetLog* const net_log_;
}; };
void InitMdns(const MdnsInitCallback& on_initialized, void InitMdns(const MdnsInitCallback& on_initialized,
const net::InterfaceIndexFamilyList& interfaces, const net::InterfaceIndexFamilyList& interfaces,
net::MDnsClient* mdns, net::MDnsClient* mdns) {
net::NetLog* net_log) { SocketFactory socket_factory(interfaces);
SocketFactory socket_factory(interfaces, net_log);
base::PostTaskWithTraits( base::PostTaskWithTraits(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::BindOnce(on_initialized, mdns->StartListening(&socket_factory))); base::BindOnce(on_initialized, mdns->StartListening(&socket_factory)));
...@@ -425,8 +421,7 @@ void ServiceDiscoveryClientMdns::OnInterfaceListReady( ...@@ -425,8 +421,7 @@ void ServiceDiscoveryClientMdns::OnInterfaceListReady(
base::BindOnce(&InitMdns, base::BindOnce(&InitMdns,
base::Bind(&ServiceDiscoveryClientMdns::OnMdnsInitialized, base::Bind(&ServiceDiscoveryClientMdns::OnMdnsInitialized,
weak_ptr_factory_.GetWeakPtr()), weak_ptr_factory_.GetWeakPtr()),
interfaces, base::Unretained(mdns_.get()), interfaces, base::Unretained(mdns_.get())));
g_browser_process->net_log()));
} }
void ServiceDiscoveryClientMdns::OnMdnsInitialized(int net_error) { void ServiceDiscoveryClientMdns::OnMdnsInitialized(int net_error) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment