summaryrefslogtreecommitdiffstats
path: root/net/url_request/url_request_unittest.h
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-14 22:37:35 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-14 22:37:35 +0000
commitb89290213d94169f8293f9bd7668550975281d45 (patch)
tree951d1218d6c660cd3cf94c9c67b8c9f193a536a8 /net/url_request/url_request_unittest.h
parent0c6da50c299be943b4c04a3953e0931734af7eaf (diff)
downloadchromium_src-b89290213d94169f8293f9bd7668550975281d45.zip
chromium_src-b89290213d94169f8293f9bd7668550975281d45.tar.gz
chromium_src-b89290213d94169f8293f9bd7668550975281d45.tar.bz2
Speed up net_unittests a bit by re-using launched test server.
On POSIX it makes the server fork a separate process for each request for better test isolation. Starting with just few tests to limit impact of an eventual breakage. The results are promising. TEST=none BUG=none Review URL: http://codereview.chromium.org/164522 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23481 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request_unittest.h')
-rw-r--r--net/url_request/url_request_unittest.h29
1 files changed, 25 insertions, 4 deletions
diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h
index 03d678d..24714ce 100644
--- a/net/url_request/url_request_unittest.h
+++ b/net/url_request/url_request_unittest.h
@@ -242,6 +242,9 @@ class BaseTestServer : public base::RefCounted<BaseTestServer> {
: launcher_(connection_attempts, connection_timeout) { }
public:
+ void set_forking(bool forking) {
+ launcher_.set_forking(forking);
+ }
// Used with e.g. HTTPTestServer::SendQuit()
bool WaitToFinish(int milliseconds) {
@@ -380,6 +383,18 @@ class HTTPTestServer : public BaseTestServer {
loop, 10, 1000);
}
+ static scoped_refptr<HTTPTestServer> CreateForkingServer(
+ const std::wstring& document_root) {
+ scoped_refptr<HTTPTestServer> test_server =
+ new HTTPTestServer(10, 1000);
+ test_server->set_forking(true);
+ FilePath no_cert;
+ FilePath docroot = FilePath::FromWStringHack(document_root);
+ if (!StartTestServer(test_server.get(), docroot, no_cert, std::wstring()))
+ return NULL;
+ return test_server;
+ }
+
static scoped_refptr<HTTPTestServer> CreateServerWithFileRootURL(
const std::wstring& document_root,
const std::wstring& file_root_url,
@@ -391,14 +406,20 @@ class HTTPTestServer : public BaseTestServer {
test_server->loop_ = loop;
FilePath no_cert;
FilePath docroot = FilePath::FromWStringHack(document_root);
- if (!test_server->Start(net::TestServerLauncher::ProtoHTTP,
- kDefaultHostName, kHTTPDefaultPort,
- docroot, no_cert, file_root_url)) {
+ if (!StartTestServer(test_server.get(), docroot, no_cert, file_root_url))
return NULL;
- }
return test_server;
}
+ static bool StartTestServer(HTTPTestServer* server,
+ const FilePath& document_root,
+ const FilePath& cert_path,
+ const std::wstring& file_root_url) {
+ return server->Start(net::TestServerLauncher::ProtoHTTP, kDefaultHostName,
+ kHTTPDefaultPort, document_root, cert_path,
+ file_root_url, "", "");
+ }
+
// A subclass may wish to send the request in a different manner
virtual bool MakeGETRequest(const std::string& page_name) {
const GURL& url = TestServerPage(page_name);