diff options
author | samuong <samuong@chromium.org> | 2014-09-25 21:15:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-26 04:15:42 +0000 |
commit | 0b4d9b95e0cb553624b994df899ee4010425985e (patch) | |
tree | 382d227f6533cc50610bdc12429f3df0e7a9cc06 | |
parent | da1f537d23c875d49c73731b0880c67a32d27b09 (diff) | |
download | chromium_src-0b4d9b95e0cb553624b994df899ee4010425985e.zip chromium_src-0b4d9b95e0cb553624b994df899ee4010425985e.tar.gz chromium_src-0b4d9b95e0cb553624b994df899ee4010425985e.tar.bz2 |
Add net::HttpServer::Delegate::OnConnect() function and set ChromeDriver buffer sizes to 100 MB
BUG=
Review URL: https://codereview.chromium.org/594393002
Cr-Commit-Position: refs/heads/master@{#296881}
-rw-r--r-- | chrome/test/chromedriver/net/net_util_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/test/chromedriver/net/test_http_server.cc | 9 | ||||
-rw-r--r-- | chrome/test/chromedriver/net/test_http_server.h | 3 | ||||
-rw-r--r-- | chrome/test/chromedriver/server/chromedriver_server.cc | 5 | ||||
-rwxr-xr-x | chrome/test/chromedriver/test/run_py_tests.py | 10 | ||||
-rw-r--r-- | cloud_print/gcp20/prototype/privet_http_server.h | 1 | ||||
-rw-r--r-- | content/browser/devtools/devtools_http_handler_impl.h | 1 | ||||
-rw-r--r-- | mojo/spy/websocket_server.h | 1 | ||||
-rw-r--r-- | net/server/http_server.cc | 4 | ||||
-rw-r--r-- | net/server/http_server.h | 1 | ||||
-rw-r--r-- | net/server/http_server_unittest.cc | 30 |
11 files changed, 53 insertions, 14 deletions
diff --git a/chrome/test/chromedriver/net/net_util_unittest.cc b/chrome/test/chromedriver/net/net_util_unittest.cc index dbe41d0..801620d 100644 --- a/chrome/test/chromedriver/net/net_util_unittest.cc +++ b/chrome/test/chromedriver/net/net_util_unittest.cc @@ -70,6 +70,8 @@ class FetchUrlTest : public testing::Test, } // Overridden from net::HttpServer::Delegate: + virtual void OnConnect(int connection_id) OVERRIDE {} + virtual void OnHttpRequest(int connection_id, const net::HttpServerRequestInfo& info) OVERRIDE { switch (response_) { diff --git a/chrome/test/chromedriver/net/test_http_server.cc b/chrome/test/chromedriver/net/test_http_server.cc index f8795cc..6b8a4bc 100644 --- a/chrome/test/chromedriver/net/test_http_server.cc +++ b/chrome/test/chromedriver/net/test_http_server.cc @@ -75,9 +75,7 @@ GURL TestHttpServer::web_socket_url() const { return web_socket_url_; } -void TestHttpServer::OnHttpRequest( - int connection_id, - const net::HttpServerRequestInfo& info) { +void TestHttpServer::OnConnect(int connection_id) { server_->SetSendBufferSize(connection_id, kBufferSize); server_->SetReceiveBufferSize(connection_id, kBufferSize); } @@ -85,9 +83,6 @@ void TestHttpServer::OnHttpRequest( void TestHttpServer::OnWebSocketRequest( int connection_id, const net::HttpServerRequestInfo& info) { - server_->SetSendBufferSize(connection_id, kBufferSize); - server_->SetReceiveBufferSize(connection_id, kBufferSize); - WebSocketRequestAction action; { base::AutoLock lock(action_lock_); @@ -111,8 +106,6 @@ void TestHttpServer::OnWebSocketRequest( void TestHttpServer::OnWebSocketMessage(int connection_id, const std::string& data) { - server_->SetSendBufferSize(connection_id, kBufferSize); - server_->SetReceiveBufferSize(connection_id, kBufferSize); WebSocketMessageAction action; { base::AutoLock lock(action_lock_); diff --git a/chrome/test/chromedriver/net/test_http_server.h b/chrome/test/chromedriver/net/test_http_server.h index 048cd34..70b26a5 100644 --- a/chrome/test/chromedriver/net/test_http_server.h +++ b/chrome/test/chromedriver/net/test_http_server.h @@ -61,8 +61,9 @@ class TestHttpServer : public net::HttpServer::Delegate { GURL web_socket_url() const; // Overridden from net::HttpServer::Delegate: + virtual void OnConnect(int connection_id) OVERRIDE; virtual void OnHttpRequest(int connection_id, - const net::HttpServerRequestInfo& info) OVERRIDE; + const net::HttpServerRequestInfo& info) OVERRIDE {} virtual void OnWebSocketRequest( int connection_id, const net::HttpServerRequestInfo& info) OVERRIDE; diff --git a/chrome/test/chromedriver/server/chromedriver_server.cc b/chrome/test/chromedriver/server/chromedriver_server.cc index f06a7fc..9772540 100644 --- a/chrome/test/chromedriver/server/chromedriver_server.cc +++ b/chrome/test/chromedriver/server/chromedriver_server.cc @@ -38,6 +38,7 @@ namespace { const char* kLocalHostAddress = "127.0.0.1"; +const int kBufferSize = 100 * 1024 * 1024; // 100 MB typedef base::Callback< void(const net::HttpServerRequestInfo&, const HttpResponseSenderFunc&)> @@ -64,6 +65,10 @@ class HttpServer : public net::HttpServer::Delegate { } // Overridden from net::HttpServer::Delegate: + virtual void OnConnect(int connection_id) OVERRIDE { + server_->SetSendBufferSize(connection_id, kBufferSize); + server_->SetReceiveBufferSize(connection_id, kBufferSize); + } virtual void OnHttpRequest(int connection_id, const net::HttpServerRequestInfo& info) OVERRIDE { handle_request_func_.Run( diff --git a/chrome/test/chromedriver/test/run_py_tests.py b/chrome/test/chromedriver/test/run_py_tests.py index 2b106a6..1738f43 100755 --- a/chrome/test/chromedriver/test/run_py_tests.py +++ b/chrome/test/chromedriver/test/run_py_tests.py @@ -715,6 +715,16 @@ class ChromeDriverTest(ChromeDriverBaseTest): def testMobileEmulationDisabledByDefault(self): self.assertFalse(self._driver.capabilities['mobileEmulationEnabled']) + def testChromeDriverSendLargeData(self): + script = 's = ""; for (i = 0; i < 10e6; i++) s += "0"; return s;' + lots_of_data = self._driver.ExecuteScript(script) + self.assertEquals('0'.zfill(int(10e6)), lots_of_data) + + def testChromeDriverRecieveAndSendLargeData(self): + lots_of_data = '1'.zfill(int(10e6)) + result = self._driver.ExecuteScript('return "%s"' % lots_of_data) + self.assertEquals(lots_of_data, result) + class ChromeDriverAndroidTest(ChromeDriverBaseTest): """End to end tests for Android-specific tests.""" diff --git a/cloud_print/gcp20/prototype/privet_http_server.h b/cloud_print/gcp20/prototype/privet_http_server.h index 6cb14d10..5a3a2fe 100644 --- a/cloud_print/gcp20/prototype/privet_http_server.h +++ b/cloud_print/gcp20/prototype/privet_http_server.h @@ -141,6 +141,7 @@ class PrivetHttpServer: public net::HttpServer::Delegate { private: // net::HttpServer::Delegate methods: + virtual void OnConnect(int connection_id) OVERRIDE {} virtual void OnHttpRequest( int connection_id, const net::HttpServerRequestInfo& info) OVERRIDE; diff --git a/content/browser/devtools/devtools_http_handler_impl.h b/content/browser/devtools/devtools_http_handler_impl.h index 0276c3f..9f32bf7 100644 --- a/content/browser/devtools/devtools_http_handler_impl.h +++ b/content/browser/devtools/devtools_http_handler_impl.h @@ -56,6 +56,7 @@ class DevToolsHttpHandlerImpl virtual GURL GetFrontendURL() OVERRIDE; // net::HttpServer::Delegate implementation. + virtual void OnConnect(int connection_id) OVERRIDE {} virtual void OnHttpRequest(int connection_id, const net::HttpServerRequestInfo& info) OVERRIDE; virtual void OnWebSocketRequest( diff --git a/mojo/spy/websocket_server.h b/mojo/spy/websocket_server.h index eb685c7..272d682 100644 --- a/mojo/spy/websocket_server.h +++ b/mojo/spy/websocket_server.h @@ -38,6 +38,7 @@ class WebSocketServer : public net::HttpServer::Delegate, protected: // Overridden from net::HttpServer::Delegate. + virtual void OnConnect(int connection_id) OVERRIDE {} virtual void OnHttpRequest( int connection_id, const net::HttpServerRequestInfo& info) OVERRIDE; diff --git a/net/server/http_server.cc b/net/server/http_server.cc index fb0dab3..6c7ee52 100644 --- a/net/server/http_server.cc +++ b/net/server/http_server.cc @@ -153,7 +153,9 @@ int HttpServer::HandleAcceptResult(int rv) { HttpConnection* connection = new HttpConnection(++last_id_, accepted_socket_.Pass()); id_to_connection_[connection->id()] = connection; - DoReadLoop(connection); + delegate_->OnConnect(connection->id()); + if (!HasClosedConnection(connection)) + DoReadLoop(connection); return OK; } diff --git a/net/server/http_server.h b/net/server/http_server.h index 2ae698b..47214ab 100644 --- a/net/server/http_server.h +++ b/net/server/http_server.h @@ -30,6 +30,7 @@ class HttpServer { // destroy the HttpServer in any of these callbacks. class Delegate { public: + virtual void OnConnect(int connection_id) = 0; virtual void OnHttpRequest(int connection_id, const HttpServerRequestInfo& info) = 0; virtual void OnWebSocketRequest(int connection_id, diff --git a/net/server/http_server_unittest.cc b/net/server/http_server_unittest.cc index 42e5639..216cb03 100644 --- a/net/server/http_server_unittest.cc +++ b/net/server/http_server_unittest.cc @@ -189,6 +189,8 @@ class HttpServerTest : public testing::Test, ASSERT_EQ(OK, server_->GetLocalAddress(&server_address_)); } + virtual void OnConnect(int connection_id) OVERRIDE {} + virtual void OnHttpRequest(int connection_id, const HttpServerRequestInfo& info) OVERRIDE { requests_.push_back(std::make_pair(info, connection_id)); @@ -243,6 +245,8 @@ class HttpServerTest : public testing::Test, size_t quit_after_request_count_; }; +namespace { + class WebSocketTest : public HttpServerTest { virtual void OnHttpRequest(int connection_id, const HttpServerRequestInfo& info) OVERRIDE { @@ -461,8 +465,6 @@ TEST_F(HttpServerTest, SendRaw) { ASSERT_EQ(expected_response, response); } -namespace { - class MockStreamSocket : public StreamSocket { public: MockStreamSocket() @@ -557,8 +559,6 @@ class MockStreamSocket : public StreamSocket { DISALLOW_COPY_AND_ASSIGN(MockStreamSocket); }; -} // namespace - TEST_F(HttpServerTest, RequestWithBodySplitAcrossPackets) { MockStreamSocket* socket = new MockStreamSocket(); HandleAcceptResult(make_scoped_ptr<StreamSocket>(socket)); @@ -619,4 +619,26 @@ TEST_F(HttpServerTest, MultipleRequestsOnSameConnection) { ASSERT_TRUE(EndsWith(response3, "Content for /test3", true)); } +class CloseOnConnectHttpServerTest : public HttpServerTest { + public: + virtual void OnConnect(int connection_id) OVERRIDE { + connection_ids_.push_back(connection_id); + server_->Close(connection_id); + } + + protected: + std::vector<int> connection_ids_; +}; + +TEST_F(CloseOnConnectHttpServerTest, ServerImmediatelyClosesConnection) { + TestHttpClient client; + ASSERT_EQ(OK, client.ConnectAndWait(server_address_)); + client.Send("GET / HTTP/1.1\r\n\r\n"); + ASSERT_FALSE(RunUntilRequestsReceived(1)); + ASSERT_EQ(1ul, connection_ids_.size()); + ASSERT_EQ(0ul, requests_.size()); +} + +} // namespace + } // namespace net |