Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: net/quic/chromium/quic_http_stream_test.cc

Issue 2334943002: Add a new QuicChromiumClientSession::Handle class (Closed)
Patch Set: fixes Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/chromium/quic_http_stream.cc ('k') | net/quic/chromium/quic_stream_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/quic/chromium/quic_http_stream.h" 5 #include "net/quic/chromium/quic_http_stream.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) { 95 void SetSendAlgorithm(SendAlgorithmInterface* send_algorithm) {
96 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm); 96 QuicConnectionPeer::SetSendAlgorithm(this, send_algorithm);
97 } 97 }
98 }; 98 };
99 99
100 // Subclass of QuicHttpStream that closes itself when the first piece of data 100 // Subclass of QuicHttpStream that closes itself when the first piece of data
101 // is received. 101 // is received.
102 class AutoClosingStream : public QuicHttpStream { 102 class AutoClosingStream : public QuicHttpStream {
103 public: 103 public:
104 explicit AutoClosingStream( 104 explicit AutoClosingStream(
105 const base::WeakPtr<QuicChromiumClientSession>& session, 105 std::unique_ptr<QuicChromiumClientSession::Handle> session,
106 HttpServerProperties* http_server_properties) 106 HttpServerProperties* http_server_properties)
107 : QuicHttpStream(session, http_server_properties) {} 107 : QuicHttpStream(std::move(session), http_server_properties) {}
108 108
109 void OnHeadersAvailable(const SpdyHeaderBlock& headers, 109 void OnHeadersAvailable(const SpdyHeaderBlock& headers,
110 size_t frame_len) override { 110 size_t frame_len) override {
111 Close(false); 111 Close(false);
112 } 112 }
113 113
114 void OnDataAvailable() override { Close(false); } 114 void OnDataAvailable() override { Close(false); }
115 }; 115 };
116 116
117 // UploadDataStream that always returns errors on data read. 117 // UploadDataStream that always returns errors on data read.
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 QuicServerId(kDefaultServerHostName, kDefaultServerPort, 314 QuicServerId(kDefaultServerHostName, kDefaultServerPort,
315 PRIVACY_MODE_DISABLED), 315 PRIVACY_MODE_DISABLED),
316 /*require_confirmation=*/false, kQuicYieldAfterPacketsRead, 316 /*require_confirmation=*/false, kQuicYieldAfterPacketsRead,
317 QuicTime::Delta::FromMilliseconds(kQuicYieldAfterDurationMilliseconds), 317 QuicTime::Delta::FromMilliseconds(kQuicYieldAfterDurationMilliseconds),
318 /*cert_verify_flags=*/0, DefaultQuicConfig(), &crypto_config_, 318 /*cert_verify_flags=*/0, DefaultQuicConfig(), &crypto_config_,
319 "CONNECTION_UNKNOWN", dns_start, dns_end, &push_promise_index_, nullptr, 319 "CONNECTION_UNKNOWN", dns_start, dns_end, &push_promise_index_, nullptr,
320 base::ThreadTaskRunnerHandle::Get().get(), 320 base::ThreadTaskRunnerHandle::Get().get(),
321 /*socket_performance_watcher=*/nullptr, net_log_.bound().net_log())); 321 /*socket_performance_watcher=*/nullptr, net_log_.bound().net_log()));
322 session_->Initialize(); 322 session_->Initialize();
323 TestCompletionCallback callback; 323 TestCompletionCallback callback;
324
324 session_->CryptoConnect(callback.callback()); 325 session_->CryptoConnect(callback.callback());
325 stream_.reset(use_closing_stream_ 326 stream_.reset(use_closing_stream_
326 ? new AutoClosingStream(session_->GetWeakPtr(), 327 ? new AutoClosingStream(session_->CreateHandle(),
327 &http_server_properties_) 328 &http_server_properties_)
328 : new QuicHttpStream(session_->GetWeakPtr(), 329 : new QuicHttpStream(session_->CreateHandle(),
329 &http_server_properties_)); 330 &http_server_properties_));
330 331
331 promised_stream_.reset(use_closing_stream_ 332 promised_stream_.reset(use_closing_stream_
332 ? new AutoClosingStream(session_->GetWeakPtr(), 333 ? new AutoClosingStream(session_->CreateHandle(),
333 &http_server_properties_) 334 &http_server_properties_)
334 : new QuicHttpStream(session_->GetWeakPtr(), 335 : new QuicHttpStream(session_->CreateHandle(),
335 &http_server_properties_)); 336 &http_server_properties_));
336 337
337 push_promise_[":path"] = "/bar"; 338 push_promise_[":path"] = "/bar";
338 push_promise_[":authority"] = "www.example.org"; 339 push_promise_[":authority"] = "www.example.org";
339 push_promise_[":version"] = "HTTP/1.1"; 340 push_promise_[":version"] = "HTTP/1.1";
340 push_promise_[":method"] = "GET"; 341 push_promise_[":method"] = "GET";
341 push_promise_[":scheme"] = "https"; 342 push_promise_[":scheme"] = "https";
342 343
343 promised_response_[":status"] = "200 OK"; 344 promised_response_[":status"] = "200 OK";
344 promised_response_[":version"] = "HTTP/1.1"; 345 promised_response_[":version"] = "HTTP/1.1";
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 request_.method = "GET"; 705 request_.method = "GET";
705 request_.url = GURL("https://www.example.org/"); 706 request_.url = GURL("https://www.example.org/");
706 // Start first request. 707 // Start first request.
707 EXPECT_EQ(OK, 708 EXPECT_EQ(OK,
708 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, 709 stream_->InitializeStream(&request_, DEFAULT_PRIORITY,
709 net_log_.bound(), callback_.callback())); 710 net_log_.bound(), callback_.callback()));
710 EXPECT_EQ(OK, 711 EXPECT_EQ(OK,
711 stream_->SendRequest(headers_, &response_, callback_.callback())); 712 stream_->SendRequest(headers_, &response_, callback_.callback()));
712 713
713 // Start a second request. 714 // Start a second request.
714 QuicHttpStream stream2(session_->GetWeakPtr(), &http_server_properties_); 715 QuicHttpStream stream2(session_->CreateHandle(), &http_server_properties_);
715 TestCompletionCallback callback2; 716 TestCompletionCallback callback2;
716 EXPECT_EQ(OK, 717 EXPECT_EQ(OK,
717 stream2.InitializeStream(&request_, DEFAULT_PRIORITY, 718 stream2.InitializeStream(&request_, DEFAULT_PRIORITY,
718 net_log_.bound(), callback2.callback())); 719 net_log_.bound(), callback2.callback()));
719 EXPECT_EQ(OK, 720 EXPECT_EQ(OK,
720 stream2.SendRequest(headers_, &response_, callback2.callback())); 721 stream2.SendRequest(headers_, &response_, callback2.callback()));
721 722
722 // Ack both requests. 723 // Ack both requests.
723 ProcessPacket(ConstructServerAckPacket(1, 0, 0, 0)); 724 ProcessPacket(ConstructServerAckPacket(1, 0, 0, 0));
724 725
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 EXPECT_TRUE(AtEof()); 2141 EXPECT_TRUE(AtEof());
2141 2142
2142 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. 2143 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers.
2143 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), 2144 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length),
2144 stream_->GetTotalSentBytes()); 2145 stream_->GetTotalSentBytes());
2145 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); 2146 EXPECT_EQ(0, stream_->GetTotalReceivedBytes());
2146 } 2147 }
2147 2148
2148 } // namespace test 2149 } // namespace test
2149 } // namespace net 2150 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_http_stream.cc ('k') | net/quic/chromium/quic_stream_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698