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

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

Issue 1139673003: Make Mandoline shut down cleanly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 | « mojo/services/network/cookie_store_impl.cc ('k') | mojo/services/network/http_server_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_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/application/app_lifetime_helper.h"
13 #include "mojo/services/network/public/interfaces/http_server.mojom.h" 14 #include "mojo/services/network/public/interfaces/http_server.mojom.h"
14 #include "mojo/services/network/public/interfaces/net_address.mojom.h" 15 #include "mojo/services/network/public/interfaces/net_address.mojom.h"
15 #include "net/server/http_server.h" 16 #include "net/server/http_server.h"
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" 17 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
17 18
18 namespace net { 19 namespace net {
19 class HttpServer; 20 class HttpServer;
20 } 21 }
21 22
22 namespace mojo { 23 namespace mojo {
23 24
24 class HttpConnectionImpl; 25 class HttpConnectionImpl;
25 26
26 class HttpServerImpl : public net::HttpServer::Delegate, 27 class HttpServerImpl : public net::HttpServer::Delegate,
27 public ErrorHandler { 28 public ErrorHandler {
28 public: 29 public:
29 static void Create( 30 static void Create(
30 NetAddressPtr local_address, 31 NetAddressPtr local_address,
31 HttpServerDelegatePtr delegate, 32 HttpServerDelegatePtr delegate,
33 scoped_ptr<mojo::AppRefCount> app_refcount,
32 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback); 34 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback);
33 35
34 net::HttpServer* server() { return server_.get(); } 36 net::HttpServer* server() { return server_.get(); }
35 37
36 private: 38 private:
37 // The lifetime of the returned HttpServerImpl object is bound to that of 39 // 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 40 // |delegate|'s underlying pipe. The object will self-destruct when it is
39 // notified that |delegate|'s pipe is closed. Deleting the object directly 41 // notified that |delegate|'s pipe is closed. Deleting the object directly
40 // before that is okay, too. 42 // before that is okay, too.
41 explicit HttpServerImpl(HttpServerDelegatePtr delegate); 43 HttpServerImpl(HttpServerDelegatePtr delegate,
44 scoped_ptr<mojo::AppRefCount> app_refcount);
42 ~HttpServerImpl() override; 45 ~HttpServerImpl() override;
43 46
44 int Start(NetAddressPtr local_address); 47 int Start(NetAddressPtr local_address);
45 NetAddressPtr GetLocalAddress() const; 48 NetAddressPtr GetLocalAddress() const;
46 49
47 // net::HttpServer::Delegate implementation. 50 // net::HttpServer::Delegate implementation.
48 void OnConnect(int connection_id) override; 51 void OnConnect(int connection_id) override;
49 void OnHttpRequest(int connection_id, 52 void OnHttpRequest(int connection_id,
50 const net::HttpServerRequestInfo& info) override; 53 const net::HttpServerRequestInfo& info) override;
51 void OnWebSocketRequest(int connection_id, 54 void OnWebSocketRequest(int connection_id,
52 const net::HttpServerRequestInfo& info) override; 55 const net::HttpServerRequestInfo& info) override;
53 void OnWebSocketMessage(int connection_id, const std::string& data) override; 56 void OnWebSocketMessage(int connection_id, const std::string& data) override;
54 void OnClose(int connection_id) override; 57 void OnClose(int connection_id) override;
55 58
56 // ErrorHandler implementation. 59 // ErrorHandler implementation.
57 void OnConnectionError() override; 60 void OnConnectionError() override;
58 61
59 HttpServerDelegatePtr delegate_; 62 HttpServerDelegatePtr delegate_;
63 scoped_ptr<mojo::AppRefCount> app_refcount_;
60 scoped_ptr<net::HttpServer> server_; 64 scoped_ptr<net::HttpServer> server_;
61 65
62 std::map<int, linked_ptr<HttpConnectionImpl>> connections_; 66 std::map<int, linked_ptr<HttpConnectionImpl>> connections_;
63 67
64 DISALLOW_COPY_AND_ASSIGN(HttpServerImpl); 68 DISALLOW_COPY_AND_ASSIGN(HttpServerImpl);
65 }; 69 };
66 70
67 } // namespace mojo 71 } // namespace mojo
68 72
69 #endif // MOJO_SERVICES_NETWORK_HTTP_SERVER_IMPL_H_ 73 #endif // MOJO_SERVICES_NETWORK_HTTP_SERVER_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/services/network/cookie_store_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