| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/http_server/http_server_factory_impl.h" | 5 #include "services/http_server/http_server_factory_impl.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "mojo/services/http_server/interfaces/http_server.mojom.h" | 8 #include "mojo/services/http_server/interfaces/http_server.mojom.h" |
| 9 #include "services/http_server/http_server_impl.h" | 9 #include "services/http_server/http_server_impl.h" |
| 10 | 10 |
| 11 namespace http_server { | 11 namespace http_server { |
| 12 | 12 |
| 13 HttpServerFactoryImpl::HttpServerFactoryImpl(mojo::ApplicationImpl* app) { | 13 HttpServerFactoryImpl::HttpServerFactoryImpl(mojo::Shell* shell) |
| 14 app_ = app; | 14 : shell_(shell) {} |
| 15 } | |
| 16 | 15 |
| 17 HttpServerFactoryImpl::~HttpServerFactoryImpl() { | 16 HttpServerFactoryImpl::~HttpServerFactoryImpl() { |
| 18 // Free the http servers. | 17 // Free the http servers. |
| 19 STLDeleteContainerPairSecondPointers(port_indicated_servers_.begin(), | 18 STLDeleteContainerPairSecondPointers(port_indicated_servers_.begin(), |
| 20 port_indicated_servers_.end()); | 19 port_indicated_servers_.end()); |
| 21 STLDeleteContainerPointers(port_any_servers_.begin(), | 20 STLDeleteContainerPointers(port_any_servers_.begin(), |
| 22 port_any_servers_.end()); | 21 port_any_servers_.end()); |
| 23 } | 22 } |
| 24 | 23 |
| 25 void HttpServerFactoryImpl::AddBinding( | 24 void HttpServerFactoryImpl::AddBinding( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 local_address->ipv4->addr[1] = 0; | 69 local_address->ipv4->addr[1] = 0; |
| 71 local_address->ipv4->addr[2] = 0; | 70 local_address->ipv4->addr[2] = 0; |
| 72 local_address->ipv4->addr[3] = 0; | 71 local_address->ipv4->addr[3] = 0; |
| 73 local_address->ipv4->port = 0; | 72 local_address->ipv4->port = 0; |
| 74 } | 73 } |
| 75 ServerKey key = GetServerKey(local_address.get()); | 74 ServerKey key = GetServerKey(local_address.get()); |
| 76 | 75 |
| 77 if (key.second) { // If the port is non-zero. | 76 if (key.second) { // If the port is non-zero. |
| 78 if (!port_indicated_servers_.count(key)) { | 77 if (!port_indicated_servers_.count(key)) { |
| 79 port_indicated_servers_[key] = | 78 port_indicated_servers_[key] = |
| 80 new HttpServerImpl(app_, this, local_address.Pass()); | 79 new HttpServerImpl(shell_, this, local_address.Pass()); |
| 81 } | 80 } |
| 82 port_indicated_servers_[key]->AddBinding(server_request.Pass()); | 81 port_indicated_servers_[key]->AddBinding(server_request.Pass()); |
| 83 } else { | 82 } else { |
| 84 HttpServerImpl* server = | 83 HttpServerImpl* server = |
| 85 new HttpServerImpl(app_, this, local_address.Pass()); | 84 new HttpServerImpl(shell_, this, local_address.Pass()); |
| 86 server->AddBinding(server_request.Pass()); | 85 server->AddBinding(server_request.Pass()); |
| 87 port_any_servers_.insert(server); | 86 port_any_servers_.insert(server); |
| 88 } | 87 } |
| 89 } | 88 } |
| 90 | 89 |
| 91 } // namespace http_server | 90 } // namespace http_server |
| OLD | NEW |