| 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 virtual void OnConnect(int connection_id) override {} |
| 145 virtual void OnHttpRequest( | 145 virtual 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 virtual 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 virtual void OnWebSocketMessage(int connection_id, |
| 152 const std::string& data) OVERRIDE; | 152 const std::string& data) override; |
| 153 virtual void OnClose(int connection_id) OVERRIDE; | 153 virtual void OnClose(int connection_id) override; |
| 154 | 154 |
| 155 // Sends error as response. Invoked when request method is invalid. | 155 // Sends error as response. Invoked when request method is invalid. |
| 156 void ReportInvalidMethod(int connection_id); | 156 void ReportInvalidMethod(int connection_id); |
| 157 | 157 |
| 158 // Returns |true| if |request| should be done with correct |method|. | 158 // Returns |true| if |request| should be done with correct |method|. |
| 159 // Otherwise sends |Invalid method| error. | 159 // Otherwise sends |Invalid method| error. |
| 160 // Also checks support of |request| by this server. | 160 // Also checks support of |request| by this server. |
| 161 bool ValidateRequestMethod(int connection_id, | 161 bool ValidateRequestMethod(int connection_id, |
| 162 const std::string& request, | 162 const std::string& request, |
| 163 const std::string& method); | 163 const std::string& method); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 | 206 |
| 207 // Contains encapsulated object for listening for requests. | 207 // Contains encapsulated object for listening for requests. |
| 208 scoped_ptr<net::HttpServer> server_; | 208 scoped_ptr<net::HttpServer> server_; |
| 209 | 209 |
| 210 Delegate* delegate_; | 210 Delegate* delegate_; |
| 211 | 211 |
| 212 DISALLOW_COPY_AND_ASSIGN(PrivetHttpServer); | 212 DISALLOW_COPY_AND_ASSIGN(PrivetHttpServer); |
| 213 }; | 213 }; |
| 214 | 214 |
| 215 #endif // CLOUD_PRINT_GCP20_PROTOTYPE_PRIVET_HTTP_SERVER_H_ | 215 #endif // CLOUD_PRINT_GCP20_PROTOTYPE_PRIVET_HTTP_SERVER_H_ |
| OLD | NEW |