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

Side by Side Diff: net/spdy/spdy_session_unittest.cc

Issue 7349023: Changed SPDY's ip connection pooling logic to only add the used IP, (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include "net/spdy/spdy_io_buffer.h" 7 #include "net/spdy/spdy_io_buffer.h"
8 #include "net/spdy/spdy_session_pool.h" 8 #include "net/spdy/spdy_session_pool.h"
9 #include "net/spdy/spdy_stream.h" 9 #include "net/spdy/spdy_stream.h"
10 #include "net/spdy/spdy_test_util.h" 10 #include "net/spdy/spdy_test_util.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 // If |clean_via_close_current_sessions| is false, the sessions are closed 410 // If |clean_via_close_current_sessions| is false, the sessions are closed
411 // manually, calling SpdySessionPool::Remove() directly. If it is true, 411 // manually, calling SpdySessionPool::Remove() directly. If it is true,
412 // sessions are closed with SpdySessionPool::CloseCurrentSessions(). 412 // sessions are closed with SpdySessionPool::CloseCurrentSessions().
413 void IPPoolingTest(bool clean_via_close_current_sessions) { 413 void IPPoolingTest(bool clean_via_close_current_sessions) {
414 const int kTestPort = 80; 414 const int kTestPort = 80;
415 struct TestHosts { 415 struct TestHosts {
416 std::string name; 416 std::string name;
417 std::string iplist; 417 std::string iplist;
418 HostPortProxyPair pair; 418 HostPortProxyPair pair;
419 } test_hosts[] = { 419 } test_hosts[] = {
420 { "www.foo.com", "192.168.0.1,192.168.0.5" }, 420 { "www.foo.com", "192.0.2.33,192.168.0.1,192.168.0.5" },
421 { "images.foo.com", "192.168.0.2,192.168.0.3,192.168.0.5" }, 421 { "images.foo.com", "192.168.0.2,192.168.0.3,192.168.0.5,192.0.2.33" },
422 { "js.foo.com", "192.168.0.4,192.168.0.3" }, 422 { "js.foo.com", "192.168.0.4,192.168.0.3" },
423 }; 423 };
424 424
425 SpdySessionDependencies session_deps; 425 SpdySessionDependencies session_deps;
426 session_deps.host_resolver->set_synchronous_mode(true); 426 session_deps.host_resolver->set_synchronous_mode(true);
427 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) { 427 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_hosts); i++) {
428 session_deps.host_resolver->rules()->AddIPLiteralRule(test_hosts[i].name, 428 session_deps.host_resolver->rules()->AddIPLiteralRule(test_hosts[i].name,
429 test_hosts[i].iplist, ""); 429 test_hosts[i].iplist, "");
430 430
431 // This test requires that the HostResolver cache be populated. Normal 431 // This test requires that the HostResolver cache be populated. Normal
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 false, 470 false,
471 false)); 471 false));
472 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle); 472 scoped_ptr<ClientSocketHandle> connection(new ClientSocketHandle);
473 EXPECT_EQ(OK, 473 EXPECT_EQ(OK,
474 connection->Init(test_host_port_pair.ToString(), 474 connection->Init(test_host_port_pair.ToString(),
475 transport_params, MEDIUM, 475 transport_params, MEDIUM,
476 NULL, http_session->transport_socket_pool(), 476 NULL, http_session->transport_socket_pool(),
477 BoundNetLog())); 477 BoundNetLog()));
478 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK)); 478 EXPECT_EQ(OK, session->InitializeWithSocket(connection.release(), false, OK));
479 479
480 // MockClientSocket::GetPeerAddress return's 0 as the port number for the
481 // host. HasSession looks up addresses with port 80. AddAliases adds addresses
482 // with port 80 into session_pool's aliases for |test_hosts[0].pair|.
483 SpdySessionPoolPeer pool_peer(spdy_session_pool);
484 pool_peer.AddAliases(test_hosts[0].pair);
willchan no longer on Chromium 2011/07/17 12:44:47 Sorry, I wasn't clear. I'd prefer you just do AddA
ramant (doing other things) 2011/07/17 19:45:34 Done.
485
480 // Flush the SpdySession::OnReadComplete() task. 486 // Flush the SpdySession::OnReadComplete() task.
481 MessageLoop::current()->RunAllPending(); 487 MessageLoop::current()->RunAllPending();
482 488
483 // The third host has no overlap with the first, so it can't pool IPs. 489 // The third host has no overlap with the first, so it can't pool IPs.
484 EXPECT_FALSE(spdy_session_pool->HasSession(test_hosts[2].pair)); 490 EXPECT_FALSE(spdy_session_pool->HasSession(test_hosts[2].pair));
485 491
486 // The second host overlaps with the first, and should IP pool. 492 // The second host overlaps with the first, and should IP pool.
487 EXPECT_TRUE(spdy_session_pool->HasSession(test_hosts[1].pair)); 493 EXPECT_TRUE(spdy_session_pool->HasSession(test_hosts[1].pair));
488 494
489 // Verify that the second host, through a proxy, won't share the IP. 495 // Verify that the second host, through a proxy, won't share the IP.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 572
567 test_settings_storage->Set(test_host_port_pair, test_settings); 573 test_settings_storage->Set(test_host_port_pair, test_settings);
568 EXPECT_NE(0u, test_settings_storage->Get(test_host_port_pair).size()); 574 EXPECT_NE(0u, test_settings_storage->Get(test_host_port_pair).size());
569 spdy_session_pool->OnIPAddressChanged(); 575 spdy_session_pool->OnIPAddressChanged();
570 EXPECT_EQ(0u, test_settings_storage->Get(test_host_port_pair).size()); 576 EXPECT_EQ(0u, test_settings_storage->Get(test_host_port_pair).size());
571 } 577 }
572 578
573 } // namespace 579 } // namespace
574 580
575 } // namespace net 581 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698