| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_FRAME_TEST_TEST_SERVER_H_ | 5 #ifndef CHROME_FRAME_TEST_TEST_SERVER_H_ |
| 6 #define CHROME_FRAME_TEST_TEST_SERVER_H_ | 6 #define CHROME_FRAME_TEST_TEST_SERVER_H_ |
| 7 | 7 |
| 8 // Implementation of an HTTP server for tests. | 8 // Implementation of an HTTP server for tests. |
| 9 // To instantiate the server, make sure you have a message loop on the | 9 // To instantiate the server, make sure you have a message loop on the |
| 10 // current thread and then create an instance of the SimpleWebServer class. | 10 // current thread and then create an instance of the SimpleWebServer class. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // To implement a custom response object (e.g. to match against a request | 32 // To implement a custom response object (e.g. to match against a request |
| 33 // based on some data, serve up dynamic content or take some action on the | 33 // based on some data, serve up dynamic content or take some action on the |
| 34 // server), just inherit from one of the response classes or directly from the | 34 // server), just inherit from one of the response classes or directly from the |
| 35 // Response interface and add your response object to the server's list of | 35 // Response interface and add your response object to the server's list of |
| 36 // response objects. | 36 // response objects. |
| 37 | 37 |
| 38 #include <list> | 38 #include <list> |
| 39 #include <string> | 39 #include <string> |
| 40 | 40 |
| 41 #include "base/basictypes.h" | 41 #include "base/basictypes.h" |
| 42 #include "base/file_util.h" | 42 #include "base/file_path.h" |
| 43 #include "base/files/memory_mapped_file.h" |
| 43 #include "base/message_loop.h" | 44 #include "base/message_loop.h" |
| 44 #include "net/base/stream_listen_socket.h" | 45 #include "net/base/stream_listen_socket.h" |
| 45 | 46 |
| 46 namespace test_server { | 47 namespace test_server { |
| 47 | 48 |
| 48 class Request { | 49 class Request { |
| 49 public: | 50 public: |
| 50 Request() : content_length_(0) { | 51 Request() : content_length_(0) { |
| 51 } | 52 } |
| 52 | 53 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 FileResponse(const char* request_path, const base::FilePath& file_path) | 245 FileResponse(const char* request_path, const base::FilePath& file_path) |
| 245 : ResponseForPath(request_path), file_path_(file_path) { | 246 : ResponseForPath(request_path), file_path_(file_path) { |
| 246 } | 247 } |
| 247 | 248 |
| 248 virtual bool GetContentType(std::string* content_type) const; | 249 virtual bool GetContentType(std::string* content_type) const; |
| 249 virtual void WriteContents(net::StreamListenSocket* socket) const; | 250 virtual void WriteContents(net::StreamListenSocket* socket) const; |
| 250 virtual size_t ContentLength() const; | 251 virtual size_t ContentLength() const; |
| 251 | 252 |
| 252 protected: | 253 protected: |
| 253 base::FilePath file_path_; | 254 base::FilePath file_path_; |
| 254 mutable scoped_ptr<file_util::MemoryMappedFile> file_; | 255 mutable scoped_ptr<base::MemoryMappedFile> file_; |
| 255 | 256 |
| 256 private: | 257 private: |
| 257 DISALLOW_COPY_AND_ASSIGN(FileResponse); | 258 DISALLOW_COPY_AND_ASSIGN(FileResponse); |
| 258 }; | 259 }; |
| 259 | 260 |
| 260 // Returns a 302 (temporary redirect) to redirect the client from a path | 261 // Returns a 302 (temporary redirect) to redirect the client from a path |
| 261 // on the test server to a different URL. | 262 // on the test server to a different URL. |
| 262 class RedirectResponse : public ResponseForPath { | 263 class RedirectResponse : public ResponseForPath { |
| 263 public: | 264 public: |
| 264 RedirectResponse(const char* request_path, const std::string& redirect_url) | 265 RedirectResponse(const char* request_path, const std::string& redirect_url) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 439 |
| 439 scoped_refptr<net::StreamListenSocket> server_; | 440 scoped_refptr<net::StreamListenSocket> server_; |
| 440 ConnectionList connection_list_; | 441 ConnectionList connection_list_; |
| 441 | 442 |
| 442 DISALLOW_COPY_AND_ASSIGN(HTTPTestServer); | 443 DISALLOW_COPY_AND_ASSIGN(HTTPTestServer); |
| 443 }; | 444 }; |
| 444 | 445 |
| 445 } // namespace test_server | 446 } // namespace test_server |
| 446 | 447 |
| 447 #endif // CHROME_FRAME_TEST_TEST_SERVER_H_ | 448 #endif // CHROME_FRAME_TEST_TEST_SERVER_H_ |
| OLD | NEW |