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

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

Issue 3197018: Refactor: change the spdy session pool key to take a ProxyServer instead of a stri... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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
« no previous file with comments | « net/spdy/spdy_http_stream_unittest.cc ('k') | net/spdy/spdy_session_pool.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include <vector> 6 #include <vector>
7 7
8 #include "net/base/net_log_unittest.h" 8 #include "net/base/net_log_unittest.h"
9 #include "net/http/http_stream_handle.h" 9 #include "net/http/http_stream_handle.h"
10 #include "net/http/http_transaction_unittest.h" 10 #include "net/http/http_transaction_unittest.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 return bytes_read; 354 return bytes_read;
355 } 355 }
356 356
357 void VerifyStreamsClosed(const NormalSpdyTransactionHelper& helper) { 357 void VerifyStreamsClosed(const NormalSpdyTransactionHelper& helper) {
358 // This lengthy block is reaching into the pool to dig out the active 358 // This lengthy block is reaching into the pool to dig out the active
359 // session. Once we have the session, we verify that the streams are 359 // session. Once we have the session, we verify that the streams are
360 // all closed and not leaked at this point. 360 // all closed and not leaked at this point.
361 const GURL& url = helper.request().url; 361 const GURL& url = helper.request().url;
362 int port = helper.test_type() == SPDYNPN ? 443 : 80; 362 int port = helper.test_type() == SPDYNPN ? 443 : 80;
363 HostPortPair host_port_pair(url.host(), port); 363 HostPortPair host_port_pair(url.host(), port);
364 HostPortProxyPair pair(host_port_pair, "DIRECT"); 364 HostPortProxyPair pair(host_port_pair, ProxyServer::Direct());
365 BoundNetLog log; 365 BoundNetLog log;
366 const scoped_refptr<HttpNetworkSession>& session = helper.session(); 366 const scoped_refptr<HttpNetworkSession>& session = helper.session();
367 scoped_refptr<SpdySessionPool> pool(session->spdy_session_pool()); 367 scoped_refptr<SpdySessionPool> pool(session->spdy_session_pool());
368 EXPECT_TRUE(pool->HasSession(pair)); 368 EXPECT_TRUE(pool->HasSession(pair));
369 scoped_refptr<SpdySession> spdy_session(pool->Get(pair, session, log)); 369 scoped_refptr<SpdySession> spdy_session(pool->Get(pair, session, log));
370 ASSERT_TRUE(spdy_session.get() != NULL); 370 ASSERT_TRUE(spdy_session.get() != NULL);
371 EXPECT_EQ(0u, spdy_session->num_active_streams()); 371 EXPECT_EQ(0u, spdy_session->num_active_streams());
372 EXPECT_EQ(0u, spdy_session->num_unclaimed_pushed_streams()); 372 EXPECT_EQ(0u, spdy_session->num_unclaimed_pushed_streams());
373 } 373 }
374 374
(...skipping 3628 matching lines...) Expand 10 before | Expand all | Expand 10 after
4003 EXPECT_TRUE(response->headers != NULL); 4003 EXPECT_TRUE(response->headers != NULL);
4004 EXPECT_TRUE(response->was_fetched_via_spdy); 4004 EXPECT_TRUE(response->was_fetched_via_spdy);
4005 out.rv = ReadTransaction(trans, &out.response_data); 4005 out.rv = ReadTransaction(trans, &out.response_data);
4006 EXPECT_EQ(OK, out.rv); 4006 EXPECT_EQ(OK, out.rv);
4007 out.status_line = response->headers->GetStatusLine(); 4007 out.status_line = response->headers->GetStatusLine();
4008 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); 4008 EXPECT_EQ("HTTP/1.1 200 OK", out.status_line);
4009 EXPECT_EQ("hello!", out.response_data); 4009 EXPECT_EQ("hello!", out.response_data);
4010 4010
4011 // Check that the SpdySession is still in the SpdySessionPool. 4011 // Check that the SpdySession is still in the SpdySessionPool.
4012 HostPortPair host_port_pair("www.google.com", helper.port()); 4012 HostPortPair host_port_pair("www.google.com", helper.port());
4013 HostPortProxyPair session_pool_key_direct(host_port_pair, "DIRECT"); 4013 HostPortProxyPair session_pool_key_direct(
4014 host_port_pair, ProxyServer::Direct());
4014 EXPECT_TRUE(spdy_session_pool->HasSession(session_pool_key_direct)); 4015 EXPECT_TRUE(spdy_session_pool->HasSession(session_pool_key_direct));
4015 HostPortProxyPair session_pool_key_proxy(host_port_pair, "PROXY www.foo.com"); 4016 HostPortProxyPair session_pool_key_proxy(
4017 host_port_pair,
4018 ProxyServer::FromURI("www.foo.com", ProxyServer::SCHEME_HTTP));
4016 EXPECT_FALSE(spdy_session_pool->HasSession(session_pool_key_proxy)); 4019 EXPECT_FALSE(spdy_session_pool->HasSession(session_pool_key_proxy));
4017 4020
4018 // Set up data for the proxy connection. 4021 // Set up data for the proxy connection.
4019 const char kConnect443[] = {"CONNECT www.google.com:443 HTTP/1.1\r\n" 4022 const char kConnect443[] = {"CONNECT www.google.com:443 HTTP/1.1\r\n"
4020 "Host: www.google.com\r\n" 4023 "Host: www.google.com\r\n"
4021 "Proxy-Connection: keep-alive\r\n\r\n"}; 4024 "Proxy-Connection: keep-alive\r\n\r\n"};
4022 const char kConnect80[] = {"CONNECT www.google.com:80 HTTP/1.1\r\n" 4025 const char kConnect80[] = {"CONNECT www.google.com:80 HTTP/1.1\r\n"
4023 "Host: www.google.com\r\n" 4026 "Host: www.google.com\r\n"
4024 "Proxy-Connection: keep-alive\r\n\r\n"}; 4027 "Proxy-Connection: keep-alive\r\n\r\n"};
4025 const char kHTTP200[] = {"HTTP/1.1 200 OK\r\n\r\n"}; 4028 const char kHTTP200[] = {"HTTP/1.1 200 OK\r\n\r\n"};
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
4198 rv = ReadTransaction(trans.get(), &response_data); 4201 rv = ReadTransaction(trans.get(), &response_data);
4199 EXPECT_EQ(OK, rv); 4202 EXPECT_EQ(OK, rv);
4200 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); 4203 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine());
4201 EXPECT_EQ("hello!", response_data); 4204 EXPECT_EQ("hello!", response_data);
4202 } 4205 }
4203 4206
4204 helper.VerifyDataConsumed(); 4207 helper.VerifyDataConsumed();
4205 } 4208 }
4206 } 4209 }
4207 } // namespace net 4210 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_stream_unittest.cc ('k') | net/spdy/spdy_session_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698