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

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

Issue 1227373002: Roll mojo SDK to 734c6e1652ff2f3b696e441722838f453f4f9b42 (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Follow review Created 5 years, 5 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
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_SERVER_IMPL_H_ 5 #ifndef MOJO_SERVICES_NETWORK_HTTP_SERVER_IMPL_H_
6 #define MOJO_SERVICES_NETWORK_HTTP_SERVER_IMPL_H_ 6 #define MOJO_SERVICES_NETWORK_HTTP_SERVER_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "mojo/services/network/public/interfaces/http_server.mojom.h" 13 #include "mojo/services/network/public/interfaces/http_server.mojom.h"
14 #include "mojo/services/network/public/interfaces/net_address.mojom.h" 14 #include "mojo/services/network/public/interfaces/net_address.mojom.h"
15 #include "net/server/http_server.h" 15 #include "net/server/http_server.h"
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
17 16
18 namespace net { 17 namespace net {
19 class HttpServer; 18 class HttpServer;
20 } 19 }
21 20
22 namespace mojo { 21 namespace mojo {
23 22
24 class HttpConnectionImpl; 23 class HttpConnectionImpl;
25 24
26 class HttpServerImpl : public net::HttpServer::Delegate, 25 class HttpServerImpl : public net::HttpServer::Delegate {
27 public ErrorHandler {
28 public: 26 public:
29 static void Create( 27 static void Create(
30 NetAddressPtr local_address, 28 NetAddressPtr local_address,
31 HttpServerDelegatePtr delegate, 29 HttpServerDelegatePtr delegate,
32 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback); 30 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback);
33 31
34 net::HttpServer* server() { return server_.get(); } 32 net::HttpServer* server() { return server_.get(); }
35 33
36 private: 34 private:
37 // The lifetime of the returned HttpServerImpl object is bound to that of 35 // The lifetime of the returned HttpServerImpl object is bound to that of
38 // |delegate|'s underlying pipe. The object will self-destruct when it is 36 // |delegate|'s underlying pipe. The object will self-destruct when it is
39 // notified that |delegate|'s pipe is closed. Deleting the object directly 37 // notified that |delegate|'s pipe is closed. Deleting the object directly
40 // before that is okay, too. 38 // before that is okay, too.
41 explicit HttpServerImpl(HttpServerDelegatePtr delegate); 39 explicit HttpServerImpl(HttpServerDelegatePtr delegate);
42 ~HttpServerImpl() override; 40 virtual ~HttpServerImpl();
43 41
44 int Start(NetAddressPtr local_address); 42 int Start(NetAddressPtr local_address);
45 NetAddressPtr GetLocalAddress() const; 43 NetAddressPtr GetLocalAddress() const;
46 44
47 // net::HttpServer::Delegate implementation. 45 // net::HttpServer::Delegate implementation.
48 void OnConnect(int connection_id) override; 46 void OnConnect(int connection_id) override;
49 void OnHttpRequest(int connection_id, 47 void OnHttpRequest(int connection_id,
50 const net::HttpServerRequestInfo& info) override; 48 const net::HttpServerRequestInfo& info) override;
51 void OnWebSocketRequest(int connection_id, 49 void OnWebSocketRequest(int connection_id,
52 const net::HttpServerRequestInfo& info) override; 50 const net::HttpServerRequestInfo& info) override;
53 void OnWebSocketMessage(int connection_id, const std::string& data) override; 51 void OnWebSocketMessage(int connection_id, const std::string& data) override;
54 void OnClose(int connection_id) override; 52 void OnClose(int connection_id) override;
55 53
56 // ErrorHandler implementation.
57 void OnConnectionError() override;
58
59 HttpServerDelegatePtr delegate_; 54 HttpServerDelegatePtr delegate_;
60 scoped_ptr<net::HttpServer> server_; 55 scoped_ptr<net::HttpServer> server_;
61 56
62 std::map<int, linked_ptr<HttpConnectionImpl>> connections_; 57 std::map<int, linked_ptr<HttpConnectionImpl>> connections_;
63 58
64 DISALLOW_COPY_AND_ASSIGN(HttpServerImpl); 59 DISALLOW_COPY_AND_ASSIGN(HttpServerImpl);
65 }; 60 };
66 61
67 } // namespace mojo 62 } // namespace mojo
68 63
69 #endif // MOJO_SERVICES_NETWORK_HTTP_SERVER_IMPL_H_ 64 #endif // MOJO_SERVICES_NETWORK_HTTP_SERVER_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/services/network/http_connection_impl.cc ('k') | mojo/services/network/http_server_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698