| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 9 #include "net/base/address_list.h" | 9 #include "net/base/address_list.h" |
| 10 #include "net/base/sys_addrinfo.h" | 10 #include "net/base/sys_addrinfo.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 DLOG(INFO) << "socket3 close"; | 272 DLOG(INFO) << "socket3 close"; |
| 273 w3->OnClose(s3.get()); | 273 w3->OnClose(s3.get()); |
| 274 MessageLoopForIO::current()->RunAllPending(); | 274 MessageLoopForIO::current()->RunAllPending(); |
| 275 s3->DetachDelegate(); | 275 s3->DetachDelegate(); |
| 276 w4->OnClose(s4.get()); | 276 w4->OnClose(s4.get()); |
| 277 s4->DetachDelegate(); | 277 s4->DetachDelegate(); |
| 278 DLOG(INFO) << "Done"; | 278 DLOG(INFO) << "Done"; |
| 279 MessageLoopForIO::current()->RunAllPending(); | 279 MessageLoopForIO::current()->RunAllPending(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 TEST_F(WebSocketThrottleTest, NoThrottleForDuplicateAddress) { |
| 283 DummySocketStreamDelegate delegate; |
| 284 |
| 285 // For localhost: 127.0.0.1, 127.0.0.1 |
| 286 struct addrinfo* addr = AddAddr(127, 0, 0, 1, NULL); |
| 287 addr = AddAddr(127, 0, 0, 1, addr); |
| 288 scoped_refptr<WebSocketJob> w1 = new WebSocketJob(&delegate); |
| 289 scoped_refptr<SocketStream> s1 = |
| 290 new SocketStream(GURL("ws://localhost/"), w1.get()); |
| 291 w1->InitSocketStream(s1.get()); |
| 292 WebSocketThrottleTest::MockSocketStreamConnect(s1, addr); |
| 293 DeleteAddrInfo(addr); |
| 294 |
| 295 DLOG(INFO) << "socket1"; |
| 296 TestCompletionCallback callback_s1; |
| 297 // Trying to open connection to localhost will start without wait. |
| 298 EXPECT_EQ(OK, w1->OnStartOpenConnection(s1, &callback_s1)); |
| 299 |
| 300 DLOG(INFO) << "socket1 close"; |
| 301 w1->OnClose(s1.get()); |
| 302 s1->DetachDelegate(); |
| 303 DLOG(INFO) << "Done"; |
| 304 MessageLoopForIO::current()->RunAllPending(); |
| 305 } |
| 306 |
| 282 } | 307 } |
| OLD | NEW |