OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "mojo/services/network/http_connection_impl.h" |
| 6 |
| 7 #include <limits> |
| 8 |
| 9 #include "mojo/services/network/http_server_impl.h" |
| 10 #include "mojo/services/network/net_adapters.h" |
| 11 #include "net/base/net_errors.h" |
| 12 #include "net/server/http_server.h" |
| 13 #include "net/server/http_server_request_info.h" |
| 14 |
| 15 namespace mojo { |
| 16 |
| 17 HttpConnectionImpl::HttpConnectionImpl(int connection_id, |
| 18 HttpServerImpl* owner, |
| 19 HttpConnectionDelegatePtr delegate, |
| 20 HttpConnectionPtr* connection) |
| 21 : connection_id_(connection_id), |
| 22 owner_(owner), |
| 23 delegate_(delegate.Pass()), |
| 24 binding_(this, connection) { |
| 25 binding_.set_error_handler(this); |
| 26 delegate_.set_error_handler(this); |
| 27 } |
| 28 |
| 29 HttpConnectionImpl::~HttpConnectionImpl() {} |
| 30 |
| 31 void HttpConnectionImpl::OnReceivedHttpRequest( |
| 32 const net::HttpServerRequestInfo& info) { |
| 33 // TODO(yzshen): implement it. |
| 34 } |
| 35 |
| 36 void HttpConnectionImpl::OnReceivedWebSocketRequest( |
| 37 const net::HttpServerRequestInfo& info) { |
| 38 // TODO(yzshen): implement it. |
| 39 } |
| 40 |
| 41 void HttpConnectionImpl::OnReceivedWebSocketMessage(const std::string& data) { |
| 42 // TODO(yzshen): implement it. |
| 43 } |
| 44 |
| 45 void HttpConnectionImpl::SetSendBufferSize( |
| 46 uint32_t size, |
| 47 const SetSendBufferSizeCallback& callback) { |
| 48 if (size > static_cast<uint32_t>(std::numeric_limits<int32_t>::max())) |
| 49 size = std::numeric_limits<int32_t>::max(); |
| 50 |
| 51 owner_->server()->SetSendBufferSize( |
| 52 connection_id_, static_cast<int32_t>(size)); |
| 53 callback.Run(MakeNetworkError(net::OK)); |
| 54 } |
| 55 |
| 56 void HttpConnectionImpl::SetReceiveBufferSize( |
| 57 uint32_t size, |
| 58 const SetReceiveBufferSizeCallback& callback) { |
| 59 if (size > static_cast<uint32_t>(std::numeric_limits<int32_t>::max())) |
| 60 size = std::numeric_limits<int32_t>::max(); |
| 61 |
| 62 owner_->server()->SetReceiveBufferSize( |
| 63 connection_id_, static_cast<int32_t>(size)); |
| 64 callback.Run(MakeNetworkError(net::OK)); |
| 65 } |
| 66 |
| 67 void HttpConnectionImpl::OnConnectionError() { |
| 68 // The proxy side of |binding_| or the impl side of |delegate_| has closed the |
| 69 // pipe. The connection is not needed anymore. |
| 70 owner_->server()->Close(connection_id_); |
| 71 } |
| 72 |
| 73 } // namespace mojo |
OLD | NEW |