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

Unified Diff: services/http_server/http_server_impl.cc

Issue 953513002: http_server: accept full NetAddress in CreateHttpServer. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Address Ben's comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/http_server/http_server_impl.h ('k') | services/http_server/public/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/http_server/http_server_impl.cc
diff --git a/services/http_server/http_server_impl.cc b/services/http_server/http_server_impl.cc
index 4313d423cd07895ef7d4c66271a38f1d57667f74..ba40741ddeade0dd3aae353dfb94bb59ecddad14 100644
--- a/services/http_server/http_server_impl.cc
+++ b/services/http_server/http_server_impl.cc
@@ -17,9 +17,9 @@ namespace http_server {
HttpServerImpl::HttpServerImpl(mojo::ApplicationImpl* app,
HttpServerFactoryImpl* factory,
- uint16_t port)
+ mojo::NetAddressPtr requested_local_address)
: factory_(factory),
- requested_port_(port),
+ requested_local_address_(requested_local_address.Pass()),
assigned_port_(0),
weak_ptr_factory_(this) {
app->ConnectToService("mojo:network_service", &network_service_);
@@ -63,7 +63,7 @@ void HttpServerImpl::OnConnectionError() {
if (handlers_.empty()) {
// The call deregisters the server from the factory and deletes |this|.
- factory_->DeleteServer(this, requested_port_);
+ factory_->DeleteServer(this, requested_local_address_.get());
}
}
@@ -75,7 +75,6 @@ void HttpServerImpl::OnSocketBound(mojo::NetworkErrorPtr err,
}
assigned_port_ = bound_address->ipv4->port;
- DCHECK(requested_port_ == 0u || requested_port_ == assigned_port_);
for (GetPortCallback& port_callback : pending_get_port_callbacks_) {
port_callback.Run(assigned_port_);
@@ -129,21 +128,11 @@ void HttpServerImpl::WaitForNextConnection() {
}
void HttpServerImpl::Start() {
- mojo::NetAddressPtr net_address(mojo::NetAddress::New());
- net_address->family = mojo::NET_ADDRESS_FAMILY_IPV4;
- net_address->ipv4 = mojo::NetAddressIPv4::New();
- net_address->ipv4->addr.resize(4);
- net_address->ipv4->addr[0] = 0;
- net_address->ipv4->addr[1] = 0;
- net_address->ipv4->addr[2] = 0;
- net_address->ipv4->addr[3] = 0;
- net_address->ipv4->port = requested_port_;
-
// Note that we can start using the proxies right away even thought the
// callbacks have not been called yet. If a previous step fails, they'll
// all fail.
network_service_->CreateTCPBoundSocket(
- net_address.Pass(), GetProxy(&bound_socket_),
+ requested_local_address_.Clone(), GetProxy(&bound_socket_),
base::Bind(&HttpServerImpl::OnSocketBound, base::Unretained(this)));
bound_socket_->StartListening(
GetProxy(&server_socket_),
« no previous file with comments | « services/http_server/http_server_impl.h ('k') | services/http_server/public/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698