| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cstddef> | 9 #include <cstddef> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <utility> |
| 12 #include <vector> |
| 11 | 13 |
| 12 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 15 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 16 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 17 #include "base/strings/string_split.h" | 19 #include "base/strings/string_split.h" |
| 18 #include "base/test/histogram_tester.h" | 20 #include "base/test/histogram_tester.h" |
| 19 #include "net/base/auth.h" | 21 #include "net/base/auth.h" |
| 20 #include "net/base/request_priority.h" | 22 #include "net/base/request_priority.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 "Content-Length: 12\r\n\r\n"), | 129 "Content-Length: 12\r\n\r\n"), |
| 128 MockRead("Test Content")}; | 130 MockRead("Test Content")}; |
| 129 | 131 |
| 130 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes, | 132 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes, |
| 131 arraysize(writes)); | 133 arraysize(writes)); |
| 132 socket_factory_.AddSocketDataProvider(&socket_data); | 134 socket_factory_.AddSocketDataProvider(&socket_data); |
| 133 | 135 |
| 134 std::unique_ptr<URLRequest> request = | 136 std::unique_ptr<URLRequest> request = |
| 135 context_.CreateRequest(GURL("http://www.example.com"), DEFAULT_PRIORITY, | 137 context_.CreateRequest(GURL("http://www.example.com"), DEFAULT_PRIORITY, |
| 136 &delegate_, TRAFFIC_ANNOTATION_FOR_TESTS); | 138 &delegate_, TRAFFIC_ANNOTATION_FOR_TESTS); |
| 137 std::unique_ptr<TestURLRequestHttpJob> job( | 139 auto job = base::MakeUnique<TestURLRequestHttpJob>(request.get()); |
| 138 new TestURLRequestHttpJob(request.get())); | |
| 139 job->set_use_null_source_stream(true); | 140 job->set_use_null_source_stream(true); |
| 140 test_job_interceptor_->set_main_intercept_job(std::move(job)); | 141 test_job_interceptor_->set_main_intercept_job(std::move(job)); |
| 141 request->Start(); | 142 request->Start(); |
| 142 | 143 |
| 143 base::RunLoop().Run(); | 144 base::RunLoop().Run(); |
| 144 EXPECT_EQ(ERR_CONTENT_DECODING_INIT_FAILED, delegate_.request_status()); | 145 EXPECT_EQ(ERR_CONTENT_DECODING_INIT_FAILED, delegate_.request_status()); |
| 145 } | 146 } |
| 146 | 147 |
| 147 // Tests that if there is an unknown content-encoding type, the raw response | 148 // Tests that if there is an unknown content-encoding type, the raw response |
| 148 // body is passed through. | 149 // body is passed through. |
| 149 TEST_F(URLRequestHttpJobSetUpSourceTest, UnknownEncoding) { | 150 TEST_F(URLRequestHttpJobSetUpSourceTest, UnknownEncoding) { |
| 150 MockWrite writes[] = {MockWrite(kSimpleGetMockWrite)}; | 151 MockWrite writes[] = {MockWrite(kSimpleGetMockWrite)}; |
| 151 MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n" | 152 MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n" |
| 152 "Content-Encoding: foo, gzip\r\n" | 153 "Content-Encoding: foo, gzip\r\n" |
| 153 "Content-Length: 12\r\n\r\n"), | 154 "Content-Length: 12\r\n\r\n"), |
| 154 MockRead("Test Content")}; | 155 MockRead("Test Content")}; |
| 155 | 156 |
| 156 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes, | 157 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes, |
| 157 arraysize(writes)); | 158 arraysize(writes)); |
| 158 socket_factory_.AddSocketDataProvider(&socket_data); | 159 socket_factory_.AddSocketDataProvider(&socket_data); |
| 159 | 160 |
| 160 std::unique_ptr<URLRequest> request = | 161 std::unique_ptr<URLRequest> request = |
| 161 context_.CreateRequest(GURL("http://www.example.com"), DEFAULT_PRIORITY, | 162 context_.CreateRequest(GURL("http://www.example.com"), DEFAULT_PRIORITY, |
| 162 &delegate_, TRAFFIC_ANNOTATION_FOR_TESTS); | 163 &delegate_, TRAFFIC_ANNOTATION_FOR_TESTS); |
| 163 std::unique_ptr<TestURLRequestHttpJob> job( | 164 auto job = base::MakeUnique<TestURLRequestHttpJob>(request.get()); |
| 164 new TestURLRequestHttpJob(request.get())); | |
| 165 test_job_interceptor_->set_main_intercept_job(std::move(job)); | 165 test_job_interceptor_->set_main_intercept_job(std::move(job)); |
| 166 request->Start(); | 166 request->Start(); |
| 167 | 167 |
| 168 base::RunLoop().Run(); | 168 base::RunLoop().Run(); |
| 169 EXPECT_EQ(OK, delegate_.request_status()); | 169 EXPECT_EQ(OK, delegate_.request_status()); |
| 170 EXPECT_EQ("Test Content", delegate_.data_received()); | 170 EXPECT_EQ("Test Content", delegate_.data_received()); |
| 171 } | 171 } |
| 172 | 172 |
| 173 // Received a malformed SDCH encoded response when there is no SdchManager. | 173 // Received a malformed SDCH encoded response when there is no SdchManager. |
| 174 TEST_F(URLRequestHttpJobSetUpSourceTest, SdchNotAdvertisedGotSdchResponse) { | 174 TEST_F(URLRequestHttpJobSetUpSourceTest, SdchNotAdvertisedGotSdchResponse) { |
| 175 MockWrite writes[] = {MockWrite(kSimpleGetMockWrite)}; | 175 MockWrite writes[] = {MockWrite(kSimpleGetMockWrite)}; |
| 176 MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n" | 176 MockRead reads[] = {MockRead("HTTP/1.1 200 OK\r\n" |
| 177 "Content-Encoding: sdch\r\n" | 177 "Content-Encoding: sdch\r\n" |
| 178 "Content-Length: 12\r\n\r\n"), | 178 "Content-Length: 12\r\n\r\n"), |
| 179 MockRead("Test Content")}; | 179 MockRead("Test Content")}; |
| 180 | 180 |
| 181 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes, | 181 StaticSocketDataProvider socket_data(reads, arraysize(reads), writes, |
| 182 arraysize(writes)); | 182 arraysize(writes)); |
| 183 socket_factory_.AddSocketDataProvider(&socket_data); | 183 socket_factory_.AddSocketDataProvider(&socket_data); |
| 184 | 184 |
| 185 // This test expects TestURLRequestContexts to have no SdchManager. | 185 // This test expects TestURLRequestContexts to have no SdchManager. |
| 186 DCHECK(!context_.sdch_manager()); | 186 DCHECK(!context_.sdch_manager()); |
| 187 | 187 |
| 188 std::unique_ptr<URLRequest> request = | 188 std::unique_ptr<URLRequest> request = |
| 189 context_.CreateRequest(GURL("http://www.example.com"), DEFAULT_PRIORITY, | 189 context_.CreateRequest(GURL("http://www.example.com"), DEFAULT_PRIORITY, |
| 190 &delegate_, TRAFFIC_ANNOTATION_FOR_TESTS); | 190 &delegate_, TRAFFIC_ANNOTATION_FOR_TESTS); |
| 191 std::unique_ptr<TestURLRequestHttpJob> job( | 191 auto job = base::MakeUnique<TestURLRequestHttpJob>(request.get()); |
| 192 new TestURLRequestHttpJob(request.get())); | |
| 193 test_job_interceptor_->set_main_intercept_job(std::move(job)); | 192 test_job_interceptor_->set_main_intercept_job(std::move(job)); |
| 194 request->Start(); | 193 request->Start(); |
| 195 | 194 |
| 196 base::RunLoop().Run(); | 195 base::RunLoop().Run(); |
| 197 EXPECT_EQ(ERR_CONTENT_DECODING_FAILED, delegate_.request_status()); | 196 EXPECT_EQ(ERR_CONTENT_DECODING_FAILED, delegate_.request_status()); |
| 198 } | 197 } |
| 199 | 198 |
| 200 class URLRequestHttpJobTest : public ::testing::Test { | 199 class URLRequestHttpJobTest : public ::testing::Test { |
| 201 protected: | 200 protected: |
| 202 URLRequestHttpJobTest() : context_(true) { | 201 URLRequestHttpJobTest() : context_(true) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 for (const std::string& token : | 235 for (const std::string& token : |
| 237 base::SplitString(encoding_headers, ", ", base::KEEP_WHITESPACE, | 236 base::SplitString(encoding_headers, ", ", base::KEEP_WHITESPACE, |
| 238 base::SPLIT_WANT_NONEMPTY)) { | 237 base::SPLIT_WANT_NONEMPTY)) { |
| 239 if (base::EqualsCaseInsensitiveASCII(token, "sdch")) | 238 if (base::EqualsCaseInsensitiveASCII(token, "sdch")) |
| 240 return true; | 239 return true; |
| 241 } | 240 } |
| 242 return false; | 241 return false; |
| 243 } | 242 } |
| 244 | 243 |
| 245 void EnableSdch() { | 244 void EnableSdch() { |
| 246 context_.SetSdchManager(std::unique_ptr<SdchManager>(new SdchManager)); | 245 context_.SetSdchManager(base::MakeUnique<SdchManager>()); |
| 247 } | 246 } |
| 248 | 247 |
| 249 MockNetworkLayer network_layer_; | 248 MockNetworkLayer network_layer_; |
| 250 | 249 |
| 251 // |test_job_interceptor_| is owned by |test_job_factory_|. | 250 // |test_job_interceptor_| is owned by |test_job_factory_|. |
| 252 TestJobInterceptor* test_job_interceptor_; | 251 TestJobInterceptor* test_job_interceptor_; |
| 253 URLRequestJobFactoryImpl test_job_factory_; | 252 URLRequestJobFactoryImpl test_job_factory_; |
| 254 | 253 |
| 255 TestURLRequestContext context_; | 254 TestURLRequestContext context_; |
| 256 TestDelegate delegate_; | 255 TestDelegate delegate_; |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 request->Start(); | 693 request->Start(); |
| 695 request->Cancel(); | 694 request->Cancel(); |
| 696 base::RunLoop().Run(); | 695 base::RunLoop().Run(); |
| 697 | 696 |
| 698 EXPECT_THAT(delegate.request_status(), IsError(ERR_ABORTED)); | 697 EXPECT_THAT(delegate.request_status(), IsError(ERR_ABORTED)); |
| 699 } | 698 } |
| 700 | 699 |
| 701 // Make sure that SetPriority actually sets the URLRequestHttpJob's | 700 // Make sure that SetPriority actually sets the URLRequestHttpJob's |
| 702 // priority, before start. Other tests handle the after start case. | 701 // priority, before start. Other tests handle the after start case. |
| 703 TEST_F(URLRequestHttpJobTest, SetPriorityBasic) { | 702 TEST_F(URLRequestHttpJobTest, SetPriorityBasic) { |
| 704 std::unique_ptr<TestURLRequestHttpJob> job( | 703 auto job = base::MakeUnique<TestURLRequestHttpJob>(req_.get()); |
| 705 new TestURLRequestHttpJob(req_.get())); | |
| 706 EXPECT_EQ(DEFAULT_PRIORITY, job->priority()); | 704 EXPECT_EQ(DEFAULT_PRIORITY, job->priority()); |
| 707 | 705 |
| 708 job->SetPriority(LOWEST); | 706 job->SetPriority(LOWEST); |
| 709 EXPECT_EQ(LOWEST, job->priority()); | 707 EXPECT_EQ(LOWEST, job->priority()); |
| 710 | 708 |
| 711 job->SetPriority(LOW); | 709 job->SetPriority(LOW); |
| 712 EXPECT_EQ(LOW, job->priority()); | 710 EXPECT_EQ(LOW, job->priority()); |
| 713 } | 711 } |
| 714 | 712 |
| 715 // Make sure that URLRequestHttpJob passes on its priority to its | 713 // Make sure that URLRequestHttpJob passes on its priority to its |
| 716 // transaction on start. | 714 // transaction on start. |
| 717 TEST_F(URLRequestHttpJobTest, SetTransactionPriorityOnStart) { | 715 TEST_F(URLRequestHttpJobTest, SetTransactionPriorityOnStart) { |
| 718 test_job_interceptor_->set_main_intercept_job( | 716 test_job_interceptor_->set_main_intercept_job( |
| 719 base::WrapUnique(new TestURLRequestHttpJob(req_.get()))); | 717 base::MakeUnique<TestURLRequestHttpJob>(req_.get())); |
| 720 req_->SetPriority(LOW); | 718 req_->SetPriority(LOW); |
| 721 | 719 |
| 722 EXPECT_FALSE(network_layer_.last_transaction()); | 720 EXPECT_FALSE(network_layer_.last_transaction()); |
| 723 | 721 |
| 724 req_->Start(); | 722 req_->Start(); |
| 725 | 723 |
| 726 ASSERT_TRUE(network_layer_.last_transaction()); | 724 ASSERT_TRUE(network_layer_.last_transaction()); |
| 727 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); | 725 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); |
| 728 } | 726 } |
| 729 | 727 |
| 730 // Make sure that URLRequestHttpJob passes on its priority updates to | 728 // Make sure that URLRequestHttpJob passes on its priority updates to |
| 731 // its transaction. | 729 // its transaction. |
| 732 TEST_F(URLRequestHttpJobTest, SetTransactionPriority) { | 730 TEST_F(URLRequestHttpJobTest, SetTransactionPriority) { |
| 733 test_job_interceptor_->set_main_intercept_job( | 731 test_job_interceptor_->set_main_intercept_job( |
| 734 base::WrapUnique(new TestURLRequestHttpJob(req_.get()))); | 732 base::MakeUnique<TestURLRequestHttpJob>(req_.get())); |
| 735 req_->SetPriority(LOW); | 733 req_->SetPriority(LOW); |
| 736 req_->Start(); | 734 req_->Start(); |
| 737 ASSERT_TRUE(network_layer_.last_transaction()); | 735 ASSERT_TRUE(network_layer_.last_transaction()); |
| 738 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); | 736 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); |
| 739 | 737 |
| 740 req_->SetPriority(HIGHEST); | 738 req_->SetPriority(HIGHEST); |
| 741 EXPECT_EQ(HIGHEST, network_layer_.last_transaction()->priority()); | 739 EXPECT_EQ(HIGHEST, network_layer_.last_transaction()->priority()); |
| 742 } | 740 } |
| 743 | 741 |
| 744 // Confirm we do advertise SDCH encoding in the case of a GET. | 742 // Confirm we do advertise SDCH encoding in the case of a GET. |
| 745 TEST_F(URLRequestHttpJobTest, SdchAdvertisementGet) { | 743 TEST_F(URLRequestHttpJobTest, SdchAdvertisementGet) { |
| 746 EnableSdch(); | 744 EnableSdch(); |
| 747 req_->set_method("GET"); // Redundant with default. | 745 req_->set_method("GET"); // Redundant with default. |
| 748 test_job_interceptor_->set_main_intercept_job( | 746 test_job_interceptor_->set_main_intercept_job( |
| 749 base::WrapUnique(new TestURLRequestHttpJob(req_.get()))); | 747 base::MakeUnique<TestURLRequestHttpJob>(req_.get())); |
| 750 req_->Start(); | 748 req_->Start(); |
| 751 EXPECT_TRUE(TransactionAcceptsSdchEncoding()); | 749 EXPECT_TRUE(TransactionAcceptsSdchEncoding()); |
| 752 } | 750 } |
| 753 | 751 |
| 754 // Confirm we don't advertise SDCH encoding in the case of a POST. | 752 // Confirm we don't advertise SDCH encoding in the case of a POST. |
| 755 TEST_F(URLRequestHttpJobTest, SdchAdvertisementPost) { | 753 TEST_F(URLRequestHttpJobTest, SdchAdvertisementPost) { |
| 756 EnableSdch(); | 754 EnableSdch(); |
| 757 req_->set_method("POST"); | 755 req_->set_method("POST"); |
| 758 test_job_interceptor_->set_main_intercept_job( | 756 test_job_interceptor_->set_main_intercept_job( |
| 759 base::WrapUnique(new TestURLRequestHttpJob(req_.get()))); | 757 base::MakeUnique<TestURLRequestHttpJob>(req_.get())); |
| 760 req_->Start(); | 758 req_->Start(); |
| 761 EXPECT_FALSE(TransactionAcceptsSdchEncoding()); | 759 EXPECT_FALSE(TransactionAcceptsSdchEncoding()); |
| 762 } | 760 } |
| 763 | 761 |
| 764 TEST_F(URLRequestHttpJobTest, HSTSInternalRedirectTest) { | 762 TEST_F(URLRequestHttpJobTest, HSTSInternalRedirectTest) { |
| 765 // Setup HSTS state. | 763 // Setup HSTS state. |
| 766 context_.transport_security_state()->AddHSTS( | 764 context_.transport_security_state()->AddHSTS( |
| 767 "upgrade.test", base::Time::Now() + base::TimeDelta::FromSeconds(10), | 765 "upgrade.test", base::Time::Now() + base::TimeDelta::FromSeconds(10), |
| 768 true); | 766 true); |
| 769 ASSERT_TRUE( | 767 ASSERT_TRUE( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 MOCK_METHOD1(OnDictionaryRemoved, void(const std::string& server_hash)); | 828 MOCK_METHOD1(OnDictionaryRemoved, void(const std::string& server_hash)); |
| 831 MOCK_METHOD1(OnDictionaryUsed, void(const std::string& server_hash)); | 829 MOCK_METHOD1(OnDictionaryUsed, void(const std::string& server_hash)); |
| 832 MOCK_METHOD2(OnGetDictionary, | 830 MOCK_METHOD2(OnGetDictionary, |
| 833 void(const GURL& request_url, const GURL& dictionary_url)); | 831 void(const GURL& request_url, const GURL& dictionary_url)); |
| 834 MOCK_METHOD0(OnClearDictionaries, void()); | 832 MOCK_METHOD0(OnClearDictionaries, void()); |
| 835 }; | 833 }; |
| 836 | 834 |
| 837 class URLRequestHttpJobWithSdchSupportTest : public ::testing::Test { | 835 class URLRequestHttpJobWithSdchSupportTest : public ::testing::Test { |
| 838 protected: | 836 protected: |
| 839 URLRequestHttpJobWithSdchSupportTest() : context_(true) { | 837 URLRequestHttpJobWithSdchSupportTest() : context_(true) { |
| 840 std::unique_ptr<HttpNetworkSession::Params> params( | 838 auto params = base::MakeUnique<HttpNetworkSession::Params>(); |
| 841 new HttpNetworkSession::Params); | |
| 842 context_.set_http_network_session_params(std::move(params)); | 839 context_.set_http_network_session_params(std::move(params)); |
| 843 context_.set_client_socket_factory(&socket_factory_); | 840 context_.set_client_socket_factory(&socket_factory_); |
| 844 context_.Init(); | 841 context_.Init(); |
| 845 } | 842 } |
| 846 | 843 |
| 847 MockClientSocketFactory socket_factory_; | 844 MockClientSocketFactory socket_factory_; |
| 848 TestURLRequestContext context_; | 845 TestURLRequestContext context_; |
| 849 }; | 846 }; |
| 850 | 847 |
| 851 // Received a malformed SDCH encoded response that has no valid dictionary id. | 848 // Received a malformed SDCH encoded response that has no valid dictionary id. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 EXPECT_THAT(delegate2.request_status(), IsOk()); | 930 EXPECT_THAT(delegate2.request_status(), IsOk()); |
| 934 | 931 |
| 935 // Cleanup manager. | 932 // Cleanup manager. |
| 936 sdch_manager.RemoveObserver(&sdch_observer); | 933 sdch_manager.RemoveObserver(&sdch_observer); |
| 937 } | 934 } |
| 938 | 935 |
| 939 class URLRequestHttpJobWithBrotliSupportTest : public ::testing::Test { | 936 class URLRequestHttpJobWithBrotliSupportTest : public ::testing::Test { |
| 940 protected: | 937 protected: |
| 941 URLRequestHttpJobWithBrotliSupportTest() | 938 URLRequestHttpJobWithBrotliSupportTest() |
| 942 : context_(new TestURLRequestContext(true)) { | 939 : context_(new TestURLRequestContext(true)) { |
| 943 std::unique_ptr<HttpNetworkSession::Params> params( | 940 auto params = base::MakeUnique<HttpNetworkSession::Params>(); |
| 944 new HttpNetworkSession::Params); | |
| 945 context_->set_enable_brotli(true); | 941 context_->set_enable_brotli(true); |
| 946 context_->set_http_network_session_params(std::move(params)); | 942 context_->set_http_network_session_params(std::move(params)); |
| 947 context_->set_client_socket_factory(&socket_factory_); | 943 context_->set_client_socket_factory(&socket_factory_); |
| 948 context_->Init(); | 944 context_->Init(); |
| 949 } | 945 } |
| 950 | 946 |
| 951 MockClientSocketFactory socket_factory_; | 947 MockClientSocketFactory socket_factory_; |
| 952 std::unique_ptr<TestURLRequestContext> context_; | 948 std::unique_ptr<TestURLRequestContext> context_; |
| 953 }; | 949 }; |
| 954 | 950 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 bool initialize_stream_was_called_; | 1186 bool initialize_stream_was_called_; |
| 1191 }; | 1187 }; |
| 1192 | 1188 |
| 1193 TEST_F(URLRequestHttpJobWebSocketTest, RejectedWithoutCreateHelper) { | 1189 TEST_F(URLRequestHttpJobWebSocketTest, RejectedWithoutCreateHelper) { |
| 1194 req_->Start(); | 1190 req_->Start(); |
| 1195 base::RunLoop().RunUntilIdle(); | 1191 base::RunLoop().RunUntilIdle(); |
| 1196 EXPECT_THAT(delegate_.request_status(), IsError(ERR_DISALLOWED_URL_SCHEME)); | 1192 EXPECT_THAT(delegate_.request_status(), IsError(ERR_DISALLOWED_URL_SCHEME)); |
| 1197 } | 1193 } |
| 1198 | 1194 |
| 1199 TEST_F(URLRequestHttpJobWebSocketTest, CreateHelperPassedThrough) { | 1195 TEST_F(URLRequestHttpJobWebSocketTest, CreateHelperPassedThrough) { |
| 1200 std::unique_ptr<MockCreateHelper> create_helper( | 1196 std::unique_ptr<MockCreateHelper> create_helper = |
| 1201 new ::testing::StrictMock<MockCreateHelper>()); | 1197 base::MakeUnique<::testing::StrictMock<MockCreateHelper>>(); |
| 1202 FakeWebSocketHandshakeStream* fake_handshake_stream( | 1198 FakeWebSocketHandshakeStream* fake_handshake_stream( |
| 1203 new FakeWebSocketHandshakeStream); | 1199 new FakeWebSocketHandshakeStream); |
| 1204 // Ownership of fake_handshake_stream is transferred when CreateBasicStream() | 1200 // Ownership of fake_handshake_stream is transferred when CreateBasicStream() |
| 1205 // is called. | 1201 // is called. |
| 1206 EXPECT_CALL(*create_helper, CreateBasicStreamMock()) | 1202 EXPECT_CALL(*create_helper, CreateBasicStreamMock()) |
| 1207 .WillOnce(Return(fake_handshake_stream)); | 1203 .WillOnce(Return(fake_handshake_stream)); |
| 1208 req_->SetUserData(WebSocketHandshakeStreamBase::CreateHelper::DataKey(), | 1204 req_->SetUserData(WebSocketHandshakeStreamBase::CreateHelper::DataKey(), |
| 1209 std::move(create_helper)); | 1205 std::move(create_helper)); |
| 1210 req_->SetLoadFlags(LOAD_DISABLE_CACHE); | 1206 req_->SetLoadFlags(LOAD_DISABLE_CACHE); |
| 1211 req_->Start(); | 1207 req_->Start(); |
| 1212 base::RunLoop().RunUntilIdle(); | 1208 base::RunLoop().RunUntilIdle(); |
| 1213 EXPECT_THAT(delegate_.request_status(), IsError(ERR_IO_PENDING)); | 1209 EXPECT_THAT(delegate_.request_status(), IsError(ERR_IO_PENDING)); |
| 1214 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); | 1210 EXPECT_TRUE(fake_handshake_stream->initialize_stream_was_called()); |
| 1215 } | 1211 } |
| 1216 | 1212 |
| 1217 #endif // BUILDFLAG(ENABLE_WEBSOCKETS) | 1213 #endif // BUILDFLAG(ENABLE_WEBSOCKETS) |
| 1218 | 1214 |
| 1219 } // namespace | 1215 } // namespace |
| 1220 | 1216 |
| 1221 } // namespace net | 1217 } // namespace net |
| OLD | NEW |