OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CLOUD_PRINT_GCP20_PROTOTYPE_PRIVET_HTTP_SERVER_H_ | 5 #ifndef CLOUD_PRINT_GCP20_PROTOTYPE_PRIVET_HTTP_SERVER_H_ |
6 #define CLOUD_PRINT_GCP20_PROTOTYPE_PRIVET_HTTP_SERVER_H_ | 6 #define CLOUD_PRINT_GCP20_PROTOTYPE_PRIVET_HTTP_SERVER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 virtual ~PrivetHttpServer(); | 134 virtual ~PrivetHttpServer(); |
135 | 135 |
136 // Starts HTTP server: start listening port |port| for HTTP requests. | 136 // Starts HTTP server: start listening port |port| for HTTP requests. |
137 bool Start(uint16 port); | 137 bool Start(uint16 port); |
138 | 138 |
139 // Stops HTTP server. | 139 // Stops HTTP server. |
140 void Shutdown(); | 140 void Shutdown(); |
141 | 141 |
142 private: | 142 private: |
143 // net::HttpServer::Delegate methods: | 143 // net::HttpServer::Delegate methods: |
144 virtual void OnConnect(int connection_id) override {} | 144 void OnConnect(int connection_id) override {} |
145 virtual void OnHttpRequest( | 145 void OnHttpRequest( |
146 int connection_id, | 146 int connection_id, |
147 const net::HttpServerRequestInfo& info) override; | 147 const net::HttpServerRequestInfo& info) override; |
148 virtual void OnWebSocketRequest( | 148 void OnWebSocketRequest( |
149 int connection_id, | 149 int connection_id, |
150 const net::HttpServerRequestInfo& info) override; | 150 const net::HttpServerRequestInfo& info) override; |
151 virtual void OnWebSocketMessage(int connection_id, | 151 void OnWebSocketMessage(int connection_id, const std::string& data) override; |
152 const std::string& data) override; | 152 void OnClose(int connection_id) override; |
153 virtual void OnClose(int connection_id) override; | |
154 | 153 |
155 // Sends error as response. Invoked when request method is invalid. | 154 // Sends error as response. Invoked when request method is invalid. |
156 void ReportInvalidMethod(int connection_id); | 155 void ReportInvalidMethod(int connection_id); |
157 | 156 |
158 // Returns |true| if |request| should be done with correct |method|. | 157 // Returns |true| if |request| should be done with correct |method|. |
159 // Otherwise sends |Invalid method| error. | 158 // Otherwise sends |Invalid method| error. |
160 // Also checks support of |request| by this server. | 159 // Also checks support of |request| by this server. |
161 bool ValidateRequestMethod(int connection_id, | 160 bool ValidateRequestMethod(int connection_id, |
162 const std::string& request, | 161 const std::string& request, |
163 const std::string& method); | 162 const std::string& method); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 205 |
207 // Contains encapsulated object for listening for requests. | 206 // Contains encapsulated object for listening for requests. |
208 scoped_ptr<net::HttpServer> server_; | 207 scoped_ptr<net::HttpServer> server_; |
209 | 208 |
210 Delegate* delegate_; | 209 Delegate* delegate_; |
211 | 210 |
212 DISALLOW_COPY_AND_ASSIGN(PrivetHttpServer); | 211 DISALLOW_COPY_AND_ASSIGN(PrivetHttpServer); |
213 }; | 212 }; |
214 | 213 |
215 #endif // CLOUD_PRINT_GCP20_PROTOTYPE_PRIVET_HTTP_SERVER_H_ | 214 #endif // CLOUD_PRINT_GCP20_PROTOTYPE_PRIVET_HTTP_SERVER_H_ |
OLD | NEW |