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

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

Issue 2868036: Brushed up listen socket: (Closed)
Patch Set: Lint. 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
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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // Ownership of response objects is by default assumed to be outside 281 // Ownership of response objects is by default assumed to be outside
282 // of the SimpleWebServer class. 282 // of the SimpleWebServer class.
283 // However, if the caller doesn't wish to maintain a list of response objects 283 // However, if the caller doesn't wish to maintain a list of response objects
284 // but rather let this class hold the only references to those objects, 284 // but rather let this class hold the only references to those objects,
285 // the caller can call this method to delete the objects as part of 285 // the caller can call this method to delete the objects as part of
286 // the cleanup process. 286 // the cleanup process.
287 void DeleteAllResponses(); 287 void DeleteAllResponses();
288 288
289 // ListenSocketDelegate overrides. 289 // ListenSocketDelegate overrides.
290 virtual void DidAccept(ListenSocket* server, ListenSocket* connection); 290 virtual void DidAccept(ListenSocket* server, ListenSocket* connection);
291 virtual void DidRead(ListenSocket* connection, const std::string& data); 291 virtual void DidRead(ListenSocket* connection, const char* data, int len);
292 virtual void DidClose(ListenSocket* sock); 292 virtual void DidClose(ListenSocket* sock);
293 293
294 const ConnectionList& connections() const { 294 const ConnectionList& connections() const {
295 return connections_; 295 return connections_;
296 } 296 }
297 297
298 protected: 298 protected:
299 class QuitResponse : public SimpleResponse { 299 class QuitResponse : public SimpleResponse {
300 public: 300 public:
301 QuitResponse() 301 QuitResponse()
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 virtual ~HTTPTestServer(); 374 virtual ~HTTPTestServer();
375 // HTTP GET request is received. Override in derived classes. 375 // HTTP GET request is received. Override in derived classes.
376 // |connection| can be used to send the response. 376 // |connection| can be used to send the response.
377 virtual void Get(ConfigurableConnection* connection, 377 virtual void Get(ConfigurableConnection* connection,
378 const std::string& path, const Request& r) = 0; 378 const std::string& path, const Request& r) = 0;
379 // HTTP POST request is received. Override in derived classes. 379 // HTTP POST request is received. Override in derived classes.
380 // |connection| can be used to send the response 380 // |connection| can be used to send the response
381 virtual void Post(ConfigurableConnection* connection, 381 virtual void Post(ConfigurableConnection* connection,
382 const std::string& path, const Request& r) = 0; 382 const std::string& path, const Request& r) = 0;
383 383
384 private: 384 private:
385 typedef std::list<scoped_refptr<ConfigurableConnection> > ConnectionList; 385 typedef std::list<scoped_refptr<ConfigurableConnection> > ConnectionList;
386 ConnectionList::iterator FindConnection(const ListenSocket* socket); 386 ConnectionList::iterator FindConnection(const ListenSocket* socket);
387 scoped_refptr<ConfigurableConnection> ConnectionFromSocket( 387 scoped_refptr<ConfigurableConnection> ConnectionFromSocket(
388 const ListenSocket* socket); 388 const ListenSocket* socket);
389 389
390 // ListenSocketDelegate overrides. 390 // ListenSocketDelegate overrides.
391 virtual void DidAccept(ListenSocket* server, ListenSocket* socket); 391 virtual void DidAccept(ListenSocket* server, ListenSocket* socket);
392 virtual void DidRead(ListenSocket* socket, const std::string& data); 392 virtual void DidRead(ListenSocket* socket, const char* data, int len);
393 virtual void DidClose(ListenSocket* socket); 393 virtual void DidClose(ListenSocket* socket);
394 394
395 scoped_refptr<ListenSocket> server_; 395 scoped_refptr<ListenSocket> server_;
396 ConnectionList connection_list_; 396 ConnectionList connection_list_;
397 DISALLOW_COPY_AND_ASSIGN(HTTPTestServer); 397 DISALLOW_COPY_AND_ASSIGN(HTTPTestServer);
398 }; 398 };
399 399
400 400
401 } // namespace test_server 401 } // namespace test_server
402 402
403 #endif // CHROME_FRAME_TEST_TEST_SERVER_H_ 403 #endif // CHROME_FRAME_TEST_TEST_SERVER_H_
OLDNEW
« no previous file with comments | « chrome/browser/debugger/devtools_remote_listen_socket_unittest.cc ('k') | chrome_frame/test/test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698