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

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

Issue 1134883002: Mojo service implementation for HTTP server - part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
OLDNEW
(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 #ifndef MOJO_SERVICES_NETWORK_HTTP_SERVER_IMPL_H_
6 #define MOJO_SERVICES_NETWORK_HTTP_SERVER_IMPL_H_
7
8 #include <map>
9
10 #include "base/macros.h"
11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "mojo/services/network/public/interfaces/http_server.mojom.h"
14 #include "mojo/services/network/public/interfaces/net_address.mojom.h"
15 #include "net/server/http_server.h"
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
17
18 namespace net {
19 class HttpServer;
20 }
21
22 namespace mojo {
23
24 class HttpConnectionImpl;
25
26 class HttpServerImpl : public net::HttpServer::Delegate,
27 public ErrorHandler {
28 public:
29 // The lifetime of the returned HttpServerImpl object is bound to that of
30 // |delegate|'s underlying pipe. The object will self-destruct when
31 // |delegate|'s pipe is closed. However, it is safe to delete the object
32 // directly as well.
33 static HttpServerImpl* Create(HttpServerDelegatePtr delegate);
jam 2015/05/12 15:50:23 why is there a static factory method which just ca
yzshen1 2015/05/12 16:02:04 Making the ctor private has be benefit of preventi
34 ~HttpServerImpl() override;
35
36 int Start(NetAddressPtr local_address);
37
38 NetAddressPtr GetLocalAddress() const;
39
40 net::HttpServer* server() { return server_.get(); }
41
42 private:
43 explicit HttpServerImpl(HttpServerDelegatePtr delegate);
44
45 // net::HttpServer::Delegate implementation.
46 void OnConnect(int connection_id) override;
47 void OnHttpRequest(int connection_id,
48 const net::HttpServerRequestInfo& info) override;
49 void OnWebSocketRequest(int connection_id,
50 const net::HttpServerRequestInfo& info) override;
51 void OnWebSocketMessage(int connection_id, const std::string& data) override;
52 void OnClose(int connection_id) override;
53
54 // ErrorHandler implementation.
55 void OnConnectionError() override;
56
57 HttpServerDelegatePtr delegate_;
58 scoped_ptr<net::HttpServer> server_;
59
60 std::map<int, linked_ptr<HttpConnectionImpl>> connections_;
61
62 DISALLOW_COPY_AND_ASSIGN(HttpServerImpl);
63 };
64
65 } // namespace mojo
66
67 #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