OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_http_stream.h" | 5 #include "net/spdy/spdy_http_stream.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "crypto/ec_private_key.h" | 13 #include "crypto/ec_private_key.h" |
14 #include "crypto/ec_signature_creator.h" | 14 #include "crypto/ec_signature_creator.h" |
15 #include "crypto/signature_creator.h" | 15 #include "crypto/signature_creator.h" |
16 #include "net/base/chunked_upload_data_stream.h" | 16 #include "net/base/chunked_upload_data_stream.h" |
17 #include "net/base/load_timing_info.h" | 17 #include "net/base/load_timing_info.h" |
18 #include "net/base/load_timing_info_test_util.h" | 18 #include "net/base/load_timing_info_test_util.h" |
19 #include "net/base/test_completion_callback.h" | 19 #include "net/base/test_completion_callback.h" |
20 #include "net/cert/asn1_util.h" | 20 #include "net/cert/asn1_util.h" |
21 #include "net/http/http_request_info.h" | 21 #include "net/http/http_request_info.h" |
22 #include "net/http/http_response_headers.h" | 22 #include "net/http/http_response_headers.h" |
23 #include "net/http/http_response_info.h" | 23 #include "net/http/http_response_info.h" |
| 24 #include "net/log/net_log_source.h" |
| 25 #include "net/log/net_log_with_source.h" |
24 #include "net/log/test_net_log.h" | 26 #include "net/log/test_net_log.h" |
25 #include "net/socket/socket_test_util.h" | 27 #include "net/socket/socket_test_util.h" |
26 #include "net/spdy/spdy_http_utils.h" | 28 #include "net/spdy/spdy_http_utils.h" |
27 #include "net/spdy/spdy_session.h" | 29 #include "net/spdy/spdy_session.h" |
28 #include "net/spdy/spdy_test_util_common.h" | 30 #include "net/spdy/spdy_test_util_common.h" |
29 #include "net/ssl/default_channel_id_store.h" | 31 #include "net/ssl/default_channel_id_store.h" |
30 #include "net/test/cert_test_util.h" | 32 #include "net/test/cert_test_util.h" |
31 #include "net/test/gtest_util.h" | 33 #include "net/test/gtest_util.h" |
32 #include "net/test/test_data_directory.h" | 34 #include "net/test/test_data_directory.h" |
33 #include "testing/gmock/include/gmock/gmock.h" | 35 #include "testing/gmock/include/gmock/gmock.h" |
34 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
35 | 37 |
36 using net::test::IsError; | 38 using net::test::IsError; |
37 using net::test::IsOk; | 39 using net::test::IsOk; |
38 | 40 |
39 namespace net { | 41 namespace net { |
40 | 42 |
41 namespace { | 43 namespace { |
42 | 44 |
43 // Tests the load timing of a stream that's connected and is not the first | 45 // Tests the load timing of a stream that's connected and is not the first |
44 // request sent on a connection. | 46 // request sent on a connection. |
45 void TestLoadTimingReused(const HttpStream& stream) { | 47 void TestLoadTimingReused(const HttpStream& stream) { |
46 LoadTimingInfo load_timing_info; | 48 LoadTimingInfo load_timing_info; |
47 EXPECT_TRUE(stream.GetLoadTimingInfo(&load_timing_info)); | 49 EXPECT_TRUE(stream.GetLoadTimingInfo(&load_timing_info)); |
48 | 50 |
49 EXPECT_TRUE(load_timing_info.socket_reused); | 51 EXPECT_TRUE(load_timing_info.socket_reused); |
50 EXPECT_NE(NetLog::Source::kInvalidId, load_timing_info.socket_log_id); | 52 EXPECT_NE(NetLogSource::kInvalidId, load_timing_info.socket_log_id); |
51 | 53 |
52 ExpectConnectTimingHasNoTimes(load_timing_info.connect_timing); | 54 ExpectConnectTimingHasNoTimes(load_timing_info.connect_timing); |
53 ExpectLoadTimingHasOnlyConnectionTimes(load_timing_info); | 55 ExpectLoadTimingHasOnlyConnectionTimes(load_timing_info); |
54 } | 56 } |
55 | 57 |
56 // Tests the load timing of a stream that's connected and using a fresh | 58 // Tests the load timing of a stream that's connected and using a fresh |
57 // connection. | 59 // connection. |
58 void TestLoadTimingNotReused(const HttpStream& stream) { | 60 void TestLoadTimingNotReused(const HttpStream& stream) { |
59 LoadTimingInfo load_timing_info; | 61 LoadTimingInfo load_timing_info; |
60 EXPECT_TRUE(stream.GetLoadTimingInfo(&load_timing_info)); | 62 EXPECT_TRUE(stream.GetLoadTimingInfo(&load_timing_info)); |
61 | 63 |
62 EXPECT_FALSE(load_timing_info.socket_reused); | 64 EXPECT_FALSE(load_timing_info.socket_reused); |
63 EXPECT_NE(NetLog::Source::kInvalidId, load_timing_info.socket_log_id); | 65 EXPECT_NE(NetLogSource::kInvalidId, load_timing_info.socket_log_id); |
64 | 66 |
65 ExpectConnectTimingHasTimes( | 67 ExpectConnectTimingHasTimes( |
66 load_timing_info.connect_timing, | 68 load_timing_info.connect_timing, |
67 CONNECT_TIMING_HAS_DNS_TIMES | CONNECT_TIMING_HAS_SSL_TIMES); | 69 CONNECT_TIMING_HAS_DNS_TIMES | CONNECT_TIMING_HAS_SSL_TIMES); |
68 ExpectLoadTimingHasOnlyConnectionTimes(load_timing_info); | 70 ExpectLoadTimingHasOnlyConnectionTimes(load_timing_info); |
69 } | 71 } |
70 | 72 |
71 class ReadErrorUploadDataStream : public UploadDataStream { | 73 class ReadErrorUploadDataStream : public UploadDataStream { |
72 public: | 74 public: |
73 enum class FailureMode { SYNC, ASYNC }; | 75 enum class FailureMode { SYNC, ASYNC }; |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 // The callback cancels |http_stream|. | 1037 // The callback cancels |http_stream|. |
1036 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 1038 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
1037 | 1039 |
1038 EXPECT_FALSE(HasSpdySession(http_session_->spdy_session_pool(), key_)); | 1040 EXPECT_FALSE(HasSpdySession(http_session_->spdy_session_pool(), key_)); |
1039 } | 1041 } |
1040 | 1042 |
1041 // TODO(willchan): Write a longer test for SpdyStream that exercises all | 1043 // TODO(willchan): Write a longer test for SpdyStream that exercises all |
1042 // methods. | 1044 // methods. |
1043 | 1045 |
1044 } // namespace net | 1046 } // namespace net |
OLD | NEW |