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

Side by Side Diff: mojo/services/network/http_connection_impl.h

Issue 1144843002: Mojo service implementation for HTTP server - part 3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase & resolve Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | mojo/services/network/http_connection_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
17 17
18 namespace net { 18 namespace net {
19 class HttpServerRequestInfo; 19 class HttpServerRequestInfo;
20 } 20 }
21 21
22 namespace mojo { 22 namespace mojo {
23 23
24 class HttpServerImpl; 24 class HttpServerImpl;
25 25
26 class HttpConnectionImpl : public HttpConnection, 26 class HttpConnectionImpl : public HttpConnection,
27 public ErrorHandler { 27 public ErrorHandler {
28 public: 28 public:
29 // |owner| must outlive this object. 29 // |server| must outlive this object.
30 HttpConnectionImpl(int connection_id, 30 HttpConnectionImpl(int connection_id,
31 HttpServerImpl* owner, 31 HttpServerImpl* server,
32 HttpConnectionDelegatePtr delegate, 32 HttpConnectionDelegatePtr delegate,
33 HttpConnectionPtr* connection); 33 HttpConnectionPtr* connection);
34 34
35 ~HttpConnectionImpl() override; 35 ~HttpConnectionImpl() override;
36 36
37 void OnReceivedHttpRequest(const net::HttpServerRequestInfo& info); 37 void OnReceivedHttpRequest(const net::HttpServerRequestInfo& info);
38 void OnReceivedWebSocketRequest(const net::HttpServerRequestInfo& info); 38 void OnReceivedWebSocketRequest(const net::HttpServerRequestInfo& info);
39 void OnReceivedWebSocketMessage(const std::string& data); 39 void OnReceivedWebSocketMessage(const std::string& data);
40 40
41 private: 41 private:
42 class SimpleDataPipeReader; 42 class SimpleDataPipeReader;
43 class WebSocketImpl;
43 44
44 // HttpConnection implementation. 45 // HttpConnection implementation.
45 void SetSendBufferSize(uint32_t size, 46 void SetSendBufferSize(uint32_t size,
46 const SetSendBufferSizeCallback& callback) override; 47 const SetSendBufferSizeCallback& callback) override;
47 void SetReceiveBufferSize( 48 void SetReceiveBufferSize(
48 uint32_t size, 49 uint32_t size,
49 const SetReceiveBufferSizeCallback& callback) override; 50 const SetReceiveBufferSizeCallback& callback) override;
50 51
51 // ErrorHandler implementation. 52 // ErrorHandler implementation.
52 void OnConnectionError() override; 53 void OnConnectionError() override;
53 54
54 void OnFinishedReadingResponseBody(HttpResponsePtr response_ptr, 55 void OnFinishedReadingResponseBody(HttpResponsePtr response_ptr,
55 SimpleDataPipeReader* reader, 56 SimpleDataPipeReader* reader,
56 scoped_ptr<std::string> body); 57 scoped_ptr<std::string> body);
57 58
58 bool EncounteredConnectionError() const { 59 void Close();
59 return !binding_.is_bound() || !delegate_; 60
60 } 61 // Checks whether Close() has been called.
62 bool IsClosing() const { return !binding_.is_bound(); }
63
64 // Checks whether all wrap-up work has been done during the closing process.
65 // If yes, notifies the owner, which may result in the destruction of this
66 // object.
67 void NotifyOwnerCloseIfAllDone();
68
69 void OnWebSocketClosed();
61 70
62 const int connection_id_; 71 const int connection_id_;
63 HttpServerImpl* const owner_; 72 HttpServerImpl* const server_;
64 HttpConnectionDelegatePtr delegate_; 73 HttpConnectionDelegatePtr delegate_;
65 Binding<HttpConnection> binding_; 74 Binding<HttpConnection> binding_;
66 // Owns its elements. 75 // Owns its elements.
67 std::set<SimpleDataPipeReader*> response_body_readers_; 76 std::set<SimpleDataPipeReader*> response_body_readers_;
68 77
78 scoped_ptr<WebSocketImpl> web_socket_;
79
69 DISALLOW_COPY_AND_ASSIGN(HttpConnectionImpl); 80 DISALLOW_COPY_AND_ASSIGN(HttpConnectionImpl);
70 }; 81 };
71 82
72 } // namespace mojo 83 } // namespace mojo
73 84
74 #endif // MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_ 85 #endif // MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/services/network/http_connection_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698