summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvitalybuka <vitalybuka@chromium.org>2016-01-06 19:21:45 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-07 03:22:36 +0000
commit2ecd7818d1b1bf26ca9c0c8ae4dd44007abb9ef9 (patch)
tree4607c5519d1956727e814700dd37bb48eaad9535
parent2a41135331b37b94b15df5af641421cf407b2d11 (diff)
downloadchromium_src-2ecd7818d1b1bf26ca9c0c8ae4dd44007abb9ef9.zip
chromium_src-2ecd7818d1b1bf26ca9c0c8ae4dd44007abb9ef9.tar.gz
chromium_src-2ecd7818d1b1bf26ca9c0c8ae4dd44007abb9ef9.tar.bz2
Remove unused code
This code is not used for a while after it was decided that secure sandbox with network access is not possible on Windows. BUG=349645 Review URL: https://codereview.chromium.org/1568573002 Cr-Commit-Position: refs/heads/master@{#368002}
-rw-r--r--chrome/browser/local_discovery/service_discovery_client_utility.cc109
-rw-r--r--chrome/browser/local_discovery/service_discovery_client_utility.h61
-rw-r--r--chrome/browser/local_discovery/service_discovery_host_client.cc461
-rw-r--r--chrome/browser/local_discovery/service_discovery_host_client.h150
-rw-r--r--chrome/browser/local_discovery/service_discovery_shared_client.cc34
-rw-r--r--chrome/browser/local_discovery/service_discovery_shared_client.h1
-rw-r--r--chrome/chrome_browser.gypi4
-rw-r--r--chrome/chrome_common.gypi5
-rw-r--r--chrome/chrome_utility.gypi8
-rw-r--r--chrome/common/BUILD.gn4
-rw-r--r--chrome/common/common_message_generator.h4
-rw-r--r--chrome/common/local_discovery/local_discovery_messages.h139
-rw-r--r--chrome/utility/BUILD.gn7
-rw-r--r--chrome/utility/chrome_content_utility_client.cc18
-rw-r--r--chrome/utility/local_discovery/OWNERS3
-rw-r--r--chrome/utility/local_discovery/service_discovery_message_handler.cc489
-rw-r--r--chrome/utility/local_discovery/service_discovery_message_handler.h123
-rw-r--r--content/browser/utility_process_host_impl.cc8
-rw-r--r--content/browser/utility_process_host_impl.h5
-rw-r--r--content/public/browser/utility_process_host.h3
-rw-r--r--content/public/common/content_switches.cc3
-rw-r--r--content/public/common/content_switches.h1
-rw-r--r--ipc/ipc_message_start.h1
-rw-r--r--net/socket/socket_descriptor.cc20
-rw-r--r--net/socket/socket_descriptor.h17
25 files changed, 1 insertions, 1677 deletions
diff --git a/chrome/browser/local_discovery/service_discovery_client_utility.cc b/chrome/browser/local_discovery/service_discovery_client_utility.cc
deleted file mode 100644
index 4b9242a..0000000
--- a/chrome/browser/local_discovery/service_discovery_client_utility.cc
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/local_discovery/service_discovery_client_utility.h"
-
-#include "base/location.h"
-#include "base/metrics/histogram.h"
-#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
-#include "chrome/browser/local_discovery/service_discovery_host_client.h"
-#include "content/public/browser/browser_thread.h"
-
-namespace local_discovery {
-
-using content::BrowserThread;
-
-namespace {
-const int kMaxRestartAttempts = 10;
-const int kRestartDelayOnNetworkChangeSeconds = 3;
-const int kReportSuccessAfterSeconds = 10;
-}
-
-scoped_ptr<ServiceWatcher> ServiceDiscoveryClientUtility::CreateServiceWatcher(
- const std::string& service_type,
- const ServiceWatcher::UpdatedCallback& callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- return host_client_->CreateServiceWatcher(service_type, callback);
-}
-
-scoped_ptr<ServiceResolver>
-ServiceDiscoveryClientUtility::CreateServiceResolver(
- const std::string& service_name,
- const ServiceResolver::ResolveCompleteCallback& callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- return host_client_->CreateServiceResolver(service_name, callback);
-}
-
-scoped_ptr<LocalDomainResolver>
-ServiceDiscoveryClientUtility::CreateLocalDomainResolver(
- const std::string& domain,
- net::AddressFamily address_family,
- const LocalDomainResolver::IPAddressCallback& callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- return host_client_->CreateLocalDomainResolver(domain, address_family,
- callback);
-}
-
-ServiceDiscoveryClientUtility::ServiceDiscoveryClientUtility()
- : restart_attempts_(kMaxRestartAttempts),
- weak_ptr_factory_(this) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
- StartNewClient();
-}
-
-ServiceDiscoveryClientUtility::~ServiceDiscoveryClientUtility() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
- host_client_->Shutdown();
-}
-
-void ServiceDiscoveryClientUtility::OnNetworkChanged(
- net::NetworkChangeNotifier::ConnectionType type) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- // Only network changes resets kMaxRestartAttempts.
- restart_attempts_ = kMaxRestartAttempts;
- ScheduleStartNewClient();
-}
-
-void ServiceDiscoveryClientUtility::ScheduleStartNewClient() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- host_client_->Shutdown();
- weak_ptr_factory_.InvalidateWeakPtrs();
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, base::Bind(&ServiceDiscoveryClientUtility::StartNewClient,
- weak_ptr_factory_.GetWeakPtr()),
- base::TimeDelta::FromSeconds(kRestartDelayOnNetworkChangeSeconds));
-}
-
-void ServiceDiscoveryClientUtility::StartNewClient() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- scoped_refptr<ServiceDiscoveryHostClient> old_client = host_client_;
- if ((restart_attempts_--) > 0) {
- host_client_ = new ServiceDiscoveryHostClient();
- host_client_->Start(
- base::Bind(&ServiceDiscoveryClientUtility::ScheduleStartNewClient,
- weak_ptr_factory_.GetWeakPtr()));
-
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, base::Bind(&ServiceDiscoveryClientUtility::ReportSuccess,
- weak_ptr_factory_.GetWeakPtr()),
- base::TimeDelta::FromSeconds(kReportSuccessAfterSeconds));
- } else {
- restart_attempts_ = -1;
- ReportSuccess();
- }
- // Run when host_client_ is created. Callbacks created by InvalidateWatchers
- // may create new watchers.
- if (old_client.get())
- old_client->InvalidateWatchers();
-}
-
-void ServiceDiscoveryClientUtility::ReportSuccess() {
- UMA_HISTOGRAM_COUNTS_100("LocalDiscovery.ClientRestartAttempts",
- kMaxRestartAttempts - restart_attempts_);
-}
-
-} // namespace local_discovery
diff --git a/chrome/browser/local_discovery/service_discovery_client_utility.h b/chrome/browser/local_discovery/service_discovery_client_utility.h
deleted file mode 100644
index 3df9dfe..0000000
--- a/chrome/browser/local_discovery/service_discovery_client_utility.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_CLIENT_UTILITY_H_
-#define CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_CLIENT_UTILITY_H_
-
-#include <string>
-
-#include "base/cancelable_callback.h"
-#include "base/macros.h"
-#include "chrome/browser/local_discovery/service_discovery_shared_client.h"
-#include "chrome/common/local_discovery/service_discovery_client.h"
-#include "net/base/network_change_notifier.h"
-
-namespace local_discovery {
-
-class ServiceDiscoveryHostClient;
-
-// Wrapper for ServiceDiscoveryHostClient to hide restarting of utility process
-// from mdns users.
-class ServiceDiscoveryClientUtility
- : public ServiceDiscoverySharedClient,
- public net::NetworkChangeNotifier::NetworkChangeObserver {
- public:
- ServiceDiscoveryClientUtility();
-
- // ServiceDiscoveryClient implementation.
- scoped_ptr<ServiceWatcher> CreateServiceWatcher(
- const std::string& service_type,
- const ServiceWatcher::UpdatedCallback& callback) override;
- scoped_ptr<ServiceResolver> CreateServiceResolver(
- const std::string& service_name,
- const ServiceResolver::ResolveCompleteCallback& callback) override;
- scoped_ptr<LocalDomainResolver> CreateLocalDomainResolver(
- const std::string& domain,
- net::AddressFamily address_family,
- const LocalDomainResolver::IPAddressCallback& callback) override;
-
- // net::NetworkChangeNotifier::NetworkChangeObserver implementation.
- void OnNetworkChanged(
- net::NetworkChangeNotifier::ConnectionType type) override;
-
- private:
- friend class base::RefCounted<ServiceDiscoveryClientUtility>;
-
- ~ServiceDiscoveryClientUtility() override;
- void ScheduleStartNewClient();
- void StartNewClient();
- void ReportSuccess();
-
- scoped_refptr<ServiceDiscoveryHostClient> host_client_;
- int restart_attempts_;
- base::WeakPtrFactory<ServiceDiscoveryClientUtility> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(ServiceDiscoveryClientUtility);
-};
-
-} // namespace local_discovery
-
-#endif // CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_CLIENT_UTILITY_H_
diff --git a/chrome/browser/local_discovery/service_discovery_host_client.cc b/chrome/browser/local_discovery/service_discovery_host_client.cc
deleted file mode 100644
index 2d5603a..0000000
--- a/chrome/browser/local_discovery/service_discovery_host_client.cc
+++ /dev/null
@@ -1,461 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/local_discovery/service_discovery_host_client.h"
-
-#include <stddef.h>
-
-#include "base/location.h"
-#include "base/single_thread_task_runner.h"
-#include "base/thread_task_runner_handle.h"
-#include "build/build_config.h"
-#include "chrome/common/local_discovery/local_discovery_messages.h"
-#include "chrome/grit/generated_resources.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/utility_process_host.h"
-#include "net/base/net_util.h"
-#include "net/dns/mdns_client.h"
-#include "net/socket/socket_descriptor.h"
-#include "ui/base/l10n/l10n_util.h"
-
-#if defined(OS_POSIX)
-#include <netinet/in.h>
-#include "base/file_descriptor_posix.h"
-#endif // OS_POSIX
-
-namespace local_discovery {
-
-using content::BrowserThread;
-using content::UtilityProcessHost;
-
-namespace {
-
-#if defined(OS_POSIX)
-SocketInfoList GetSocketsOnFileThread() {
- net::InterfaceIndexFamilyList interfaces(net::GetMDnsInterfacesToBind());
- SocketInfoList sockets;
- for (size_t i = 0; i < interfaces.size(); ++i) {
- DCHECK(interfaces[i].second == net::ADDRESS_FAMILY_IPV4 ||
- interfaces[i].second == net::ADDRESS_FAMILY_IPV6);
- base::FileDescriptor socket_descriptor(
- net::CreatePlatformSocket(
- net::ConvertAddressFamily(interfaces[i].second), SOCK_DGRAM,
- IPPROTO_UDP),
- true);
- LOG_IF(ERROR, socket_descriptor.fd == net::kInvalidSocket)
- << "Can't create socket, family=" << interfaces[i].second;
- if (socket_descriptor.fd != net::kInvalidSocket) {
- LocalDiscoveryMsg_SocketInfo socket;
- socket.descriptor = socket_descriptor;
- socket.interface_index = interfaces[i].first;
- socket.address_family = interfaces[i].second;
- sockets.push_back(socket);
- }
- }
-
- return sockets;
-}
-#endif // OS_POSIX
-
-} // namespace
-
-class ServiceDiscoveryHostClient::ServiceWatcherProxy : public ServiceWatcher {
- public:
- ServiceWatcherProxy(ServiceDiscoveryHostClient* host,
- const std::string& service_type,
- const ServiceWatcher::UpdatedCallback& callback)
- : host_(host),
- service_type_(service_type),
- id_(host_->RegisterWatcherCallback(callback)),
- started_(false) {
- }
-
- ~ServiceWatcherProxy() override {
- DVLOG(1) << "~ServiceWatcherProxy with id " << id_;
- host_->UnregisterWatcherCallback(id_);
- if (started_)
- host_->Send(new LocalDiscoveryMsg_DestroyWatcher(id_));
- }
-
- void Start() override {
- DVLOG(1) << "ServiceWatcher::Start with id " << id_;
- DCHECK(!started_);
- host_->Send(new LocalDiscoveryMsg_StartWatcher(id_, service_type_));
- started_ = true;
- }
-
- void DiscoverNewServices(bool force_update) override {
- DVLOG(1) << "ServiceWatcher::DiscoverNewServices with id " << id_;
- DCHECK(started_);
- host_->Send(new LocalDiscoveryMsg_DiscoverServices(id_, force_update));
- }
-
- void SetActivelyRefreshServices(bool actively_refresh_services) override {
- DVLOG(1) << "ServiceWatcher::SetActivelyRefreshServices with id " << id_;
- DCHECK(started_);
- host_->Send(new LocalDiscoveryMsg_SetActivelyRefreshServices(
- id_, actively_refresh_services));
- }
-
- std::string GetServiceType() const override { return service_type_; }
-
- private:
- scoped_refptr<ServiceDiscoveryHostClient> host_;
- const std::string service_type_;
- const uint64_t id_;
- bool started_;
-};
-
-class ServiceDiscoveryHostClient::ServiceResolverProxy
- : public ServiceResolver {
- public:
- ServiceResolverProxy(ServiceDiscoveryHostClient* host,
- const std::string& service_name,
- const ServiceResolver::ResolveCompleteCallback& callback)
- : host_(host),
- service_name_(service_name),
- id_(host->RegisterResolverCallback(callback)),
- started_(false) {
- }
-
- ~ServiceResolverProxy() override {
- DVLOG(1) << "~ServiceResolverProxy with id " << id_;
- host_->UnregisterResolverCallback(id_);
- if (started_)
- host_->Send(new LocalDiscoveryMsg_DestroyResolver(id_));
- }
-
- void StartResolving() override {
- DVLOG(1) << "ServiceResolverProxy::StartResolving with id " << id_;
- DCHECK(!started_);
- host_->Send(new LocalDiscoveryMsg_ResolveService(id_, service_name_));
- started_ = true;
- }
-
- std::string GetName() const override { return service_name_; }
-
- private:
- scoped_refptr<ServiceDiscoveryHostClient> host_;
- const std::string service_name_;
- const uint64_t id_;
- bool started_;
-};
-
-class ServiceDiscoveryHostClient::LocalDomainResolverProxy
- : public LocalDomainResolver {
- public:
- LocalDomainResolverProxy(ServiceDiscoveryHostClient* host,
- const std::string& domain,
- net::AddressFamily address_family,
- const LocalDomainResolver::IPAddressCallback& callback)
- : host_(host),
- domain_(domain),
- address_family_(address_family),
- id_(host->RegisterLocalDomainResolverCallback(callback)),
- started_(false) {
- }
-
- ~LocalDomainResolverProxy() override {
- DVLOG(1) << "~LocalDomainResolverProxy with id " << id_;
- host_->UnregisterLocalDomainResolverCallback(id_);
- if (started_)
- host_->Send(new LocalDiscoveryMsg_DestroyLocalDomainResolver(id_));
- }
-
- void Start() override {
- DVLOG(1) << "LocalDomainResolverProxy::Start with id " << id_;
- DCHECK(!started_);
- host_->Send(new LocalDiscoveryMsg_ResolveLocalDomain(id_, domain_,
- address_family_));
- started_ = true;
- }
-
- private:
- scoped_refptr<ServiceDiscoveryHostClient> host_;
- std::string domain_;
- net::AddressFamily address_family_;
- const uint64_t id_;
- bool started_;
-};
-
-ServiceDiscoveryHostClient::ServiceDiscoveryHostClient() : current_id_(0) {
- callback_runner_ = base::MessageLoop::current()->task_runner();
- io_runner_ = BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
-}
-
-ServiceDiscoveryHostClient::~ServiceDiscoveryHostClient() {
- DCHECK(service_watcher_callbacks_.empty());
- DCHECK(service_resolver_callbacks_.empty());
- DCHECK(domain_resolver_callbacks_.empty());
-}
-
-scoped_ptr<ServiceWatcher> ServiceDiscoveryHostClient::CreateServiceWatcher(
- const std::string& service_type,
- const ServiceWatcher::UpdatedCallback& callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- return scoped_ptr<ServiceWatcher>(
- new ServiceWatcherProxy(this, service_type, callback));
-}
-
-scoped_ptr<ServiceResolver> ServiceDiscoveryHostClient::CreateServiceResolver(
- const std::string& service_name,
- const ServiceResolver::ResolveCompleteCallback& callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- return scoped_ptr<ServiceResolver>(
- new ServiceResolverProxy(this, service_name, callback));
-}
-
-scoped_ptr<LocalDomainResolver>
-ServiceDiscoveryHostClient::CreateLocalDomainResolver(
- const std::string& domain,
- net::AddressFamily address_family,
- const LocalDomainResolver::IPAddressCallback& callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- return scoped_ptr<LocalDomainResolver>(new LocalDomainResolverProxy(
- this, domain, address_family, callback));
-}
-
-uint64_t ServiceDiscoveryHostClient::RegisterWatcherCallback(
- const ServiceWatcher::UpdatedCallback& callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK(!ContainsKey(service_watcher_callbacks_, current_id_ + 1));
- service_watcher_callbacks_[++current_id_] = callback;
- return current_id_;
-}
-
-uint64_t ServiceDiscoveryHostClient::RegisterResolverCallback(
- const ServiceResolver::ResolveCompleteCallback& callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK(!ContainsKey(service_resolver_callbacks_, current_id_ + 1));
- service_resolver_callbacks_[++current_id_] = callback;
- return current_id_;
-}
-
-uint64_t ServiceDiscoveryHostClient::RegisterLocalDomainResolverCallback(
- const LocalDomainResolver::IPAddressCallback& callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK(!ContainsKey(domain_resolver_callbacks_, current_id_ + 1));
- domain_resolver_callbacks_[++current_id_] = callback;
- return current_id_;
-}
-
-void ServiceDiscoveryHostClient::UnregisterWatcherCallback(uint64_t id) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- service_watcher_callbacks_.erase(id);
-}
-
-void ServiceDiscoveryHostClient::UnregisterResolverCallback(uint64_t id) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- service_resolver_callbacks_.erase(id);
-}
-
-void ServiceDiscoveryHostClient::UnregisterLocalDomainResolverCallback(
- uint64_t id) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- domain_resolver_callbacks_.erase(id);
-}
-
-void ServiceDiscoveryHostClient::Start(
- const base::Closure& error_callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DCHECK(!utility_host_);
- DCHECK(error_callback_.is_null());
- error_callback_ = error_callback;
- io_runner_->PostTask(
- FROM_HERE,
- base::Bind(&ServiceDiscoveryHostClient::StartOnIOThread, this));
-}
-
-void ServiceDiscoveryHostClient::Shutdown() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- io_runner_->PostTask(
- FROM_HERE,
- base::Bind(&ServiceDiscoveryHostClient::ShutdownOnIOThread, this));
-}
-
-#if defined(OS_POSIX)
-
-void ServiceDiscoveryHostClient::StartOnIOThread() {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- DCHECK(!utility_host_);
- BrowserThread::PostTaskAndReplyWithResult(
- BrowserThread::FILE,
- FROM_HERE,
- base::Bind(&GetSocketsOnFileThread),
- base::Bind(&ServiceDiscoveryHostClient::OnSocketsReady, this));
-}
-
-void ServiceDiscoveryHostClient::OnSocketsReady(const SocketInfoList& sockets) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- DCHECK(!utility_host_);
- utility_host_ =
- UtilityProcessHost::Create(
- this, base::ThreadTaskRunnerHandle::Get().get())->AsWeakPtr();
- utility_host_->SetName(l10n_util::GetStringUTF16(
- IDS_UTILITY_PROCESS_SERVICE_DISCOVERY_HANDLER_NAME));
- utility_host_->EnableMDns();
- utility_host_->StartBatchMode();
- if (sockets.empty()) {
- ShutdownOnIOThread();
- return;
- }
- utility_host_->Send(new LocalDiscoveryMsg_SetSockets(sockets));
- // Send messages for requests made during network enumeration.
- for (size_t i = 0; i < delayed_messages_.size(); ++i)
- utility_host_->Send(delayed_messages_[i]);
- delayed_messages_.weak_clear();
-}
-
-#else // OS_POSIX
-
-void ServiceDiscoveryHostClient::StartOnIOThread() {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- DCHECK(!utility_host_);
- utility_host_ =
- UtilityProcessHost::Create(
- this, base::ThreadTaskRunnerHandle::Get().get())->AsWeakPtr();
- utility_host_->SetName(l10n_util::GetStringUTF16(
- IDS_UTILITY_PROCESS_SERVICE_DISCOVERY_HANDLER_NAME));
- utility_host_->EnableMDns();
- utility_host_->StartBatchMode();
- // Windows does not enumerate networks here.
- DCHECK(delayed_messages_.empty());
-}
-
-#endif // OS_POSIX
-
-void ServiceDiscoveryHostClient::ShutdownOnIOThread() {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (utility_host_) {
- utility_host_->Send(new LocalDiscoveryMsg_ShutdownLocalDiscovery);
- utility_host_->EndBatchMode();
- utility_host_.reset();
- }
- error_callback_ = base::Closure();
-}
-
-void ServiceDiscoveryHostClient::Send(IPC::Message* msg) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- io_runner_->PostTask(
- FROM_HERE,
- base::Bind(&ServiceDiscoveryHostClient::SendOnIOThread, this, msg));
-}
-
-void ServiceDiscoveryHostClient::SendOnIOThread(IPC::Message* msg) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (utility_host_) {
- utility_host_->Send(msg);
- } else {
- delayed_messages_.push_back(msg);
- }
-}
-
-void ServiceDiscoveryHostClient::OnProcessCrashed(int exit_code) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- DCHECK(!utility_host_);
- OnError();
-}
-
-bool ServiceDiscoveryHostClient::OnMessageReceived(
- const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(ServiceDiscoveryHostClient, message)
- IPC_MESSAGE_HANDLER(LocalDiscoveryHostMsg_Error, OnError)
- IPC_MESSAGE_HANDLER(LocalDiscoveryHostMsg_WatcherCallback,
- OnWatcherCallback)
- IPC_MESSAGE_HANDLER(LocalDiscoveryHostMsg_ResolverCallback,
- OnResolverCallback)
- IPC_MESSAGE_HANDLER(LocalDiscoveryHostMsg_LocalDomainResolverCallback,
- OnLocalDomainResolverCallback)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void ServiceDiscoveryHostClient::InvalidateWatchers() {
- WatcherCallbacks service_watcher_callbacks;
- service_watcher_callbacks_.swap(service_watcher_callbacks);
- service_resolver_callbacks_.clear();
- domain_resolver_callbacks_.clear();
-
- for (WatcherCallbacks::iterator i = service_watcher_callbacks.begin();
- i != service_watcher_callbacks.end(); i++) {
- if (!i->second.is_null()) {
- i->second.Run(ServiceWatcher::UPDATE_INVALIDATED, "");
- }
- }
-}
-
-void ServiceDiscoveryHostClient::OnError() {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (!error_callback_.is_null())
- callback_runner_->PostTask(FROM_HERE, error_callback_);
-}
-
-void ServiceDiscoveryHostClient::OnWatcherCallback(
- uint64_t id,
- ServiceWatcher::UpdateType update,
- const std::string& service_name) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- callback_runner_->PostTask(
- FROM_HERE,
- base::Bind(&ServiceDiscoveryHostClient::RunWatcherCallback, this, id,
- update, service_name));
-}
-
-void ServiceDiscoveryHostClient::OnResolverCallback(
- uint64_t id,
- ServiceResolver::RequestStatus status,
- const ServiceDescription& description) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- callback_runner_->PostTask(
- FROM_HERE,
- base::Bind(&ServiceDiscoveryHostClient::RunResolverCallback, this, id,
- status, description));
-}
-
-void ServiceDiscoveryHostClient::OnLocalDomainResolverCallback(
- uint64_t id,
- bool success,
- const net::IPAddressNumber& ip_address_ipv4,
- const net::IPAddressNumber& ip_address_ipv6) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- callback_runner_->PostTask(
- FROM_HERE,
- base::Bind(&ServiceDiscoveryHostClient::RunLocalDomainResolverCallback,
- this, id, success, ip_address_ipv4, ip_address_ipv6));
-}
-
-void ServiceDiscoveryHostClient::RunWatcherCallback(
- uint64_t id,
- ServiceWatcher::UpdateType update,
- const std::string& service_name) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- WatcherCallbacks::iterator it = service_watcher_callbacks_.find(id);
- if (it != service_watcher_callbacks_.end() && !it->second.is_null())
- it->second.Run(update, service_name);
-}
-
-void ServiceDiscoveryHostClient::RunResolverCallback(
- uint64_t id,
- ServiceResolver::RequestStatus status,
- const ServiceDescription& description) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- ResolverCallbacks::iterator it = service_resolver_callbacks_.find(id);
- if (it != service_resolver_callbacks_.end() && !it->second.is_null())
- it->second.Run(status, description);
-}
-
-void ServiceDiscoveryHostClient::RunLocalDomainResolverCallback(
- uint64_t id,
- bool success,
- const net::IPAddressNumber& ip_address_ipv4,
- const net::IPAddressNumber& ip_address_ipv6) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- DomainResolverCallbacks::iterator it = domain_resolver_callbacks_.find(id);
- if (it != domain_resolver_callbacks_.end() && !it->second.is_null())
- it->second.Run(success, ip_address_ipv4, ip_address_ipv6);
-}
-
-} // namespace local_discovery
diff --git a/chrome/browser/local_discovery/service_discovery_host_client.h b/chrome/browser/local_discovery/service_discovery_host_client.h
deleted file mode 100644
index 7849f31..0000000
--- a/chrome/browser/local_discovery/service_discovery_host_client.h
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_HOST_CLIENT_H_
-#define CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_HOST_CLIENT_H_
-
-#include <stdint.h>
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include "base/macros.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_vector.h"
-#include "base/memory/weak_ptr.h"
-#include "build/build_config.h"
-#include "chrome/common/local_discovery/service_discovery_client.h"
-#include "content/public/browser/utility_process_host_client.h"
-
-struct LocalDiscoveryMsg_SocketInfo;
-
-namespace base {
-class TaskRunner;
-}
-
-namespace content {
-class UtilityProcessHost;
-}
-
-namespace local_discovery {
-
-#if defined(OS_POSIX)
-typedef std::vector<LocalDiscoveryMsg_SocketInfo> SocketInfoList;
-#endif // OS_POSIX
-
-// Implementation of ServiceDiscoveryClient that delegates all functionality to
-// utility process.
-class ServiceDiscoveryHostClient
- : public ServiceDiscoveryClient,
- public content::UtilityProcessHostClient {
- public:
- ServiceDiscoveryHostClient();
-
- // Starts utility process with ServiceDiscoveryClient.
- void Start(const base::Closure& error_callback);
-
- // Shutdowns utility process.
- void Shutdown();
-
- // ServiceDiscoveryClient implementation.
- scoped_ptr<ServiceWatcher> CreateServiceWatcher(
- const std::string& service_type,
- const ServiceWatcher::UpdatedCallback& callback) override;
- scoped_ptr<ServiceResolver> CreateServiceResolver(
- const std::string& service_name,
- const ServiceResolver::ResolveCompleteCallback& callback) override;
- scoped_ptr<LocalDomainResolver> CreateLocalDomainResolver(
- const std::string& domain,
- net::AddressFamily address_family,
- const LocalDomainResolver::IPAddressCallback& callback) override;
-
- // UtilityProcessHostClient implementation.
- void OnProcessCrashed(int exit_code) override;
- bool OnMessageReceived(const IPC::Message& message) override;
-
- protected:
- ~ServiceDiscoveryHostClient() override;
-
- private:
- class ServiceWatcherProxy;
- class ServiceResolverProxy;
- class LocalDomainResolverProxy;
- friend class ServiceDiscoveryClientUtility;
-
- typedef std::map<uint64_t, ServiceWatcher::UpdatedCallback> WatcherCallbacks;
- typedef std::map<uint64_t, ServiceResolver::ResolveCompleteCallback>
- ResolverCallbacks;
- typedef std::map<uint64_t, LocalDomainResolver::IPAddressCallback>
- DomainResolverCallbacks;
-
- void StartOnIOThread();
- void ShutdownOnIOThread();
-
-#if defined(OS_POSIX)
- void OnSocketsReady(const SocketInfoList& interfaces);
-#endif // OS_POSIX
-
- void InvalidateWatchers();
-
- void Send(IPC::Message* msg);
- void SendOnIOThread(IPC::Message* msg);
-
- uint64_t RegisterWatcherCallback(
- const ServiceWatcher::UpdatedCallback& callback);
- uint64_t RegisterResolverCallback(
- const ServiceResolver::ResolveCompleteCallback& callback);
- uint64_t RegisterLocalDomainResolverCallback(
- const LocalDomainResolver::IPAddressCallback& callback);
-
- void UnregisterWatcherCallback(uint64_t id);
- void UnregisterResolverCallback(uint64_t id);
- void UnregisterLocalDomainResolverCallback(uint64_t id);
-
- // IPC Message handlers.
- void OnError();
- void OnWatcherCallback(uint64_t id,
- ServiceWatcher::UpdateType update,
- const std::string& service_name);
- void OnResolverCallback(uint64_t id,
- ServiceResolver::RequestStatus status,
- const ServiceDescription& description);
- void OnLocalDomainResolverCallback(uint64_t id,
- bool success,
- const net::IPAddressNumber& address_ipv4,
- const net::IPAddressNumber& address_ipv6);
-
- // Runs watcher callback on owning thread.
- void RunWatcherCallback(uint64_t id,
- ServiceWatcher::UpdateType update,
- const std::string& service_name);
- // Runs resolver callback on owning thread.
- void RunResolverCallback(uint64_t id,
- ServiceResolver::RequestStatus status,
- const ServiceDescription& description);
- // Runs local domain resolver callback on owning thread.
- void RunLocalDomainResolverCallback(uint64_t id,
- bool success,
- const net::IPAddressNumber& address_ipv4,
- const net::IPAddressNumber& address_ipv6);
-
- base::WeakPtr<content::UtilityProcessHost> utility_host_;
-
- // Incrementing counter to assign ID to watchers and resolvers.
- uint64_t current_id_;
- base::Closure error_callback_;
- WatcherCallbacks service_watcher_callbacks_;
- ResolverCallbacks service_resolver_callbacks_;
- DomainResolverCallbacks domain_resolver_callbacks_;
- scoped_refptr<base::TaskRunner> callback_runner_;
- scoped_refptr<base::TaskRunner> io_runner_;
- ScopedVector<IPC::Message> delayed_messages_;
-
- DISALLOW_COPY_AND_ASSIGN(ServiceDiscoveryHostClient);
-};
-
-} // namespace local_discovery
-
-#endif // CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_HOST_CLIENT_H_
diff --git a/chrome/browser/local_discovery/service_discovery_shared_client.cc b/chrome/browser/local_discovery/service_discovery_shared_client.cc
index 4d8c9eb..1a397e4 100644
--- a/chrome/browser/local_discovery/service_discovery_shared_client.cc
+++ b/chrome/browser/local_discovery/service_discovery_shared_client.cc
@@ -21,7 +21,6 @@
#if defined(ENABLE_MDNS)
#include "chrome/browser/local_discovery/service_discovery_client_mdns.h"
-#include "chrome/browser/local_discovery/service_discovery_client_utility.h"
#endif // ENABLE_MDNS
namespace {
@@ -97,39 +96,6 @@ scoped_refptr<ServiceDiscoverySharedClient>
#endif // OS_MACOSX
}
-// static
-void ServiceDiscoverySharedClient::GetInstanceWithoutAlert(
- const GetInstanceCallback& callback) {
-#if !defined(OS_WIN)
-
- scoped_refptr<ServiceDiscoverySharedClient> result = GetInstance();
- return callback.Run(result);
-
-#else // OS_WIN
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
- // TODO(vitalybuka): Switch to |ServiceDiscoveryClientMdns| after we find what
- // to do with firewall for user-level installs. crbug.com/366408
- scoped_refptr<ServiceDiscoverySharedClient> result =
- g_service_discovery_client;
- if (result.get())
- return callback.Run(result);
-
- if (!g_is_firewall_state_reported) {
- BrowserThread::PostTaskAndReply(
- BrowserThread::FILE,
- FROM_HERE,
- base::Bind(&ReportFirewallStats),
- base::Bind(&ServiceDiscoverySharedClient::GetInstanceWithoutAlert,
- callback));
- return;
- }
-
- result =
- g_is_firewall_ready ? GetInstance() : new ServiceDiscoveryClientUtility();
- callback.Run(result);
-#endif // OS_WIN
-}
-
#else
scoped_refptr<ServiceDiscoverySharedClient>
diff --git a/chrome/browser/local_discovery/service_discovery_shared_client.h b/chrome/browser/local_discovery/service_discovery_shared_client.h
index 9ffe5ce..dc98e7d 100644
--- a/chrome/browser/local_discovery/service_discovery_shared_client.h
+++ b/chrome/browser/local_discovery/service_discovery_shared_client.h
@@ -21,7 +21,6 @@ class ServiceDiscoverySharedClient
typedef base::Callback<void(
const scoped_refptr<ServiceDiscoverySharedClient>&)> GetInstanceCallback;
- static void GetInstanceWithoutAlert(const GetInstanceCallback& callback);
protected:
ServiceDiscoverySharedClient();
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 429ad9e..c402751 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1935,10 +1935,6 @@
'chrome_browser_mdns_sources': [
'browser/local_discovery/service_discovery_client_mdns.cc',
'browser/local_discovery/service_discovery_client_mdns.h',
- 'browser/local_discovery/service_discovery_client_utility.cc',
- 'browser/local_discovery/service_discovery_client_utility.h',
- 'browser/local_discovery/service_discovery_host_client.cc',
- 'browser/local_discovery/service_discovery_host_client.h',
'browser/printing/cloud_print/privet_traffic_detector.cc',
'browser/printing/cloud_print/privet_traffic_detector.h',
],
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 989a6ae..cbf6331 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -516,11 +516,6 @@
'<(DEPTH)/components/components.gyp:dom_distiller_core', # Needed by chrome_content_client.cc.
],
}],
- ['enable_mdns == 1', {
- 'sources': [
- 'common/local_discovery/local_discovery_messages.h',
- ]
- }],
['OS=="mac"', {
'dependencies': [
'../third_party/google_toolbox_for_mac/google_toolbox_for_mac.gyp:google_toolbox_for_mac',
diff --git a/chrome/chrome_utility.gypi b/chrome/chrome_utility.gypi
index d6e9be0..8ed5511 100644
--- a/chrome/chrome_utility.gypi
+++ b/chrome/chrome_utility.gypi
@@ -15,8 +15,6 @@
'utility/cloud_print/pwg_encoder.h',
'utility/font_cache_handler_win.cc',
'utility/font_cache_handler_win.h',
- 'utility/local_discovery/service_discovery_message_handler.cc',
- 'utility/local_discovery/service_discovery_message_handler.h',
'utility/printing_handler.cc',
'utility/printing_handler.h',
'utility/safe_json_parser_handler.cc',
@@ -215,12 +213,6 @@
'utility/printing_handler.h',
]
}],
- ['enable_mdns==0', {
- 'sources!': [
- 'utility/local_discovery/service_discovery_message_handler.cc',
- 'utility/local_discovery/service_discovery_message_handler.h',
- ]
- }],
['safe_browsing==1', {
'sources': [ '<@(chrome_utility_safe_browsing_sources)' ],
'conditions': [
diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn
index edd9bc0..df5e371 100644
--- a/chrome/common/BUILD.gn
+++ b/chrome/common/BUILD.gn
@@ -247,10 +247,6 @@ static_library("common") {
]
}
- if (enable_mdns) {
- sources += [ "local_discovery/local_discovery_messages.h" ]
- }
-
if (is_mac) {
sources -= [ "channel_info_posix.cc" ]
public_deps += [
diff --git a/chrome/common/common_message_generator.h b/chrome/common/common_message_generator.h
index d6734af..e7a3f68 100644
--- a/chrome/common/common_message_generator.h
+++ b/chrome/common/common_message_generator.h
@@ -18,10 +18,6 @@
#include "chrome/common/extensions/chrome_utility_extensions_messages.h"
#endif
-#if defined(ENABLE_MDNS)
-#include "chrome/common/local_discovery/local_discovery_messages.h"
-#endif
-
#if defined(ENABLE_PRINT_PREVIEW)
#include "chrome/common/service_messages.h"
#endif
diff --git a/chrome/common/local_discovery/local_discovery_messages.h b/chrome/common/local_discovery/local_discovery_messages.h
deleted file mode 100644
index 8d94156..0000000
--- a/chrome/common/local_discovery/local_discovery_messages.h
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Defines local discovery messages between the browser and utility process.
-
-// Multiple-included file, no traditional include guard.
-
-#include <stdint.h>
-
-#include <vector>
-
-#include "build/build_config.h"
-#include "chrome/common/local_discovery/service_discovery_client.h"
-#include "ipc/ipc_message_macros.h"
-
-#ifndef CHROME_COMMON_LOCAL_DISCOVERY_LOCAL_DISCOVERY_MESSAGES_H_
-#define CHROME_COMMON_LOCAL_DISCOVERY_LOCAL_DISCOVERY_MESSAGES_H_
-
-#if defined(OS_POSIX)
-#include "base/file_descriptor_posix.h"
-#endif
-
-#if defined(OS_POSIX)
-struct LocalDiscoveryMsg_SocketInfo {
- LocalDiscoveryMsg_SocketInfo()
- : address_family(net::ADDRESS_FAMILY_UNSPECIFIED),
- interface_index(0) {
- }
-
- base::FileDescriptor descriptor;
- net::AddressFamily address_family;
- uint32_t interface_index;
-};
-#endif // OS_POSIX
-
-#endif // CHROME_COMMON_LOCAL_DISCOVERY_LOCAL_DISCOVERY_MESSAGES_H_
-
-#define IPC_MESSAGE_START LocalDiscoveryMsgStart
-
-IPC_ENUM_TRAITS_MAX_VALUE(local_discovery::ServiceWatcher::UpdateType,
- local_discovery::ServiceWatcher::UPDATE_TYPE_LAST)
-
-IPC_ENUM_TRAITS_MAX_VALUE(
- local_discovery::ServiceResolver::RequestStatus,
- local_discovery::ServiceResolver::REQUEST_STATUS_LAST)
-
-IPC_ENUM_TRAITS_MAX_VALUE(net::AddressFamily, net::ADDRESS_FAMILY_LAST)
-
-IPC_STRUCT_TRAITS_BEGIN(local_discovery::ServiceDescription)
- IPC_STRUCT_TRAITS_MEMBER(service_name)
- IPC_STRUCT_TRAITS_MEMBER(address)
- IPC_STRUCT_TRAITS_MEMBER(metadata)
- IPC_STRUCT_TRAITS_MEMBER(ip_address)
- IPC_STRUCT_TRAITS_MEMBER(last_seen)
-IPC_STRUCT_TRAITS_END()
-
-#if defined(OS_POSIX)
-IPC_STRUCT_TRAITS_BEGIN(LocalDiscoveryMsg_SocketInfo)
- IPC_STRUCT_TRAITS_MEMBER(descriptor)
- IPC_STRUCT_TRAITS_MEMBER(address_family)
- IPC_STRUCT_TRAITS_MEMBER(interface_index)
-IPC_STRUCT_TRAITS_END()
-#endif // OS_POSIX
-//------------------------------------------------------------------------------
-// Utility process messages:
-// These are messages from the browser to the utility process.
-
-#if defined(OS_POSIX)
-IPC_MESSAGE_CONTROL1(LocalDiscoveryMsg_SetSockets,
- std::vector<LocalDiscoveryMsg_SocketInfo> /* sockets */)
-#endif // OS_POSIX
-
-// Creates watcher and starts listening in utility process.
-IPC_MESSAGE_CONTROL2(LocalDiscoveryMsg_StartWatcher,
- uint64_t /* id */,
- std::string /* service_type */)
-
-// Discovers new services.
-IPC_MESSAGE_CONTROL2(LocalDiscoveryMsg_DiscoverServices,
- uint64_t /* id */,
- bool /* force_update */)
-
-// Discovers new services.
-IPC_MESSAGE_CONTROL2(LocalDiscoveryMsg_SetActivelyRefreshServices,
- uint64_t /* id */,
- bool /* actively_refresh_services */)
-
-// Destroys watcher in utility process.
-IPC_MESSAGE_CONTROL1(LocalDiscoveryMsg_DestroyWatcher, uint64_t /* id */)
-
-// Creates service resolver and starts resolving service in utility process.
-IPC_MESSAGE_CONTROL2(LocalDiscoveryMsg_ResolveService,
- uint64_t /* id */,
- std::string /* service_name */)
-
-// Destroys service resolver in utility process.
-IPC_MESSAGE_CONTROL1(LocalDiscoveryMsg_DestroyResolver, uint64_t /* id */)
-
-// Creates a local domain resolver and starts resolving in utility process.
-IPC_MESSAGE_CONTROL3(LocalDiscoveryMsg_ResolveLocalDomain,
- uint64_t /* id */,
- std::string /* domain */,
- net::AddressFamily /* address_family */)
-
-// Destroys local domain resolver in utility process.
-IPC_MESSAGE_CONTROL1(LocalDiscoveryMsg_DestroyLocalDomainResolver,
- uint64_t /* id */)
-
-// Stops local discovery in utility process. http://crbug.com/268466.
-IPC_MESSAGE_CONTROL0(LocalDiscoveryMsg_ShutdownLocalDiscovery)
-
-
-//------------------------------------------------------------------------------
-// Utility process host messages:
-// These are messages from the utility process to the browser.
-
-// Notifies browser process if process failed.
-IPC_MESSAGE_CONTROL0(LocalDiscoveryHostMsg_Error)
-
-// Notifies browser process about new services.
-IPC_MESSAGE_CONTROL3(LocalDiscoveryHostMsg_WatcherCallback,
- uint64_t /* id */,
- local_discovery::ServiceWatcher::UpdateType /* update */,
- std::string /* service_name */)
-
-// Notifies browser process about service resolution results.
-IPC_MESSAGE_CONTROL3(
- LocalDiscoveryHostMsg_ResolverCallback,
- uint64_t /* id */,
- local_discovery::ServiceResolver::RequestStatus /* status */,
- local_discovery::ServiceDescription /* description */)
-
-// Notifies browser process about local domain resolution results.
-IPC_MESSAGE_CONTROL4(LocalDiscoveryHostMsg_LocalDomainResolverCallback,
- uint64_t /* id */,
- bool /* success */,
- net::IPAddressNumber /* ip_address_ipv4 */,
- net::IPAddressNumber /* ip_address_ipv6 */)
diff --git a/chrome/utility/BUILD.gn b/chrome/utility/BUILD.gn
index edef316..22435b7 100644
--- a/chrome/utility/BUILD.gn
+++ b/chrome/utility/BUILD.gn
@@ -118,13 +118,6 @@ static_library("utility") {
]
}
- if (!enable_mdns) {
- sources -= [
- "local_discovery/service_discovery_message_handler.cc",
- "local_discovery/service_discovery_message_handler.h",
- ]
- }
-
if (safe_browsing_mode == 1) {
sources +=
rebase_path(gypi_values.chrome_utility_safe_browsing_sources, ".", "..")
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc
index c594732..b3cc696 100644
--- a/chrome/utility/chrome_content_utility_client.cc
+++ b/chrome/utility/chrome_content_utility_client.cc
@@ -56,10 +56,6 @@
#include "chrome/utility/printing_handler.h"
#endif
-#if defined(ENABLE_MDNS)
-#include "chrome/utility/local_discovery/service_discovery_message_handler.h"
-#endif
-
#if defined(OS_MACOSX) && defined(FULL_SAFE_BROWSING)
#include "chrome/utility/safe_browsing/mac/dmg_analyzer.h"
#endif
@@ -133,13 +129,6 @@ ChromeContentUtilityClient::ChromeContentUtilityClient()
handlers_.push_back(new printing::PrintingHandler());
#endif
-#if defined(ENABLE_MDNS)
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kUtilityProcessEnableMDns)) {
- handlers_.push_back(new local_discovery::ServiceDiscoveryMessageHandler());
- }
-#endif
-
#if defined(OS_WIN)
handlers_.push_back(new ShellHandler());
handlers_.push_back(new FontCacheHandler());
@@ -225,13 +214,6 @@ void ChromeContentUtilityClient::PreSandboxStartup() {
#if defined(ENABLE_EXTENSIONS)
extensions::ExtensionsHandler::PreSandboxStartup();
#endif
-
-#if defined(ENABLE_MDNS)
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kUtilityProcessEnableMDns)) {
- local_discovery::ServiceDiscoveryMessageHandler::PreSandboxStartup();
- }
-#endif // ENABLE_MDNS
}
// static
diff --git a/chrome/utility/local_discovery/OWNERS b/chrome/utility/local_discovery/OWNERS
deleted file mode 100644
index a0508fc..0000000
--- a/chrome/utility/local_discovery/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-gene@chromium.org
-noamsml@chromium.org
-vitalybuka@chromium.org
diff --git a/chrome/utility/local_discovery/service_discovery_message_handler.cc b/chrome/utility/local_discovery/service_discovery_message_handler.cc
deleted file mode 100644
index 9a9aac7..0000000
--- a/chrome/utility/local_discovery/service_discovery_message_handler.cc
+++ /dev/null
@@ -1,489 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/utility/local_discovery/service_discovery_message_handler.h"
-
-#include <stddef.h>
-
-#include <algorithm>
-#include <vector>
-
-#include "base/lazy_instance.h"
-#include "base/location.h"
-#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/single_thread_task_runner.h"
-#include "build/build_config.h"
-#include "chrome/common/local_discovery/local_discovery_messages.h"
-#include "chrome/common/local_discovery/service_discovery_client_impl.h"
-#include "content/public/utility/utility_thread.h"
-#include "net/base/net_util.h"
-#include "net/socket/socket_descriptor.h"
-#include "net/udp/datagram_server_socket.h"
-
-namespace local_discovery {
-
-namespace {
-
-void ClosePlatformSocket(net::SocketDescriptor socket);
-
-// Sets socket factory used by |net::CreatePlatformSocket|. Implemetation
-// keeps single socket that will be returned to the first call to
-// |net::CreatePlatformSocket| during object lifetime.
-class ScopedSocketFactory : public net::PlatformSocketFactory {
- public:
- explicit ScopedSocketFactory(net::SocketDescriptor socket) : socket_(socket) {
- net::PlatformSocketFactory::SetInstance(this);
- }
-
- ~ScopedSocketFactory() override {
- net::PlatformSocketFactory::SetInstance(NULL);
- ClosePlatformSocket(socket_);
- socket_ = net::kInvalidSocket;
- }
-
- net::SocketDescriptor CreateSocket(int family,
- int type,
- int protocol) override {
- DCHECK_EQ(type, SOCK_DGRAM);
- DCHECK(family == AF_INET || family == AF_INET6);
- net::SocketDescriptor result = net::kInvalidSocket;
- std::swap(result, socket_);
- return result;
- }
-
- private:
- net::SocketDescriptor socket_;
- DISALLOW_COPY_AND_ASSIGN(ScopedSocketFactory);
-};
-
-struct SocketInfo {
- SocketInfo(net::SocketDescriptor socket,
- net::AddressFamily address_family,
- uint32_t interface_index)
- : socket(socket),
- address_family(address_family),
- interface_index(interface_index) {}
- net::SocketDescriptor socket;
- net::AddressFamily address_family;
- uint32_t interface_index;
-};
-
-// Returns list of sockets preallocated before.
-class PreCreatedMDnsSocketFactory : public net::MDnsSocketFactory {
- public:
- PreCreatedMDnsSocketFactory() {}
- ~PreCreatedMDnsSocketFactory() override {
- // Not empty if process exits too fast, before starting mDns code. If
- // happened, destructors may crash accessing destroyed global objects.
- // 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(
- std::vector<scoped_ptr<net::DatagramServerSocket>>* sockets) override {
- sockets->swap(sockets_);
- Reset();
- }
-
- 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(std::move(socket));
- }
- }
-
- void Reset() {
- sockets_.clear();
- }
-
- private:
- std::vector<scoped_ptr<net::DatagramServerSocket>> sockets_;
-
- DISALLOW_COPY_AND_ASSIGN(PreCreatedMDnsSocketFactory);
-};
-
-base::LazyInstance<PreCreatedMDnsSocketFactory>
- g_local_discovery_socket_factory = LAZY_INSTANCE_INITIALIZER;
-
-#if defined(OS_WIN)
-
-void ClosePlatformSocket(net::SocketDescriptor socket) {
- ::closesocket(socket);
-}
-
-void StaticInitializeSocketFactory() {
- net::InterfaceIndexFamilyList interfaces(net::GetMDnsInterfacesToBind());
- for (size_t i = 0; i < interfaces.size(); ++i) {
- DCHECK(interfaces[i].second == net::ADDRESS_FAMILY_IPV4 ||
- interfaces[i].second == net::ADDRESS_FAMILY_IPV6);
- net::SocketDescriptor descriptor =
- net::CreatePlatformSocket(
- net::ConvertAddressFamily(interfaces[i].second), SOCK_DGRAM,
- IPPROTO_UDP);
- g_local_discovery_socket_factory.Get().AddSocket(
- SocketInfo(descriptor, interfaces[i].second, interfaces[i].first));
- }
-}
-
-#else // OS_WIN
-
-void ClosePlatformSocket(net::SocketDescriptor socket) {
- ::close(socket);
-}
-
-void StaticInitializeSocketFactory() {
-}
-
-#endif // OS_WIN
-
-void SendHostMessageOnUtilityThread(IPC::Message* msg) {
- content::UtilityThread::Get()->Send(msg);
-}
-
-std::string WatcherUpdateToString(ServiceWatcher::UpdateType update) {
- switch (update) {
- case ServiceWatcher::UPDATE_ADDED:
- return "UPDATE_ADDED";
- case ServiceWatcher::UPDATE_CHANGED:
- return "UPDATE_CHANGED";
- case ServiceWatcher::UPDATE_REMOVED:
- return "UPDATE_REMOVED";
- case ServiceWatcher::UPDATE_INVALIDATED:
- return "UPDATE_INVALIDATED";
- }
- return "Unknown Update";
-}
-
-std::string ResolverStatusToString(ServiceResolver::RequestStatus status) {
- switch (status) {
- case ServiceResolver::STATUS_SUCCESS:
- return "STATUS_SUCESS";
- case ServiceResolver::STATUS_REQUEST_TIMEOUT:
- return "STATUS_REQUEST_TIMEOUT";
- case ServiceResolver::STATUS_KNOWN_NONEXISTENT:
- return "STATUS_KNOWN_NONEXISTENT";
- }
- return "Unknown Status";
-}
-
-} // namespace
-
-ServiceDiscoveryMessageHandler::ServiceDiscoveryMessageHandler() {
-}
-
-ServiceDiscoveryMessageHandler::~ServiceDiscoveryMessageHandler() {
- DCHECK(!discovery_thread_);
-}
-
-void ServiceDiscoveryMessageHandler::PreSandboxStartup() {
- StaticInitializeSocketFactory();
-}
-
-void ServiceDiscoveryMessageHandler::InitializeMdns() {
- if (service_discovery_client_ || mdns_client_)
- return;
-
- mdns_client_ = net::MDnsClient::CreateDefault();
- bool result =
- mdns_client_->StartListening(g_local_discovery_socket_factory.Pointer());
- // Close unused sockets.
- g_local_discovery_socket_factory.Get().Reset();
- if (!result) {
- VLOG(1) << "Failed to start MDnsClient";
- Send(new LocalDiscoveryHostMsg_Error());
- return;
- }
-
- service_discovery_client_.reset(
- new local_discovery::ServiceDiscoveryClientImpl(mdns_client_.get()));
-}
-
-bool ServiceDiscoveryMessageHandler::InitializeThread() {
- if (discovery_task_runner_.get())
- return true;
- if (discovery_thread_)
- return false;
- utility_task_runner_ = base::MessageLoop::current()->task_runner();
- discovery_thread_.reset(new base::Thread("ServiceDiscoveryThread"));
- base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
- if (discovery_thread_->StartWithOptions(thread_options)) {
- discovery_task_runner_ = discovery_thread_->task_runner();
- discovery_task_runner_->PostTask(FROM_HERE,
- base::Bind(&ServiceDiscoveryMessageHandler::InitializeMdns,
- base::Unretained(this)));
- }
- return discovery_task_runner_.get() != NULL;
-}
-
-bool ServiceDiscoveryMessageHandler::OnMessageReceived(
- const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(ServiceDiscoveryMessageHandler, message)
-#if defined(OS_POSIX)
- IPC_MESSAGE_HANDLER(LocalDiscoveryMsg_SetSockets, OnSetSockets)
-#endif // OS_POSIX
- IPC_MESSAGE_HANDLER(LocalDiscoveryMsg_StartWatcher, OnStartWatcher)
- IPC_MESSAGE_HANDLER(LocalDiscoveryMsg_DiscoverServices, OnDiscoverServices)
- IPC_MESSAGE_HANDLER(LocalDiscoveryMsg_SetActivelyRefreshServices,
- OnSetActivelyRefreshServices)
- IPC_MESSAGE_HANDLER(LocalDiscoveryMsg_DestroyWatcher, OnDestroyWatcher)
- IPC_MESSAGE_HANDLER(LocalDiscoveryMsg_ResolveService, OnResolveService)
- IPC_MESSAGE_HANDLER(LocalDiscoveryMsg_DestroyResolver, OnDestroyResolver)
- IPC_MESSAGE_HANDLER(LocalDiscoveryMsg_ResolveLocalDomain,
- OnResolveLocalDomain)
- IPC_MESSAGE_HANDLER(LocalDiscoveryMsg_DestroyLocalDomainResolver,
- OnDestroyLocalDomainResolver)
- IPC_MESSAGE_HANDLER(LocalDiscoveryMsg_ShutdownLocalDiscovery,
- ShutdownLocalDiscovery)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void ServiceDiscoveryMessageHandler::PostTask(
- const tracked_objects::Location& from_here,
- const base::Closure& task) {
- if (!InitializeThread())
- return;
- discovery_task_runner_->PostTask(from_here, task);
-}
-
-#if defined(OS_POSIX)
-void ServiceDiscoveryMessageHandler::OnSetSockets(
- const std::vector<LocalDiscoveryMsg_SocketInfo>& sockets) {
- for (size_t i = 0; i < sockets.size(); ++i) {
- g_local_discovery_socket_factory.Get().AddSocket(
- SocketInfo(sockets[i].descriptor.fd, sockets[i].address_family,
- sockets[i].interface_index));
- }
-}
-#endif // OS_POSIX
-
-void ServiceDiscoveryMessageHandler::OnStartWatcher(
- uint64_t id,
- const std::string& service_type) {
- PostTask(FROM_HERE,
- base::Bind(&ServiceDiscoveryMessageHandler::StartWatcher,
- base::Unretained(this), id, service_type));
-}
-
-void ServiceDiscoveryMessageHandler::OnDiscoverServices(uint64_t id,
- bool force_update) {
- PostTask(FROM_HERE,
- base::Bind(&ServiceDiscoveryMessageHandler::DiscoverServices,
- base::Unretained(this), id, force_update));
-}
-
-void ServiceDiscoveryMessageHandler::OnSetActivelyRefreshServices(
- uint64_t id,
- bool actively_refresh_services) {
- PostTask(FROM_HERE,
- base::Bind(
- &ServiceDiscoveryMessageHandler::SetActivelyRefreshServices,
- base::Unretained(this), id, actively_refresh_services));
-}
-
-void ServiceDiscoveryMessageHandler::OnDestroyWatcher(uint64_t id) {
- PostTask(FROM_HERE,
- base::Bind(&ServiceDiscoveryMessageHandler::DestroyWatcher,
- base::Unretained(this), id));
-}
-
-void ServiceDiscoveryMessageHandler::OnResolveService(
- uint64_t id,
- const std::string& service_name) {
- PostTask(FROM_HERE,
- base::Bind(&ServiceDiscoveryMessageHandler::ResolveService,
- base::Unretained(this), id, service_name));
-}
-
-void ServiceDiscoveryMessageHandler::OnDestroyResolver(uint64_t id) {
- PostTask(FROM_HERE,
- base::Bind(&ServiceDiscoveryMessageHandler::DestroyResolver,
- base::Unretained(this), id));
-}
-
-void ServiceDiscoveryMessageHandler::OnResolveLocalDomain(
- uint64_t id,
- const std::string& domain,
- net::AddressFamily address_family) {
- PostTask(FROM_HERE,
- base::Bind(&ServiceDiscoveryMessageHandler::ResolveLocalDomain,
- base::Unretained(this), id, domain, address_family));
-}
-
-void ServiceDiscoveryMessageHandler::OnDestroyLocalDomainResolver(uint64_t id) {
- PostTask(FROM_HERE,
- base::Bind(
- &ServiceDiscoveryMessageHandler::DestroyLocalDomainResolver,
- base::Unretained(this), id));
-}
-
-void ServiceDiscoveryMessageHandler::StartWatcher(
- uint64_t id,
- const std::string& service_type) {
- VLOG(1) << "StartWatcher, id=" << id << ", type=" << service_type;
- if (!service_discovery_client_)
- return;
- DCHECK(!ContainsKey(service_watchers_, id));
- scoped_ptr<ServiceWatcher> watcher(
- service_discovery_client_->CreateServiceWatcher(
- service_type,
- base::Bind(&ServiceDiscoveryMessageHandler::OnServiceUpdated,
- base::Unretained(this), id)));
- watcher->Start();
- service_watchers_[id].reset(watcher.release());
-}
-
-void ServiceDiscoveryMessageHandler::DiscoverServices(uint64_t id,
- bool force_update) {
- VLOG(1) << "DiscoverServices, id=" << id;
- if (!service_discovery_client_)
- return;
- DCHECK(ContainsKey(service_watchers_, id));
- service_watchers_[id]->DiscoverNewServices(force_update);
-}
-
-void ServiceDiscoveryMessageHandler::SetActivelyRefreshServices(
- uint64_t id,
- bool actively_refresh_services) {
- VLOG(1) << "ActivelyRefreshServices, id=" << id;
- if (!service_discovery_client_)
- return;
- DCHECK(ContainsKey(service_watchers_, id));
- service_watchers_[id]->SetActivelyRefreshServices(actively_refresh_services);
-}
-
-void ServiceDiscoveryMessageHandler::DestroyWatcher(uint64_t id) {
- VLOG(1) << "DestoryWatcher, id=" << id;
- if (!service_discovery_client_)
- return;
- service_watchers_.erase(id);
-}
-
-void ServiceDiscoveryMessageHandler::ResolveService(
- uint64_t id,
- const std::string& service_name) {
- VLOG(1) << "ResolveService, id=" << id << ", name=" << service_name;
- if (!service_discovery_client_)
- return;
- DCHECK(!ContainsKey(service_resolvers_, id));
- scoped_ptr<ServiceResolver> resolver(
- service_discovery_client_->CreateServiceResolver(
- service_name,
- base::Bind(&ServiceDiscoveryMessageHandler::OnServiceResolved,
- base::Unretained(this), id)));
- resolver->StartResolving();
- service_resolvers_[id].reset(resolver.release());
-}
-
-void ServiceDiscoveryMessageHandler::DestroyResolver(uint64_t id) {
- VLOG(1) << "DestroyResolver, id=" << id;
- if (!service_discovery_client_)
- return;
- service_resolvers_.erase(id);
-}
-
-void ServiceDiscoveryMessageHandler::ResolveLocalDomain(
- uint64_t id,
- const std::string& domain,
- net::AddressFamily address_family) {
- VLOG(1) << "ResolveLocalDomain, id=" << id << ", domain=" << domain;
- if (!service_discovery_client_)
- return;
- DCHECK(!ContainsKey(local_domain_resolvers_, id));
- scoped_ptr<LocalDomainResolver> resolver(
- service_discovery_client_->CreateLocalDomainResolver(
- domain, address_family,
- base::Bind(&ServiceDiscoveryMessageHandler::OnLocalDomainResolved,
- base::Unretained(this), id)));
- resolver->Start();
- local_domain_resolvers_[id].reset(resolver.release());
-}
-
-void ServiceDiscoveryMessageHandler::DestroyLocalDomainResolver(uint64_t id) {
- VLOG(1) << "DestroyLocalDomainResolver, id=" << id;
- if (!service_discovery_client_)
- return;
- local_domain_resolvers_.erase(id);
-}
-
-void ServiceDiscoveryMessageHandler::ShutdownLocalDiscovery() {
- if (!discovery_task_runner_.get())
- return;
-
- discovery_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&ServiceDiscoveryMessageHandler::ShutdownOnIOThread,
- base::Unretained(this)));
-
- // This will wait for message loop to drain, so ShutdownOnIOThread will
- // definitely be called.
- discovery_thread_.reset();
-}
-
-void ServiceDiscoveryMessageHandler::ShutdownOnIOThread() {
- VLOG(1) << "ShutdownLocalDiscovery";
- service_watchers_.clear();
- service_resolvers_.clear();
- local_domain_resolvers_.clear();
- service_discovery_client_.reset();
- mdns_client_.reset();
-}
-
-void ServiceDiscoveryMessageHandler::OnServiceUpdated(
- uint64_t id,
- ServiceWatcher::UpdateType update,
- const std::string& name) {
- VLOG(1) << "OnServiceUpdated, id=" << id
- << ", status=" << WatcherUpdateToString(update) << ", name=" << name;
- DCHECK(service_discovery_client_);
-
- Send(new LocalDiscoveryHostMsg_WatcherCallback(id, update, name));
-}
-
-void ServiceDiscoveryMessageHandler::OnServiceResolved(
- uint64_t id,
- ServiceResolver::RequestStatus status,
- const ServiceDescription& description) {
- VLOG(1) << "OnServiceResolved, id=" << id
- << ", status=" << ResolverStatusToString(status)
- << ", name=" << description.service_name;
-
- DCHECK(service_discovery_client_);
- Send(new LocalDiscoveryHostMsg_ResolverCallback(id, status, description));
-}
-
-void ServiceDiscoveryMessageHandler::OnLocalDomainResolved(
- uint64_t id,
- bool success,
- const net::IPAddressNumber& address_ipv4,
- const net::IPAddressNumber& address_ipv6) {
- VLOG(1) << "OnLocalDomainResolved, id=" << id
- << ", IPv4=" << (address_ipv4.empty() ? "" :
- net::IPAddressToString(address_ipv4))
- << ", IPv6=" << (address_ipv6.empty() ? "" :
- net::IPAddressToString(address_ipv6));
-
- DCHECK(service_discovery_client_);
- Send(new LocalDiscoveryHostMsg_LocalDomainResolverCallback(
- id, success, address_ipv4, address_ipv6));
-}
-
-void ServiceDiscoveryMessageHandler::Send(IPC::Message* msg) {
- utility_task_runner_->PostTask(FROM_HERE,
- base::Bind(&SendHostMessageOnUtilityThread,
- msg));
-}
-
-} // namespace local_discovery
diff --git a/chrome/utility/local_discovery/service_discovery_message_handler.h b/chrome/utility/local_discovery/service_discovery_message_handler.h
deleted file mode 100644
index ce0435d..0000000
--- a/chrome/utility/local_discovery/service_discovery_message_handler.h
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_UTILITY_LOCAL_DISCOVERY_SERVICE_DISCOVERY_MESSAGE_HANDLER_H_
-#define CHROME_UTILITY_LOCAL_DISCOVERY_SERVICE_DISCOVERY_MESSAGE_HANDLER_H_
-
-#include <stdint.h>
-
-#include <map>
-#include <string>
-
-#include "base/memory/linked_ptr.h"
-#include "build/build_config.h"
-#include "chrome/common/local_discovery/service_discovery_client.h"
-#include "chrome/utility/utility_message_handler.h"
-
-struct LocalDiscoveryMsg_SocketInfo;
-
-namespace net {
-class MDnsClient;
-}
-
-namespace base {
-struct FileDescriptor;
-class TaskRunner;
-class Thread;
-}
-
-namespace tracked_objects {
-class Location;
-}
-
-namespace local_discovery {
-
-class ServiceDiscoveryClient;
-
-// Handles messages related to local discovery inside utility process.
-class ServiceDiscoveryMessageHandler : public UtilityMessageHandler {
- public:
- ServiceDiscoveryMessageHandler();
- ~ServiceDiscoveryMessageHandler() override;
-
- // UtilityMessageHandler implementation.
- bool OnMessageReceived(const IPC::Message& message) override;
-
- static void PreSandboxStartup();
-
- private:
- typedef std::map<uint64_t, linked_ptr<ServiceWatcher>> ServiceWatchers;
- typedef std::map<uint64_t, linked_ptr<ServiceResolver>> ServiceResolvers;
- typedef std::map<uint64_t, linked_ptr<LocalDomainResolver>>
- LocalDomainResolvers;
-
- // Lazy initializes ServiceDiscoveryClient.
- bool InitializeThread();
- void PostTask(const tracked_objects::Location& from_here,
- const base::Closure& task);
-
- // IPC message handlers.
-#if defined(OS_POSIX)
- void OnSetSockets(const std::vector<LocalDiscoveryMsg_SocketInfo>& sockets);
-#endif // OS_POSIX
- void OnStartWatcher(uint64_t id, const std::string& service_type);
- void OnDiscoverServices(uint64_t id, bool force_update);
- void OnSetActivelyRefreshServices(uint64_t id,
- bool actively_refresh_services);
- void OnDestroyWatcher(uint64_t id);
- void OnResolveService(uint64_t id, const std::string& service_name);
- void OnDestroyResolver(uint64_t id);
- void OnResolveLocalDomain(uint64_t id,
- const std::string& domain,
- net::AddressFamily address_family);
- void OnDestroyLocalDomainResolver(uint64_t id);
-
- void InitializeMdns();
- void StartWatcher(uint64_t id, const std::string& service_type);
- void DiscoverServices(uint64_t id, bool force_update);
- void SetActivelyRefreshServices(uint64_t id, bool actively_refresh_services);
- void DestroyWatcher(uint64_t id);
- void ResolveService(uint64_t id, const std::string& service_name);
- void DestroyResolver(uint64_t id);
- void ResolveLocalDomain(uint64_t id,
- const std::string& domain,
- net::AddressFamily address_family);
- void DestroyLocalDomainResolver(uint64_t id);
-
- void ShutdownLocalDiscovery();
- void ShutdownOnIOThread();
-
- // Is called by ServiceWatcher as callback.
- void OnServiceUpdated(uint64_t id,
- ServiceWatcher::UpdateType update,
- const std::string& name);
-
- // Is called by ServiceResolver as callback.
- void OnServiceResolved(uint64_t id,
- ServiceResolver::RequestStatus status,
- const ServiceDescription& description);
-
- // Is called by LocalDomainResolver as callback.
- void OnLocalDomainResolved(uint64_t id,
- bool success,
- const net::IPAddressNumber& address_ipv4,
- const net::IPAddressNumber& address_ipv6);
-
- void Send(IPC::Message* msg);
-
- ServiceWatchers service_watchers_;
- ServiceResolvers service_resolvers_;
- LocalDomainResolvers local_domain_resolvers_;
-
- scoped_ptr<net::MDnsClient> mdns_client_;
- scoped_ptr<ServiceDiscoveryClient> service_discovery_client_;
-
- scoped_refptr<base::TaskRunner> utility_task_runner_;
- scoped_refptr<base::TaskRunner> discovery_task_runner_;
- scoped_ptr<base::Thread> discovery_thread_;
-};
-
-} // namespace local_discovery
-
-#endif // CHROME_UTILITY_LOCAL_DISCOVERY_SERVICE_DISCOVERY_MESSAGE_HANDLER_H_
diff --git a/content/browser/utility_process_host_impl.cc b/content/browser/utility_process_host_impl.cc
index 3b7891f..db67d60 100644
--- a/content/browser/utility_process_host_impl.cc
+++ b/content/browser/utility_process_host_impl.cc
@@ -130,7 +130,6 @@ UtilityProcessHostImpl::UtilityProcessHostImpl(
: client_(client),
client_task_runner_(client_task_runner),
is_batch_mode_(false),
- is_mdns_enabled_(false),
no_sandbox_(false),
run_elevated_(false),
#if defined(OS_LINUX)
@@ -177,10 +176,6 @@ void UtilityProcessHostImpl::SetExposedDir(const base::FilePath& dir) {
exposed_dir_ = dir;
}
-void UtilityProcessHostImpl::EnableMDns() {
- is_mdns_enabled_ = true;
-}
-
void UtilityProcessHostImpl::DisableSandbox() {
no_sandbox_ = true;
}
@@ -318,9 +313,6 @@ bool UtilityProcessHostImpl::StartProcess() {
exposed_dir_);
}
- if (is_mdns_enabled_)
- cmd_line->AppendSwitch(switches::kUtilityProcessEnableMDns);
-
#if defined(OS_WIN)
// Let the utility process know if it is intended to be elevated.
if (run_elevated_)
diff --git a/content/browser/utility_process_host_impl.h b/content/browser/utility_process_host_impl.h
index ea8572f..94aafa7 100644
--- a/content/browser/utility_process_host_impl.h
+++ b/content/browser/utility_process_host_impl.h
@@ -49,7 +49,6 @@ class CONTENT_EXPORT UtilityProcessHostImpl
bool StartBatchMode() override;
void EndBatchMode() override;
void SetExposedDir(const base::FilePath& dir) override;
- void EnableMDns() override;
void DisableSandbox() override;
#if defined(OS_WIN)
void ElevatePrivileges() override;
@@ -84,10 +83,6 @@ class CONTENT_EXPORT UtilityProcessHostImpl
base::FilePath exposed_dir_;
- // Whether the utility process needs to perform presandbox initialization
- // for mDNS.
- bool is_mdns_enabled_;
-
// Whether to pass switches::kNoSandbox to the child.
bool no_sandbox_;
diff --git a/content/public/browser/utility_process_host.h b/content/public/browser/utility_process_host.h
index 3e5252f..1a90313 100644
--- a/content/public/browser/utility_process_host.h
+++ b/content/public/browser/utility_process_host.h
@@ -61,9 +61,6 @@ class UtilityProcessHost : public IPC::Sender {
// the operation.
virtual void SetExposedDir(const base::FilePath& dir) = 0;
- // Perform presandbox initialization for mDNS.
- virtual void EnableMDns() = 0;
-
// Make the process run without a sandbox.
virtual void DisableSandbox() = 0;
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index 0f97ee2..2e8ddee 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -839,9 +839,6 @@ const char kUtilityProcess[] = "utility";
// specifies the directory that can be accessed.
const char kUtilityProcessAllowedDir[] = "utility-allowed-dir";
-// Allows MDns to access network in sandboxed process.
-const char kUtilityProcessEnableMDns[] = "utility-enable-mdns";
-
const char kUtilityProcessRunningElevated[] = "utility-run-elevated";
// In debug builds, asserts that the stream of input events is valid.
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
index 3c9954f..3e45a17 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -236,7 +236,6 @@ CONTENT_EXPORT extern const char kDisableSurfaces[];
extern const char kUtilityCmdPrefix[];
CONTENT_EXPORT extern const char kUtilityProcess[];
extern const char kUtilityProcessAllowedDir[];
-CONTENT_EXPORT extern const char kUtilityProcessEnableMDns[];
CONTENT_EXPORT extern const char kUtilityProcessRunningElevated[];
CONTENT_EXPORT extern const char kV8CacheOptions[];
CONTENT_EXPORT extern const char kV8NativesPassedByFD[];
diff --git a/ipc/ipc_message_start.h b/ipc/ipc_message_start.h
index 8ec7f3c..8197ac6 100644
--- a/ipc/ipc_message_start.h
+++ b/ipc/ipc_message_start.h
@@ -79,7 +79,6 @@ enum IPCMessageStart {
WebSocketMsgStart,
NaClHostMsgStart,
WebRTCIdentityMsgStart,
- LocalDiscoveryMsgStart,
PowerMonitorMsgStart,
EncryptedMediaMsgStart,
CacheStorageMsgStart,
diff --git a/net/socket/socket_descriptor.cc b/net/socket/socket_descriptor.cc
index 2744d66..0822d2d 100644
--- a/net/socket/socket_descriptor.cc
+++ b/net/socket/socket_descriptor.cc
@@ -17,19 +17,7 @@
namespace net {
-PlatformSocketFactory* g_socket_factory = nullptr;
-
-PlatformSocketFactory::PlatformSocketFactory() {
-}
-
-PlatformSocketFactory::~PlatformSocketFactory() {
-}
-
-void PlatformSocketFactory::SetInstance(PlatformSocketFactory* factory) {
- g_socket_factory = factory;
-}
-
-SocketDescriptor CreateSocketDefault(int family, int type, int protocol) {
+SocketDescriptor CreatePlatformSocket(int family, int type, int protocol) {
#if defined(OS_WIN)
EnsureWinsockInit();
SocketDescriptor result = ::WSASocket(family, type, protocol, nullptr, 0,
@@ -47,13 +35,7 @@ SocketDescriptor CreateSocketDefault(int family, int type, int protocol) {
#else // OS_WIN
return ::socket(family, type, protocol);
#endif // OS_WIN
-}
-SocketDescriptor CreatePlatformSocket(int family, int type, int protocol) {
- if (g_socket_factory)
- return g_socket_factory->CreateSocket(family, type, protocol);
- else
- return CreateSocketDefault(family, type, protocol);
}
} // namespace net
diff --git a/net/socket/socket_descriptor.h b/net/socket/socket_descriptor.h
index b2a2223..e58e140 100644
--- a/net/socket/socket_descriptor.h
+++ b/net/socket/socket_descriptor.h
@@ -22,23 +22,6 @@ typedef SOCKET SocketDescriptor;
const SocketDescriptor kInvalidSocket = INVALID_SOCKET;
#endif
-// Interface to create native socket.
-// Usually such factories are used for testing purposes, which is not true in
-// this case. This interface is used to substitute WSASocket/socket to make
-// possible execution of some network code in sandbox.
-class NET_EXPORT PlatformSocketFactory {
- public:
- PlatformSocketFactory();
- virtual ~PlatformSocketFactory();
-
- // Replace WSASocket/socket with given factory. The factory will be used by
- // CreatePlatformSocket.
- static void SetInstance(PlatformSocketFactory* factory);
-
- // Creates socket. See WSASocket/socket documentation of parameters.
- virtual SocketDescriptor CreateSocket(int family, int type, int protocol) = 0;
-};
-
// Creates socket. See WSASocket/socket documentation of parameters.
SocketDescriptor NET_EXPORT CreatePlatformSocket(int family,
int type,