Chromium Code Reviews| 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/chromium/spdy_session.h" | 5 #include "net/spdy/chromium/spdy_session.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 2833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2844 } | 2844 } |
| 2845 | 2845 |
| 2846 // Test that SpdySession::DoReadLoop reads data from the socket | 2846 // Test that SpdySession::DoReadLoop reads data from the socket |
| 2847 // without yielding. This test makes 32k - 1 bytes of data available | 2847 // without yielding. This test makes 32k - 1 bytes of data available |
| 2848 // on the socket for reading. It then verifies that it has read all | 2848 // on the socket for reading. It then verifies that it has read all |
| 2849 // the available data without yielding. | 2849 // the available data without yielding. |
| 2850 TEST_F(SpdySessionTest, ReadDataWithoutYielding) { | 2850 TEST_F(SpdySessionTest, ReadDataWithoutYielding) { |
| 2851 session_deps_.host_resolver->set_synchronous_mode(true); | 2851 session_deps_.host_resolver->set_synchronous_mode(true); |
| 2852 session_deps_.time_func = InstantaneousReads; | 2852 session_deps_.time_func = InstantaneousReads; |
| 2853 | 2853 |
| 2854 BufferedSpdyFramer framer; | 2854 BufferedSpdyFramer framer((NetLogWithSource())); |
| 2855 | 2855 |
| 2856 SpdySerializedFrame req1( | 2856 SpdySerializedFrame req1( |
| 2857 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, MEDIUM, true)); | 2857 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, MEDIUM, true)); |
| 2858 MockWrite writes[] = { | 2858 MockWrite writes[] = { |
| 2859 CreateMockWrite(req1, 0), | 2859 CreateMockWrite(req1, 0), |
| 2860 }; | 2860 }; |
| 2861 | 2861 |
| 2862 // Build buffer of size kYieldAfterBytesRead / 4 | 2862 // Build buffer of size kYieldAfterBytesRead / 4 |
| 2863 // (-spdy_data_frame_size). | 2863 // (-spdy_data_frame_size). |
| 2864 ASSERT_EQ(32 * 1024, kYieldAfterBytesRead); | 2864 ASSERT_EQ(32 * 1024, kYieldAfterBytesRead); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3057 | 3057 |
| 3058 // Test that SpdySession::DoReadLoop yields while reading the | 3058 // Test that SpdySession::DoReadLoop yields while reading the |
| 3059 // data. This test makes 32k + 1 bytes of data available on the socket | 3059 // data. This test makes 32k + 1 bytes of data available on the socket |
| 3060 // for reading. It then verifies that DoRead has yielded even though | 3060 // for reading. It then verifies that DoRead has yielded even though |
| 3061 // there is data available for it to read (i.e, socket()->Read didn't | 3061 // there is data available for it to read (i.e, socket()->Read didn't |
| 3062 // return ERR_IO_PENDING during socket reads). | 3062 // return ERR_IO_PENDING during socket reads). |
| 3063 TEST_F(SpdySessionTest, TestYieldingDuringReadData) { | 3063 TEST_F(SpdySessionTest, TestYieldingDuringReadData) { |
| 3064 session_deps_.host_resolver->set_synchronous_mode(true); | 3064 session_deps_.host_resolver->set_synchronous_mode(true); |
| 3065 session_deps_.time_func = InstantaneousReads; | 3065 session_deps_.time_func = InstantaneousReads; |
| 3066 | 3066 |
| 3067 BufferedSpdyFramer framer; | 3067 BufferedSpdyFramer framer((NetLogWithSource())); |
|
Bence
2017/05/10 12:43:29
I think there is an extra pair of () here that sho
xunjieli
2017/05/10 18:24:59
Done.
| |
| 3068 | 3068 |
| 3069 SpdySerializedFrame req1( | 3069 SpdySerializedFrame req1( |
| 3070 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, MEDIUM, true)); | 3070 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, MEDIUM, true)); |
| 3071 MockWrite writes[] = { | 3071 MockWrite writes[] = { |
| 3072 CreateMockWrite(req1, 0), | 3072 CreateMockWrite(req1, 0), |
| 3073 }; | 3073 }; |
| 3074 | 3074 |
| 3075 // Build buffer of size kYieldAfterBytesRead / 4 | 3075 // Build buffer of size kYieldAfterBytesRead / 4 |
| 3076 // (-spdy_data_frame_size). | 3076 // (-spdy_data_frame_size). |
| 3077 ASSERT_EQ(32 * 1024, kYieldAfterBytesRead); | 3077 ASSERT_EQ(32 * 1024, kYieldAfterBytesRead); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3151 // | 3151 // |
| 3152 // The above reads 26K synchronously. Since that is less that 32K, we | 3152 // The above reads 26K synchronously. Since that is less that 32K, we |
| 3153 // will attempt to read again. However, that DoRead() will return | 3153 // will attempt to read again. However, that DoRead() will return |
| 3154 // ERR_IO_PENDING (because of async read), so DoReadLoop() will | 3154 // ERR_IO_PENDING (because of async read), so DoReadLoop() will |
| 3155 // yield. When we come back, DoRead() will read the results from the | 3155 // yield. When we come back, DoRead() will read the results from the |
| 3156 // async read, and rest of the data synchronously. | 3156 // async read, and rest of the data synchronously. |
| 3157 TEST_F(SpdySessionTest, TestYieldingDuringAsyncReadData) { | 3157 TEST_F(SpdySessionTest, TestYieldingDuringAsyncReadData) { |
| 3158 session_deps_.host_resolver->set_synchronous_mode(true); | 3158 session_deps_.host_resolver->set_synchronous_mode(true); |
| 3159 session_deps_.time_func = InstantaneousReads; | 3159 session_deps_.time_func = InstantaneousReads; |
| 3160 | 3160 |
| 3161 BufferedSpdyFramer framer; | 3161 BufferedSpdyFramer framer((NetLogWithSource())); |
|
Bence
2017/05/10 12:43:29
Same here.
xunjieli
2017/05/10 18:24:59
Done.
| |
| 3162 | 3162 |
| 3163 SpdySerializedFrame req1( | 3163 SpdySerializedFrame req1( |
| 3164 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, MEDIUM, true)); | 3164 spdy_util_.ConstructSpdyGet(nullptr, 0, 1, MEDIUM, true)); |
| 3165 MockWrite writes[] = { | 3165 MockWrite writes[] = { |
| 3166 CreateMockWrite(req1, 0), | 3166 CreateMockWrite(req1, 0), |
| 3167 }; | 3167 }; |
| 3168 | 3168 |
| 3169 // Build buffer of size kYieldAfterBytesRead / 4 | 3169 // Build buffer of size kYieldAfterBytesRead / 4 |
| 3170 // (-spdy_data_frame_size). | 3170 // (-spdy_data_frame_size). |
| 3171 ASSERT_EQ(32 * 1024, kYieldAfterBytesRead); | 3171 ASSERT_EQ(32 * 1024, kYieldAfterBytesRead); |
| (...skipping 2928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6100 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), | 6100 ssl_info.cert = ImportCertFromFile(GetTestCertsDirectory(), |
| 6101 "spdy_pooling.pem"); | 6101 "spdy_pooling.pem"); |
| 6102 ssl_info.is_issued_by_known_root = true; | 6102 ssl_info.is_issued_by_known_root = true; |
| 6103 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); | 6103 ssl_info.public_key_hashes.push_back(test::GetTestHashValue(primary_pin)); |
| 6104 | 6104 |
| 6105 EXPECT_TRUE(SpdySession::CanPool( | 6105 EXPECT_TRUE(SpdySession::CanPool( |
| 6106 &tss, ssl_info, "www.example.org", "mail.example.org")); | 6106 &tss, ssl_info, "www.example.org", "mail.example.org")); |
| 6107 } | 6107 } |
| 6108 | 6108 |
| 6109 } // namespace net | 6109 } // namespace net |
| OLD | NEW |