| OLD | NEW |
| 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 "services/http_server/http_server_impl.h" | 5 #include "services/http_server/http_server_impl.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <winsock2.h> | 10 #include <winsock2.h> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "third_party/re2/re2/re2.h" | 23 #include "third_party/re2/re2/re2.h" |
| 24 | 24 |
| 25 namespace http_server { | 25 namespace http_server { |
| 26 | 26 |
| 27 HttpServerImpl::HttpServerImpl(mojo::ApplicationImpl* app) | 27 HttpServerImpl::HttpServerImpl(mojo::ApplicationImpl* app) |
| 28 : weak_ptr_factory_(this) { | 28 : weak_ptr_factory_(this) { |
| 29 app->ConnectToService("mojo:network_service", &network_service_); | 29 app->ConnectToService("mojo:network_service", &network_service_); |
| 30 Start(); | 30 Start(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 HttpServerImpl::~HttpServerImpl() { |
| 34 } |
| 35 |
| 33 void HttpServerImpl::AddBinding(mojo::InterfaceRequest<HttpServer> request) { | 36 void HttpServerImpl::AddBinding(mojo::InterfaceRequest<HttpServer> request) { |
| 34 bindings_.AddBinding(this, request.Pass()); | 37 bindings_.AddBinding(this, request.Pass()); |
| 35 } | 38 } |
| 36 | 39 |
| 37 void HttpServerImpl::SetHandler(const mojo::String& path, | 40 void HttpServerImpl::SetHandler(const mojo::String& path, |
| 38 HttpHandlerPtr http_handler, | 41 HttpHandlerPtr http_handler, |
| 39 const mojo::Callback<void(bool)>& callback) { | 42 const mojo::Callback<void(bool)>& callback) { |
| 40 for (const auto& handler : handlers_) { | 43 for (const auto& handler : handlers_) { |
| 41 if (handler->pattern->pattern() == path) | 44 if (handler->pattern->pattern() == path) |
| 42 callback.Run(false); | 45 callback.Run(false); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 void HttpServerImpl::OnResponse(Connection* connection, | 155 void HttpServerImpl::OnResponse(Connection* connection, |
| 153 HttpResponsePtr response) { | 156 HttpResponsePtr response) { |
| 154 connection->SendResponse(response.Pass()); | 157 connection->SendResponse(response.Pass()); |
| 155 } | 158 } |
| 156 | 159 |
| 157 HttpServerImpl::Handler::Handler(const std::string& pattern, | 160 HttpServerImpl::Handler::Handler(const std::string& pattern, |
| 158 HttpHandlerPtr http_handler) | 161 HttpHandlerPtr http_handler) |
| 159 : pattern(new RE2(pattern.c_str())), http_handler(http_handler.Pass()) { | 162 : pattern(new RE2(pattern.c_str())), http_handler(http_handler.Pass()) { |
| 160 } | 163 } |
| 161 | 164 |
| 165 HttpServerImpl::Handler::~Handler() { |
| 166 } |
| 167 |
| 162 } // namespace http_server | 168 } // namespace http_server |
| OLD | NEW |