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

Side by Side Diff: chrome_frame/test/test_server.h

Issue 2822016: [chrome_frame] Refactor/merge IE no interference tests with other mock event ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome_frame/test/test_mock_with_web_server.cc ('k') | chrome_frame/test/test_server.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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 int cur_pos_; 363 int cur_pos_;
364 364
365 DISALLOW_COPY_AND_ASSIGN(ConfigurableConnection); 365 DISALLOW_COPY_AND_ASSIGN(ConfigurableConnection);
366 }; 366 };
367 367
368 // Simple class used as a base class for mock webserver. 368 // Simple class used as a base class for mock webserver.
369 // Override virtual functions Get and Post and use passed ConfigurableConnection 369 // Override virtual functions Get and Post and use passed ConfigurableConnection
370 // instance to send the response. 370 // instance to send the response.
371 class HTTPTestServer : public ListenSocket::ListenSocketDelegate { 371 class HTTPTestServer : public ListenSocket::ListenSocketDelegate {
372 public: 372 public:
373 explicit HTTPTestServer(int port, const char* address); 373 explicit HTTPTestServer(int port, const std::wstring& address,
374 FilePath root_dir);
374 virtual ~HTTPTestServer(); 375 virtual ~HTTPTestServer();
376
375 // HTTP GET request is received. Override in derived classes. 377 // HTTP GET request is received. Override in derived classes.
376 // |connection| can be used to send the response. 378 // |connection| can be used to send the response.
377 virtual void Get(ConfigurableConnection* connection, 379 virtual void Get(ConfigurableConnection* connection,
378 const std::string& path, const Request& r) = 0; 380 const std::wstring& path, const Request& r) = 0;
381
379 // HTTP POST request is received. Override in derived classes. 382 // HTTP POST request is received. Override in derived classes.
380 // |connection| can be used to send the response 383 // |connection| can be used to send the response
381 virtual void Post(ConfigurableConnection* connection, 384 virtual void Post(ConfigurableConnection* connection,
382 const std::string& path, const Request& r) = 0; 385 const std::wstring& path, const Request& r) = 0;
386
387 // Return the appropriate url with the specified path for this server.
388 std::wstring Resolve(const std::wstring& path);
389
390 FilePath root_dir() { return root_dir_; }
391
392 protected:
393 int port_;
394 std::wstring address_;
395 FilePath root_dir_;
383 396
384 private: 397 private:
385 typedef std::list<scoped_refptr<ConfigurableConnection> > ConnectionList; 398 typedef std::list<scoped_refptr<ConfigurableConnection> > ConnectionList;
386 ConnectionList::iterator FindConnection(const ListenSocket* socket); 399 ConnectionList::iterator FindConnection(const ListenSocket* socket);
387 scoped_refptr<ConfigurableConnection> ConnectionFromSocket( 400 scoped_refptr<ConfigurableConnection> ConnectionFromSocket(
388 const ListenSocket* socket); 401 const ListenSocket* socket);
389 402
390 // ListenSocketDelegate overrides. 403 // ListenSocketDelegate overrides.
391 virtual void DidAccept(ListenSocket* server, ListenSocket* socket); 404 virtual void DidAccept(ListenSocket* server, ListenSocket* socket);
392 virtual void DidRead(ListenSocket* socket, const char* data, int len); 405 virtual void DidRead(ListenSocket* socket, const char* data, int len);
393 virtual void DidClose(ListenSocket* socket); 406 virtual void DidClose(ListenSocket* socket);
394 407
395 scoped_refptr<ListenSocket> server_; 408 scoped_refptr<ListenSocket> server_;
396 ConnectionList connection_list_; 409 ConnectionList connection_list_;
410
397 DISALLOW_COPY_AND_ASSIGN(HTTPTestServer); 411 DISALLOW_COPY_AND_ASSIGN(HTTPTestServer);
398 }; 412 };
399 413
400
401 } // namespace test_server 414 } // namespace test_server
402 415
403 #endif // CHROME_FRAME_TEST_TEST_SERVER_H_ 416 #endif // CHROME_FRAME_TEST_TEST_SERVER_H_
OLDNEW
« no previous file with comments | « chrome_frame/test/test_mock_with_web_server.cc ('k') | chrome_frame/test/test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698