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

Unified Diff: net/websockets/websocket_throttle_unittest.cc

Issue 12033072: Include destination port for websocket throttling. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix things caught by toyoshim. Created 7 years, 11 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 | « net/websockets/websocket_throttle.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_throttle_unittest.cc
diff --git a/net/websockets/websocket_throttle_unittest.cc b/net/websockets/websocket_throttle_unittest.cc
index ef05c4ce4e629a01db54e80f94f8b324fccf8909..4374e12ddf03b65fb4a8a4f163f3713bf3c37d9e 100644
--- a/net/websockets/websocket_throttle_unittest.cc
+++ b/net/websockets/websocket_throttle_unittest.cc
@@ -32,7 +32,7 @@ namespace net {
class WebSocketThrottleTest : public PlatformTest {
protected:
- IPEndPoint MakeAddr(int a1, int a2, int a3, int a4) {
+ static IPEndPoint MakeAddr(int a1, int a2, int a3, int a4) {
IPAddressNumber ip;
ip.push_back(a1);
ip.push_back(a2);
@@ -305,4 +305,50 @@ TEST_F(WebSocketThrottleTest, NoThrottleForDuplicateAddress) {
MessageLoopForIO::current()->RunUntilIdle();
}
+// A connection should not be blocked by another connection to the same IP
+// with a different port.
+TEST_F(WebSocketThrottleTest, NoThrottleForDistinctPort) {
+ TestURLRequestContext context;
+ DummySocketStreamDelegate delegate;
+ IPAddressNumber localhost;
+ ParseIPLiteralToNumber("127.0.0.1", &localhost);
+ WebSocketJob::set_websocket_over_spdy_enabled(false);
+
+ // socket1: 127.0.0.1:80
+ scoped_refptr<WebSocketJob> w1(new WebSocketJob(&delegate));
+ scoped_refptr<SocketStream> s1(
+ new SocketStream(GURL("ws://localhost:80/"), w1.get()));
+ s1->set_context(&context);
+ w1->InitSocketStream(s1.get());
+ MockSocketStreamConnect(s1, AddressList::CreateFromIPAddress(localhost, 80));
+
+ DVLOG(1) << "connecting socket1";
+ TestCompletionCallback callback_s1;
+ // Trying to open connection to localhost:80 will start without waiting.
+ EXPECT_EQ(OK, w1->OnStartOpenConnection(s1, callback_s1.callback()));
+
+ // socket2: 127.0.0.1:81
+ scoped_refptr<WebSocketJob> w2(new WebSocketJob(&delegate));
+ scoped_refptr<SocketStream> s2(
+ new SocketStream(GURL("ws://localhost:81/"), w2.get()));
+ s2->set_context(&context);
+ w2->InitSocketStream(s2.get());
+ MockSocketStreamConnect(s2, AddressList::CreateFromIPAddress(localhost, 81));
+
+ DVLOG(1) << "connecting socket2";
+ TestCompletionCallback callback_s2;
+ // Trying to open connection to localhost:81 will start without waiting.
+ EXPECT_EQ(OK, w2->OnStartOpenConnection(s2, callback_s2.callback()));
+
+ DVLOG(1) << "closing socket1";
+ w1->OnClose(s1.get());
+ s1->DetachDelegate();
+
+ DVLOG(1) << "closing socket2";
+ w2->OnClose(s2.get());
+ s2->DetachDelegate();
+ DVLOG(1) << "Done";
+ MessageLoopForIO::current()->RunUntilIdle();
+}
+
}
« no previous file with comments | « net/websockets/websocket_throttle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698