summaryrefslogtreecommitdiffstats
path: root/chrome/browser/local_discovery
diff options
context:
space:
mode:
authorvitalybuka <vitalybuka@chromium.org>2015-02-25 01:47:14 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-25 09:47:46 +0000
commite61a6220ca4341f7eafac6dc3aacaa6f80a89896 (patch)
tree10b31227937f4b49989ae21604bd71748624d195 /chrome/browser/local_discovery
parent0d1cd5b310196798843d2db561e274549c86993f (diff)
downloadchromium_src-e61a6220ca4341f7eafac6dc3aacaa6f80a89896.zip
chromium_src-e61a6220ca4341f7eafac6dc3aacaa6f80a89896.tar.gz
chromium_src-e61a6220ca4341f7eafac6dc3aacaa6f80a89896.tar.bz2
Remove ServiceDiscoveryClient* from PrivetHTTPAsynchronousFactoryImpl interface
PrivetHTTPAsynchronousFactoryImpl can use ServiceDiscoverySharedClient::GetInstance. Also we don't use this for testing, so we can simplify interface. BUG=461504 Review URL: https://codereview.chromium.org/959503003 Cr-Commit-Position: refs/heads/master@{#318013}
Diffstat (limited to 'chrome/browser/local_discovery')
-rw-r--r--chrome/browser/local_discovery/privet_http_asynchronous_factory.cc4
-rw-r--r--chrome/browser/local_discovery/privet_http_asynchronous_factory.h2
-rw-r--r--chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.cc20
-rw-r--r--chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.h8
-rw-r--r--chrome/browser/local_discovery/privet_local_printer_lister.cc2
-rw-r--r--chrome/browser/local_discovery/privet_local_printer_lister_unittest.cc9
-rw-r--r--chrome/browser/local_discovery/privet_notifications.cc2
7 files changed, 19 insertions, 28 deletions
diff --git a/chrome/browser/local_discovery/privet_http_asynchronous_factory.cc b/chrome/browser/local_discovery/privet_http_asynchronous_factory.cc
index 786c98b..ab2ade2 100644
--- a/chrome/browser/local_discovery/privet_http_asynchronous_factory.cc
+++ b/chrome/browser/local_discovery/privet_http_asynchronous_factory.cc
@@ -15,7 +15,6 @@ namespace local_discovery {
// static
scoped_ptr<PrivetHTTPAsynchronousFactory>
PrivetHTTPAsynchronousFactory::CreateInstance(
- ServiceDiscoveryClient* service_discovery_client,
net::URLRequestContextGetter* request_context) {
#if defined(OS_MACOSX)
return make_scoped_ptr<PrivetHTTPAsynchronousFactory>(
@@ -23,8 +22,7 @@ PrivetHTTPAsynchronousFactory::CreateInstance(
#else
return make_scoped_ptr<PrivetHTTPAsynchronousFactory>(
- new PrivetHTTPAsynchronousFactoryImpl(service_discovery_client,
- request_context));
+ new PrivetHTTPAsynchronousFactoryImpl(request_context));
#endif
}
diff --git a/chrome/browser/local_discovery/privet_http_asynchronous_factory.h b/chrome/browser/local_discovery/privet_http_asynchronous_factory.h
index 3882081..656a946 100644
--- a/chrome/browser/local_discovery/privet_http_asynchronous_factory.h
+++ b/chrome/browser/local_discovery/privet_http_asynchronous_factory.h
@@ -18,7 +18,6 @@ class URLRequestContextGetter;
namespace local_discovery {
class PrivetHTTPClient;
-class ServiceDiscoveryClient;
class PrivetHTTPResolution {
public:
@@ -34,7 +33,6 @@ class PrivetHTTPAsynchronousFactory {
virtual ~PrivetHTTPAsynchronousFactory() {}
static scoped_ptr<PrivetHTTPAsynchronousFactory> CreateInstance(
- ServiceDiscoveryClient* service_discovery_client,
net::URLRequestContextGetter* request_context);
virtual scoped_ptr<PrivetHTTPResolution> CreatePrivetHTTP(
diff --git a/chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.cc b/chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.cc
index 0bfa23a..8a961aa 100644
--- a/chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.cc
+++ b/chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.cc
@@ -8,6 +8,7 @@
#include "base/command_line.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/local_discovery/privet_http_impl.h"
+#include "chrome/browser/local_discovery/service_discovery_shared_client.h"
#include "chrome/common/chrome_switches.h"
namespace local_discovery {
@@ -28,10 +29,8 @@ std::string IPAddressToHostString(const net::IPAddressNumber& address) {
} // namespace
PrivetHTTPAsynchronousFactoryImpl::PrivetHTTPAsynchronousFactoryImpl(
- ServiceDiscoveryClient* service_discovery_client,
net::URLRequestContextGetter* request_context)
- : service_discovery_client_(service_discovery_client),
- request_context_(request_context) {
+ : request_context_(request_context) {
}
PrivetHTTPAsynchronousFactoryImpl::~PrivetHTTPAsynchronousFactoryImpl() {
@@ -43,33 +42,28 @@ PrivetHTTPAsynchronousFactoryImpl::CreatePrivetHTTP(
const net::HostPortPair& address,
const ResultCallback& callback) {
return scoped_ptr<PrivetHTTPResolution>(
- new ResolutionImpl(name,
- address,
- callback,
- service_discovery_client_,
- request_context_.get()));
+ new ResolutionImpl(name, address, callback, request_context_.get()));
}
PrivetHTTPAsynchronousFactoryImpl::ResolutionImpl::ResolutionImpl(
const std::string& name,
const net::HostPortPair& address,
const ResultCallback& callback,
- ServiceDiscoveryClient* service_discovery_client,
net::URLRequestContextGetter* request_context)
: name_(name),
hostport_(address),
callback_(callback),
request_context_(request_context) {
- net::AddressFamily address_family = net::ADDRESS_FAMILY_UNSPECIFIED;
+ service_discovery_client_ = ServiceDiscoverySharedClient::GetInstance();
+ net::AddressFamily address_family = net::ADDRESS_FAMILY_UNSPECIFIED;
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kPrivetIPv6Only)) {
address_family = net::ADDRESS_FAMILY_IPV6;
}
- resolver_ = service_discovery_client->CreateLocalDomainResolver(
- address.host(),
- address_family,
+ resolver_ = service_discovery_client_->CreateLocalDomainResolver(
+ address.host(), address_family,
base::Bind(&ResolutionImpl::ResolveComplete, base::Unretained(this)));
}
diff --git a/chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.h b/chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.h
index 10cda8c..243e775 100644
--- a/chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.h
+++ b/chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.h
@@ -11,10 +11,11 @@
namespace local_discovery {
+class ServiceDiscoverySharedClient;
+
class PrivetHTTPAsynchronousFactoryImpl : public PrivetHTTPAsynchronousFactory {
public:
- PrivetHTTPAsynchronousFactoryImpl(
- ServiceDiscoveryClient* service_discovery_client,
+ explicit PrivetHTTPAsynchronousFactoryImpl(
net::URLRequestContextGetter* request_context);
~PrivetHTTPAsynchronousFactoryImpl() override;
@@ -29,7 +30,6 @@ class PrivetHTTPAsynchronousFactoryImpl : public PrivetHTTPAsynchronousFactory {
ResolutionImpl(const std::string& name,
const net::HostPortPair& address,
const ResultCallback& callback,
- ServiceDiscoveryClient* service_discovery_client,
net::URLRequestContextGetter* request_context);
~ResolutionImpl() override;
@@ -46,9 +46,9 @@ class PrivetHTTPAsynchronousFactoryImpl : public PrivetHTTPAsynchronousFactory {
net::HostPortPair hostport_;
ResultCallback callback_;
scoped_refptr<net::URLRequestContextGetter> request_context_;
+ scoped_refptr<ServiceDiscoverySharedClient> service_discovery_client_;
};
- ServiceDiscoveryClient* service_discovery_client_;
scoped_refptr<net::URLRequestContextGetter> request_context_;
};
diff --git a/chrome/browser/local_discovery/privet_local_printer_lister.cc b/chrome/browser/local_discovery/privet_local_printer_lister.cc
index f9ffb43..ef5ebc2 100644
--- a/chrome/browser/local_discovery/privet_local_printer_lister.cc
+++ b/chrome/browser/local_discovery/privet_local_printer_lister.cc
@@ -31,7 +31,7 @@ PrivetLocalPrinterLister::PrivetLocalPrinterLister(
privet_lister_.reset(
new PrivetDeviceListerImpl(service_discovery_client, this));
privet_http_factory_ = PrivetHTTPAsynchronousFactory::CreateInstance(
- service_discovery_client, request_context);
+ request_context);
}
PrivetLocalPrinterLister::~PrivetLocalPrinterLister() {
diff --git a/chrome/browser/local_discovery/privet_local_printer_lister_unittest.cc b/chrome/browser/local_discovery/privet_local_printer_lister_unittest.cc
index 35b6541..b6893aa 100644
--- a/chrome/browser/local_discovery/privet_local_printer_lister_unittest.cc
+++ b/chrome/browser/local_discovery/privet_local_printer_lister_unittest.cc
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/message_loop/message_loop.h"
#include "chrome/browser/local_discovery/privet_local_printer_lister.h"
+
+#include "base/run_loop.h"
#include "chrome/browser/local_discovery/test_service_discovery_client.h"
+#include "content/public/test/test_browser_thread_bundle.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_request_test_util.h"
-
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -137,7 +138,7 @@ class PrivetLocalPrinterListerTest : public testing::Test {
void SimulateReceive(const uint8* packet, size_t size) {
test_service_discovery_client_->SimulateReceive(packet, size);
- message_loop_.RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
}
void ExpectAnyPacket() {
@@ -146,7 +147,7 @@ class PrivetLocalPrinterListerTest : public testing::Test {
}
protected:
- base::MessageLoop message_loop_;
+ content::TestBrowserThreadBundle test_thread_bundle;
scoped_refptr<TestServiceDiscoveryClient> test_service_discovery_client_;
scoped_refptr<net::TestURLRequestContextGetter> url_request_context_;
scoped_ptr<PrivetLocalPrinterLister> local_printer_lister_;
diff --git a/chrome/browser/local_discovery/privet_notifications.cc b/chrome/browser/local_discovery/privet_notifications.cc
index a6f19c4..cd02d669 100644
--- a/chrome/browser/local_discovery/privet_notifications.cc
+++ b/chrome/browser/local_discovery/privet_notifications.cc
@@ -351,7 +351,7 @@ void PrivetNotificationService::StartLister() {
scoped_ptr<PrivetHTTPAsynchronousFactory> http_factory(
PrivetHTTPAsynchronousFactory::CreateInstance(
- service_discovery_client_.get(), profile_->GetRequestContext()));
+ profile_->GetRequestContext()));
privet_notifications_listener_.reset(new PrivetNotificationsListener(
http_factory.Pass(), this));