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

Unified Diff: chrome_frame/test/test_server.h

Issue 10868027: Attempt to fix flake in FullTabModeIE_TestPostReissue by avoiding loopback address. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another try with net tests Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome_frame/test/net/fake_external_tab.cc ('k') | chrome_frame/test/test_server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/test/test_server.h
diff --git a/chrome_frame/test/test_server.h b/chrome_frame/test/test_server.h
index 01ce4bb20afe7339ba8352a3f6e649a61f67d281..04da1265556ba8a278f9f7b1cb2e907ba10e8409 100644
--- a/chrome_frame/test/test_server.h
+++ b/chrome_frame/test/test_server.h
@@ -15,7 +15,7 @@
// all derived from the Response interface.
//
// Here's a simple example that starts a web server that can serve up
-// a single document (http://localhost:1337/foo).
+// a single document (http://<server.host()>:1337/foo).
// All other requests will get a 404.
//
// MessageLoopForUI loop;
@@ -24,7 +24,7 @@
// test_server.AddResponse(&document);
// loop.MessageLoop::Run();
//
-// To close the web server, just go to http://localhost:1337/quit.
+// To close the web server, just go to http://<server.host()>:1337/quit.
//
// All Response classes count how many times they have been accessed. Just
// call Response::accessed().
@@ -282,7 +282,12 @@ typedef std::list<Connection*> ConnectionList;
// has a message loop.
class SimpleWebServer : public net::StreamListenSocket::Delegate {
public:
+ // Constructs a server listening at the given port on a local IPv4 address.
+ // An address on a NIC is preferred over the loopback address.
explicit SimpleWebServer(int port);
+
+ // Constructs a server listening at the given address:port.
+ SimpleWebServer(const std::string& address, int port);
virtual ~SimpleWebServer();
void AddResponse(Response* response);
@@ -303,6 +308,12 @@ class SimpleWebServer : public net::StreamListenSocket::Delegate {
int len);
virtual void DidClose(net::StreamListenSocket* sock);
+ // Returns the host on which the server is listening. This is suitable for
+ // use in URLs for resources served by this instance.
+ const std::string& host() const {
+ return host_;
+ }
+
const ConnectionList& connections() const {
return connections_;
}
@@ -323,13 +334,14 @@ class SimpleWebServer : public net::StreamListenSocket::Delegate {
Response* FindResponse(const Request& request) const;
Connection* FindConnection(const net::StreamListenSocket* socket) const;
- protected:
+ std::string host_;
scoped_refptr<net::StreamListenSocket> server_;
ConnectionList connections_;
std::list<Response*> responses_;
QuitResponse quit_;
private:
+ void Construct(const std::string& address, int port);
DISALLOW_COPY_AND_ASSIGN(SimpleWebServer);
};
« no previous file with comments | « chrome_frame/test/net/fake_external_tab.cc ('k') | chrome_frame/test/test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698