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" |
15 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
16 #include "net/base/auth.h" | 17 #include "net/base/auth.h" |
17 #include "net/base/capturing_net_log.h" | 18 #include "net/base/capturing_net_log.h" |
18 #include "net/base/completion_callback.h" | 19 #include "net/base/completion_callback.h" |
19 #include "net/base/mock_host_resolver.h" | 20 #include "net/base/mock_host_resolver.h" |
20 #include "net/base/net_log.h" | 21 #include "net/base/net_log.h" |
21 #include "net/base/net_log_unittest.h" | 22 #include "net/base/net_log_unittest.h" |
22 #include "net/base/request_priority.h" | 23 #include "net/base/request_priority.h" |
23 #include "net/base/ssl_cert_request_info.h" | 24 #include "net/base/ssl_cert_request_info.h" |
24 #include "net/base/ssl_config_service_defaults.h" | 25 #include "net/base/ssl_config_service_defaults.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 //----------------------------------------------------------------------------- | 327 //----------------------------------------------------------------------------- |
327 | 328 |
328 // This is the expected list of advertised protocols from the browser's NPN | 329 // This is the expected list of advertised protocols from the browser's NPN |
329 // list. | 330 // list. |
330 static const char kExpectedNPNString[] = "\x08http/1.1\x06spdy/2"; | 331 static const char kExpectedNPNString[] = "\x08http/1.1\x06spdy/2"; |
331 | 332 |
332 // This is the expected return from a current server advertising SPDY. | 333 // This is the expected return from a current server advertising SPDY. |
333 static const char kAlternateProtocolHttpHeader[] = | 334 static const char kAlternateProtocolHttpHeader[] = |
334 "Alternate-Protocol: 443:npn-spdy/2\r\n\r\n"; | 335 "Alternate-Protocol: 443:npn-spdy/2\r\n\r\n"; |
335 | 336 |
| 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 |
336 TEST_F(HttpNetworkTransactionTest, Basic) { | 365 TEST_F(HttpNetworkTransactionTest, Basic) { |
337 SessionDependencies session_deps; | 366 SessionDependencies session_deps; |
338 scoped_ptr<HttpTransaction> trans( | 367 scoped_ptr<HttpTransaction> trans( |
339 new HttpNetworkTransaction(CreateSession(&session_deps))); | 368 new HttpNetworkTransaction(CreateSession(&session_deps))); |
340 } | 369 } |
341 | 370 |
342 TEST_F(HttpNetworkTransactionTest, SimpleGET) { | 371 TEST_F(HttpNetworkTransactionTest, SimpleGET) { |
343 MockRead data_reads[] = { | 372 MockRead data_reads[] = { |
344 MockRead("HTTP/1.0 200 OK\r\n\r\n"), | 373 MockRead("HTTP/1.0 200 OK\r\n\r\n"), |
345 MockRead("hello world"), | 374 MockRead("hello world"), |
(...skipping 8322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8668 // Now that the new handshake has failed, ensure that the client | 8697 // Now that the new handshake has failed, ensure that the client |
8669 // certificate was removed from the client auth cache. | 8698 // certificate was removed from the client auth cache. |
8670 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("proxy:70", | 8699 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("proxy:70", |
8671 &client_cert)); | 8700 &client_cert)); |
8672 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", | 8701 ASSERT_FALSE(session->ssl_client_auth_cache()->Lookup("www.example.com:443", |
8673 &client_cert)); | 8702 &client_cert)); |
8674 } | 8703 } |
8675 } | 8704 } |
8676 | 8705 |
8677 } // namespace net | 8706 } // namespace net |
OLD | NEW |