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

Unified Diff: services/http_server/http_server_factory_impl.h

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_apptest.cc ('k') | services/http_server/http_server_factory_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/http_server/http_server_factory_impl.h
diff --git a/services/http_server/http_server_factory_impl.h b/services/http_server/http_server_factory_impl.h
index d1ee1d7916f520ad38de13fe43466bdd267983b9..93e55d487a139025c32ce2abeab9f1a0e6d49f0d 100644
--- a/services/http_server/http_server_factory_impl.h
+++ b/services/http_server/http_server_factory_impl.h
@@ -5,11 +5,14 @@
#ifndef SERVICES_HTTP_SERVER_HTTP_SERVER_FACTORY_IMPL_H_
#define SERVICES_HTTP_SERVER_HTTP_SERVER_FACTORY_IMPL_H_
+#include <algorithm>
#include <map>
#include <set>
+#include <vector>
#include "mojo/common/weak_binding_set.h"
#include "mojo/public/cpp/bindings/interface_request.h"
+#include "mojo/services/network/public/interfaces/net_address.mojom.h"
#include "services/http_server/public/http_server_factory.mojom.h"
namespace mojo {
@@ -28,18 +31,24 @@ class HttpServerFactoryImpl : public HttpServerFactory {
void AddBinding(mojo::InterfaceRequest<HttpServerFactory> request);
// The server impl calls back here when the last of its clients disconnects.
- void DeleteServer(HttpServerImpl* server, uint16_t port);
+ void DeleteServer(HttpServerImpl* server,
+ mojo::NetAddress* requested_address);
private:
+ // Servers that were requested with non-zero port are stored in a map and we
+ // allow multiple clients to connect to them. We use a pair of the IP address
+ // and the port as a lookup key.
+ typedef std::pair<std::vector<uint8_t>, uint16_t> ServerKey;
+
+ ServerKey GetServerKey(mojo::NetAddress* local_address);
+
// HttpServerFactory:
void CreateHttpServer(mojo::InterfaceRequest<HttpServer> server_request,
- uint16_t port) override;
+ mojo::NetAddressPtr local_address) override;
mojo::WeakBindingSet<HttpServerFactory> bindings_;
- // Servers that were requested with non-zero port are stored in a map and we
- // allow multiple clients to connect to them.
- std::map<uint16_t, HttpServerImpl*> port_indicated_servers_;
+ std::map<ServerKey, HttpServerImpl*> port_indicated_servers_;
// Servers that were requested with port = 0 (pick any) are not available to
// other clients.
« no previous file with comments | « services/http_server/http_server_apptest.cc ('k') | services/http_server/http_server_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698