diff options
9 files changed, 21 insertions, 32 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)); diff --git a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc index 33c9451..0c9ac49 100644 --- a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc +++ b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.cc @@ -171,7 +171,7 @@ void LocalDiscoveryUIHandler::HandleStart(const base::ListValue* args) { privet_lister_.reset( new PrivetDeviceListerImpl(service_discovery_client_.get(), this)); privet_http_factory_ = PrivetHTTPAsynchronousFactory::CreateInstance( - service_discovery_client_.get(), profile->GetRequestContext()); + profile->GetRequestContext()); SigninManagerBase* signin_manager = SigninManagerFactory::GetInstance()->GetForProfile(profile); @@ -211,8 +211,7 @@ void LocalDiscoveryUIHandler::HandleRegisterDevice( if (found->second.version < kCloudDevicesPrivetVersion) { privet_resolution_ = privet_http_factory_->CreatePrivetHTTP( - device, - found->second.address, + device, found->second.address, base::Bind(&LocalDiscoveryUIHandler::StartRegisterHTTP, base::Unretained(this))); privet_resolution_->Start(); diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc index e465e03..92a4342 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc @@ -1621,7 +1621,6 @@ bool PrintPreviewHandler::CreatePrivetHTTP( privet_http_factory_ = local_discovery::PrivetHTTPAsynchronousFactory::CreateInstance( - service_discovery_client_.get(), Profile::FromWebUI(web_ui())->GetRequestContext()); privet_http_resolution_ = privet_http_factory_->CreatePrivetHTTP( name, device_description->address, callback); |