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

Side by Side Diff: chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.cc

Issue 948283005: Added PrivetHTTPResolution::Start for service name only (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_start
Patch Set: Wed Feb 25 15:43:16 PST 2015 Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.h " 5 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory_impl.h "
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/local_discovery/privet_http_impl.h" 10 #include "chrome/browser/local_discovery/privet_http_impl.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 PrivetHTTPAsynchronousFactoryImpl::ResolutionImpl::~ResolutionImpl() { 53 PrivetHTTPAsynchronousFactoryImpl::ResolutionImpl::~ResolutionImpl() {
54 } 54 }
55 55
56 const std::string& 56 const std::string&
57 PrivetHTTPAsynchronousFactoryImpl::ResolutionImpl::GetName() { 57 PrivetHTTPAsynchronousFactoryImpl::ResolutionImpl::GetName() {
58 return name_; 58 return name_;
59 } 59 }
60 60
61 void PrivetHTTPAsynchronousFactoryImpl::ResolutionImpl::Start( 61 void PrivetHTTPAsynchronousFactoryImpl::ResolutionImpl::Start(
62 const ResultCallback& callback) {
63 service_resolver_ = service_discovery_client_->CreateServiceResolver(
64 name_, base::Bind(&ResolutionImpl::ServiceResolveComplete,
65 base::Unretained(this), callback));
66 service_resolver_->StartResolving();
67 }
68
69 void PrivetHTTPAsynchronousFactoryImpl::ResolutionImpl::ServiceResolveComplete(
70 const ResultCallback& callback,
71 ServiceResolver::RequestStatus result,
72 const ServiceDescription& description) {
73 if (result != ServiceResolver::STATUS_SUCCESS)
74 return callback.Run(scoped_ptr<PrivetHTTPClient>());
75
76 Start(description.address, callback);
77 }
78
79 void PrivetHTTPAsynchronousFactoryImpl::ResolutionImpl::Start(
62 const net::HostPortPair& address, 80 const net::HostPortPair& address,
63 const ResultCallback& callback) { 81 const ResultCallback& callback) {
64 #if defined(OS_MACOSX) 82 #if defined(OS_MACOSX)
65 // MAC already has IP there. 83 // MAC already has IP there.
66 callback.Run(scoped_ptr<PrivetHTTPClient>( 84 callback.Run(scoped_ptr<PrivetHTTPClient>(
67 new PrivetHTTPClientImpl(name_, address, request_context_.get()))); 85 new PrivetHTTPClientImpl(name_, address, request_context_.get())));
68 #else // OS_MACOSX 86 #else // OS_MACOSX
69 net::AddressFamily address_family = net::ADDRESS_FAMILY_UNSPECIFIED; 87 net::AddressFamily address_family = net::ADDRESS_FAMILY_UNSPECIFIED;
70 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 88 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
71 switches::kPrivetIPv6Only)) { 89 switches::kPrivetIPv6Only)) {
(...skipping 25 matching lines...) Expand all
97 115
98 DCHECK(!address.empty()); 116 DCHECK(!address.empty());
99 117
100 net::HostPortPair new_address = 118 net::HostPortPair new_address =
101 net::HostPortPair(IPAddressToHostString(address), port); 119 net::HostPortPair(IPAddressToHostString(address), port);
102 callback.Run(scoped_ptr<PrivetHTTPClient>( 120 callback.Run(scoped_ptr<PrivetHTTPClient>(
103 new PrivetHTTPClientImpl(name_, new_address, request_context_.get()))); 121 new PrivetHTTPClientImpl(name_, new_address, request_context_.get())));
104 } 122 }
105 123
106 } // namespace local_discovery 124 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698