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 #ifndef MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_ | 5 #ifndef MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_ |
6 #define MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_ | 6 #define MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "mojo/services/network/public/interfaces/http_connection.mojom.h" | 13 #include "mojo/services/network/public/interfaces/http_connection.mojom.h" |
14 #include "mojo/services/network/public/interfaces/http_message.mojom.h" | 14 #include "mojo/services/network/public/interfaces/http_message.mojom.h" |
15 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" | |
17 | 16 |
18 namespace net { | 17 namespace net { |
19 class HttpServerRequestInfo; | 18 class HttpServerRequestInfo; |
20 } | 19 } |
21 | 20 |
22 namespace mojo { | 21 namespace mojo { |
23 | 22 |
24 class HttpServerImpl; | 23 class HttpServerImpl; |
25 | 24 |
26 class HttpConnectionImpl : public HttpConnection, | 25 class HttpConnectionImpl : public HttpConnection { |
27 public ErrorHandler { | |
28 public: | 26 public: |
29 // |server| must outlive this object. | 27 // |server| must outlive this object. |
30 HttpConnectionImpl(int connection_id, | 28 HttpConnectionImpl(int connection_id, |
31 HttpServerImpl* server, | 29 HttpServerImpl* server, |
32 HttpConnectionDelegatePtr delegate, | 30 HttpConnectionDelegatePtr delegate, |
33 HttpConnectionPtr* connection); | 31 HttpConnectionPtr* connection); |
34 | 32 |
35 ~HttpConnectionImpl() override; | 33 ~HttpConnectionImpl() override; |
36 | 34 |
37 void OnReceivedHttpRequest(const net::HttpServerRequestInfo& info); | 35 void OnReceivedHttpRequest(const net::HttpServerRequestInfo& info); |
38 void OnReceivedWebSocketRequest(const net::HttpServerRequestInfo& info); | 36 void OnReceivedWebSocketRequest(const net::HttpServerRequestInfo& info); |
39 void OnReceivedWebSocketMessage(const std::string& data); | 37 void OnReceivedWebSocketMessage(const std::string& data); |
40 | 38 |
41 private: | 39 private: |
42 class SimpleDataPipeReader; | 40 class SimpleDataPipeReader; |
43 class WebSocketImpl; | 41 class WebSocketImpl; |
44 | 42 |
45 // HttpConnection implementation. | 43 // HttpConnection implementation. |
46 void SetSendBufferSize(uint32_t size, | 44 void SetSendBufferSize(uint32_t size, |
47 const SetSendBufferSizeCallback& callback) override; | 45 const SetSendBufferSizeCallback& callback) override; |
48 void SetReceiveBufferSize( | 46 void SetReceiveBufferSize( |
49 uint32_t size, | 47 uint32_t size, |
50 const SetReceiveBufferSizeCallback& callback) override; | 48 const SetReceiveBufferSizeCallback& callback) override; |
51 | 49 |
52 // ErrorHandler implementation. | |
53 void OnConnectionError() override; | |
54 | |
55 void OnFinishedReadingResponseBody(HttpResponsePtr response_ptr, | 50 void OnFinishedReadingResponseBody(HttpResponsePtr response_ptr, |
56 SimpleDataPipeReader* reader, | 51 SimpleDataPipeReader* reader, |
57 scoped_ptr<std::string> body); | 52 scoped_ptr<std::string> body); |
58 | 53 |
59 void Close(); | 54 void Close(); |
60 | 55 |
61 // Checks whether Close() has been called. | 56 // Checks whether Close() has been called. |
62 bool IsClosing() const { return !binding_.is_bound(); } | 57 bool IsClosing() const { return !binding_.is_bound(); } |
63 | 58 |
64 // Checks whether all wrap-up work has been done during the closing process. | 59 // Checks whether all wrap-up work has been done during the closing process. |
(...skipping 11 matching lines...) Expand all Loading... |
76 std::set<SimpleDataPipeReader*> response_body_readers_; | 71 std::set<SimpleDataPipeReader*> response_body_readers_; |
77 | 72 |
78 scoped_ptr<WebSocketImpl> web_socket_; | 73 scoped_ptr<WebSocketImpl> web_socket_; |
79 | 74 |
80 DISALLOW_COPY_AND_ASSIGN(HttpConnectionImpl); | 75 DISALLOW_COPY_AND_ASSIGN(HttpConnectionImpl); |
81 }; | 76 }; |
82 | 77 |
83 } // namespace mojo | 78 } // namespace mojo |
84 | 79 |
85 #endif // MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_ | 80 #endif // MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_ |
OLD | NEW |