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

Side by Side Diff: net/tools/quic/test_tools/quic_test_client.cc

Issue 2589983002: Create a QUIC wrapper around scoped_refptr. (Closed)
Patch Set: rm = nullptr Created 3 years, 12 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/tools/quic/test_tools/quic_test_client.h ('k') | no next file » | 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/tools/quic/test_tools/quic_test_client.h" 5 #include "net/tools/quic/test_tools/quic_test_client.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 285 }
286 while (client()->WaitForEvents()) { 286 while (client()->WaitForEvents()) {
287 } 287 }
288 return; 288 return;
289 } 289 }
290 290
291 ssize_t QuicTestClient::GetOrCreateStreamAndSendRequest( 291 ssize_t QuicTestClient::GetOrCreateStreamAndSendRequest(
292 const SpdyHeaderBlock* headers, 292 const SpdyHeaderBlock* headers,
293 StringPiece body, 293 StringPiece body,
294 bool fin, 294 bool fin,
295 scoped_refptr<QuicAckListenerInterface> delegate) { 295 QuicReferenceCountedPointer<QuicAckListenerInterface> delegate) {
296 if (headers) { 296 if (headers) {
297 QuicClientPushPromiseIndex::TryHandle* handle; 297 QuicClientPushPromiseIndex::TryHandle* handle;
298 QuicAsyncStatus rv = 298 QuicAsyncStatus rv =
299 client()->push_promise_index()->Try(*headers, this, &handle); 299 client()->push_promise_index()->Try(*headers, this, &handle);
300 if (rv == QUIC_SUCCESS) 300 if (rv == QUIC_SUCCESS)
301 return 1; 301 return 1;
302 if (rv == QUIC_PENDING) { 302 if (rv == QUIC_PENDING) {
303 // May need to retry request if asynchronous rendezvous fails. 303 // May need to retry request if asynchronous rendezvous fails.
304 std::unique_ptr<SpdyHeaderBlock> new_headers( 304 std::unique_ptr<SpdyHeaderBlock> new_headers(
305 new SpdyHeaderBlock(headers->Clone())); 305 new SpdyHeaderBlock(headers->Clone()));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return ret; 370 return ret;
371 } 371 }
372 372
373 ssize_t QuicTestClient::SendData(const string& data, bool last_data) { 373 ssize_t QuicTestClient::SendData(const string& data, bool last_data) {
374 return SendData(data, last_data, nullptr); 374 return SendData(data, last_data, nullptr);
375 } 375 }
376 376
377 ssize_t QuicTestClient::SendData( 377 ssize_t QuicTestClient::SendData(
378 const string& data, 378 const string& data,
379 bool last_data, 379 bool last_data,
380 scoped_refptr<QuicAckListenerInterface> delegate) { 380 QuicReferenceCountedPointer<QuicAckListenerInterface> delegate) {
381 return GetOrCreateStreamAndSendRequest(nullptr, StringPiece(data), last_data, 381 return GetOrCreateStreamAndSendRequest(nullptr, StringPiece(data), last_data,
382 std::move(delegate)); 382 std::move(delegate));
383 } 383 }
384 384
385 bool QuicTestClient::response_complete() const { 385 bool QuicTestClient::response_complete() const {
386 return response_complete_; 386 return response_complete_;
387 } 387 }
388 388
389 int64_t QuicTestClient::response_body_size() const { 389 int64_t QuicTestClient::response_body_size() const {
390 return response_body_size_; 390 return response_body_size_;
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 while (connected() && client()->session()->HasDataToWrite()) { 670 while (connected() && client()->session()->HasDataToWrite()) {
671 client_->WaitForEvents(); 671 client_->WaitForEvents();
672 } 672 }
673 } 673 }
674 674
675 QuicTestClient::TestClientDataToResend::TestClientDataToResend( 675 QuicTestClient::TestClientDataToResend::TestClientDataToResend(
676 std::unique_ptr<SpdyHeaderBlock> headers, 676 std::unique_ptr<SpdyHeaderBlock> headers,
677 base::StringPiece body, 677 base::StringPiece body,
678 bool fin, 678 bool fin,
679 QuicTestClient* test_client, 679 QuicTestClient* test_client,
680 scoped_refptr<QuicAckListenerInterface> delegate) 680 QuicReferenceCountedPointer<QuicAckListenerInterface> delegate)
681 : QuicClient::QuicDataToResend(std::move(headers), body, fin), 681 : QuicClient::QuicDataToResend(std::move(headers), body, fin),
682 test_client_(test_client), 682 test_client_(test_client),
683 delegate_(std::move(delegate)) {} 683 delegate_(std::move(delegate)) {}
684 684
685 QuicTestClient::TestClientDataToResend::~TestClientDataToResend() {} 685 QuicTestClient::TestClientDataToResend::~TestClientDataToResend() {}
686 686
687 void QuicTestClient::TestClientDataToResend::Resend() { 687 void QuicTestClient::TestClientDataToResend::Resend() {
688 test_client_->GetOrCreateStreamAndSendRequest(headers_.get(), body_, fin_, 688 test_client_->GetOrCreateStreamAndSendRequest(headers_.get(), body_, fin_,
689 delegate_); 689 delegate_);
690 headers_.reset(); 690 headers_.reset();
691 } 691 }
692 692
693 bool QuicTestClient::PopulateHeaderBlockFromUrl(const string& uri, 693 bool QuicTestClient::PopulateHeaderBlockFromUrl(const string& uri,
694 SpdyHeaderBlock* headers) { 694 SpdyHeaderBlock* headers) {
695 string url; 695 string url;
696 if (base::StartsWith(uri, "https://", base::CompareCase::INSENSITIVE_ASCII) || 696 if (base::StartsWith(uri, "https://", base::CompareCase::INSENSITIVE_ASCII) ||
697 base::StartsWith(uri, "http://", base::CompareCase::INSENSITIVE_ASCII)) { 697 base::StartsWith(uri, "http://", base::CompareCase::INSENSITIVE_ASCII)) {
698 url = uri; 698 url = uri;
699 } else if (uri[0] == '/') { 699 } else if (uri[0] == '/') {
700 url = "https://" + client_->server_id().host() + uri; 700 url = "https://" + client_->server_id().host() + uri;
701 } else { 701 } else {
702 url = "https://" + uri; 702 url = "https://" + uri;
703 } 703 }
704 return SpdyUtils::PopulateHeaderBlockFromUrl(url, headers); 704 return SpdyUtils::PopulateHeaderBlockFromUrl(url, headers);
705 } 705 }
706 706
707 } // namespace test 707 } // namespace test
708 } // namespace net 708 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/quic_test_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698