| OLD | NEW |
| 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/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/metrics/histogram.h" | |
| 16 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 17 #include "net/base/auth.h" | 16 #include "net/base/auth.h" |
| 18 #include "net/base/capturing_net_log.h" | 17 #include "net/base/capturing_net_log.h" |
| 19 #include "net/base/completion_callback.h" | 18 #include "net/base/completion_callback.h" |
| 20 #include "net/base/mock_host_resolver.h" | 19 #include "net/base/mock_host_resolver.h" |
| 21 #include "net/base/net_log.h" | 20 #include "net/base/net_log.h" |
| 22 #include "net/base/net_log_unittest.h" | 21 #include "net/base/net_log_unittest.h" |
| 23 #include "net/base/request_priority.h" | 22 #include "net/base/request_priority.h" |
| 24 #include "net/base/ssl_cert_request_info.h" | 23 #include "net/base/ssl_cert_request_info.h" |
| 25 #include "net/base/ssl_config_service_defaults.h" | 24 #include "net/base/ssl_config_service_defaults.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 //----------------------------------------------------------------------------- | 326 //----------------------------------------------------------------------------- |
| 328 | 327 |
| 329 // This is the expected list of advertised protocols from the browser's NPN | 328 // This is the expected list of advertised protocols from the browser's NPN |
| 330 // list. | 329 // list. |
| 331 static const char kExpectedNPNString[] = "\x08http/1.1\x06spdy/2"; | 330 static const char kExpectedNPNString[] = "\x08http/1.1\x06spdy/2"; |
| 332 | 331 |
| 333 // This is the expected return from a current server advertising SPDY. | 332 // This is the expected return from a current server advertising SPDY. |
| 334 static const char kAlternateProtocolHttpHeader[] = | 333 static const char kAlternateProtocolHttpHeader[] = |
| 335 "Alternate-Protocol: 443:npn-spdy/2\r\n\r\n"; | 334 "Alternate-Protocol: 443:npn-spdy/2\r\n\r\n"; |
| 336 | 335 |
| 337 TEST_F(HttpNetworkTransactionTest, LogNumRttVsBytesMetrics_WarmestSocket) { | |
| 338 MockRead data_reads[1000]; | |
| 339 data_reads[0] = MockRead("HTTP/1.0 200 OK\r\n\r\n"); | |
| 340 for (int i = 1; i < 999; i++) { | |
| 341 data_reads[i] = MockRead("Gagan is a good boy!"); | |
| 342 } | |
| 343 data_reads[999] = MockRead(false, OK); | |
| 344 | |
| 345 net::SetSocketReusePolicy(0); | |
| 346 SimpleGetHelperResult out = SimpleGetHelper(data_reads, | |
| 347 arraysize(data_reads)); | |
| 348 | |
| 349 base::Histogram* histogram = NULL; | |
| 350 base::StatisticsRecorder::FindHistogram( | |
| 351 "Net.Num_RTT_vs_KB_warmest_socket_15KB", &histogram); | |
| 352 CHECK(histogram); | |
| 353 | |
| 354 base::Histogram::SampleSet sample_set; | |
| 355 histogram->SnapshotSample(&sample_set); | |
| 356 EXPECT_EQ(1, sample_set.TotalCount()); | |
| 357 | |
| 358 EXPECT_EQ(OK, out.rv); | |
| 359 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | |
| 360 } | |
| 361 | |
| 362 // TODO(gagansingh): Add test for LogNumRttVsBytesMetrics_LastAccessSocket once | |
| 363 // it is possible to clear histograms from previous tests. | |
| 364 | |
| 365 TEST_F(HttpNetworkTransactionTest, Basic) { | 336 TEST_F(HttpNetworkTransactionTest, Basic) { |
| 366 SessionDependencies session_deps; | 337 SessionDependencies session_deps; |
| 367 scoped_ptr<HttpTransaction> trans( | 338 scoped_ptr<HttpTransaction> trans( |
| 368 new HttpNetworkTransaction(CreateSession(&session_deps))); | 339 new HttpNetworkTransaction(CreateSession(&session_deps))); |
| 369 } | 340 } |
| 370 | 341 |
| 371 TEST_F(HttpNetworkTransactionTest, SimpleGET) { | 342 TEST_F(HttpNetworkTransactionTest, SimpleGET) { |
| 372 MockRead data_reads[] = { | 343 MockRead data_reads[] = { |
| 373 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 344 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
| 374 MockRead("hello world"), | 345 MockRead("hello world"), |
| (...skipping 8319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8694 // Now that the new handshake has failed, ensure that the client | 8665 // Now that the new handshake has failed, ensure that the client |
| 8695 // certificate was removed from the client auth cache. | 8666 // certificate was removed from the client auth cache. |
| 8696 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("proxy:70", | 8667 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("proxy:70", |
| 8697 &client_cert)); | 8668 &client_cert)); |
| 8698 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", | 8669 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", |
| 8699 &client_cert)); | 8670 &client_cert)); |
| 8700 } | 8671 } |
| 8701 } | 8672 } |
| 8702 | 8673 |
| 8703 } // namespace net | 8674 } // namespace net |
| OLD | NEW |