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

Side by Side Diff: net/http/http_response_body_drainer_unittest.cc

Issue 403393003: HTTP retry support. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
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/http/http_response_body_drainer.h" 5 #include "net/http/http_response_body_drainer.h"
6 6
7 #include <cstring> 7 #include <cstring>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 virtual int ReadResponseHeaders(const CompletionCallback& callback) OVERRIDE { 93 virtual int ReadResponseHeaders(const CompletionCallback& callback) OVERRIDE {
94 return ERR_UNEXPECTED; 94 return ERR_UNEXPECTED;
95 } 95 }
96 96
97 virtual bool CanFindEndOfResponse() const OVERRIDE { return true; } 97 virtual bool CanFindEndOfResponse() const OVERRIDE { return true; }
98 virtual bool IsConnectionReused() const OVERRIDE { return false; } 98 virtual bool IsConnectionReused() const OVERRIDE { return false; }
99 virtual void SetConnectionReused() OVERRIDE {} 99 virtual void SetConnectionReused() OVERRIDE {}
100 virtual bool IsConnectionReusable() const OVERRIDE { return false; } 100 virtual bool IsConnectionReusable() const OVERRIDE { return false; }
101 virtual int64 GetTotalReceivedBytes() const OVERRIDE { return 0; } 101 virtual int64 GetTotalReceivedBytes() const OVERRIDE { return 0; }
102 virtual int64 GetReceivedBodyLength() const OVERRIDE { return 0; }
102 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE {} 103 virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE {}
103 virtual void GetSSLCertRequestInfo( 104 virtual void GetSSLCertRequestInfo(
104 SSLCertRequestInfo* cert_request_info) OVERRIDE {} 105 SSLCertRequestInfo* cert_request_info) OVERRIDE {}
105 106
106 // Mocked API 107 // Mocked API
107 virtual int ReadResponseBody(IOBuffer* buf, int buf_len, 108 virtual int ReadResponseBody(IOBuffer* buf, int buf_len,
108 const CompletionCallback& callback) OVERRIDE; 109 const CompletionCallback& callback) OVERRIDE;
109 virtual void Close(bool not_reusable) OVERRIDE { 110 virtual void Close(bool not_reusable) OVERRIDE {
110 CHECK(!closed_); 111 CHECK(!closed_);
111 closed_ = true; 112 closed_ = true;
112 result_waiter_->set_result(not_reusable); 113 result_waiter_->set_result(not_reusable);
113 } 114 }
114 115
115 virtual HttpStream* RenewStreamForAuth() OVERRIDE { 116 virtual HttpStream* RenewStreamForAuth() OVERRIDE {
116 return NULL; 117 return NULL;
117 } 118 }
118 119
119 virtual bool IsResponseBodyComplete() const OVERRIDE { return is_complete_; } 120 virtual bool IsResponseBodyComplete() const OVERRIDE { return is_complete_; }
120 121
121 virtual bool IsSpdyHttpStream() const OVERRIDE { return false; } 122 virtual bool IsSpdyHttpStream() const OVERRIDE { return false; }
122 123
123 virtual bool GetLoadTimingInfo( 124 virtual bool GetLoadTimingInfo(
124 LoadTimingInfo* load_timing_info) const OVERRIDE { return false; } 125 LoadTimingInfo* load_timing_info) const OVERRIDE { return false; }
125 126
126 virtual void Drain(HttpNetworkSession*) OVERRIDE {} 127 virtual void Drain(HttpNetworkSession*) OVERRIDE {}
127 128
128 virtual void SetPriority(RequestPriority priority) OVERRIDE {} 129 virtual void SetPriority(RequestPriority priority) OVERRIDE {}
129 130
131 virtual void SetRestartInfo(int64 read_offset, const void* hash,
132 size_t hash_length) OVERRIDE {}
133
134 virtual void GetHash(void* output, size_t len) OVERRIDE {}
135
136
130 // Methods to tweak/observer mock behavior: 137 // Methods to tweak/observer mock behavior:
131 void set_stall_reads_forever() { stall_reads_forever_ = true; } 138 void set_stall_reads_forever() { stall_reads_forever_ = true; }
132 139
133 void set_num_chunks(int num_chunks) { num_chunks_ = num_chunks; } 140 void set_num_chunks(int num_chunks) { num_chunks_ = num_chunks; }
134 141
135 void set_sync() { is_sync_ = true; } 142 void set_sync() { is_sync_ = true; }
136 143
137 void set_is_last_chunk_zero_size() { is_last_chunk_zero_size_ = true; } 144 void set_is_last_chunk_zero_size() { is_last_chunk_zero_size_ = true; }
138 145
139 private: 146 private:
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 too_many_chunks += 1; // Now it's too large. 305 too_many_chunks += 1; // Now it's too large.
299 306
300 mock_stream_->set_num_chunks(too_many_chunks); 307 mock_stream_->set_num_chunks(too_many_chunks);
301 drainer_->Start(session_.get()); 308 drainer_->Start(session_.get());
302 EXPECT_TRUE(result_waiter_.WaitForResult()); 309 EXPECT_TRUE(result_waiter_.WaitForResult());
303 } 310 }
304 311
305 } // namespace 312 } // namespace
306 313
307 } // namespace net 314 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698