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

Side by Side Diff: content/public/test/test_download_request_handler.cc

Issue 2672113002: Remove URLRequestJob::GetResponseCode implementations from some tests.
Patch Set: Created 3 years, 10 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 | « content/browser/fileapi/file_writer_delegate_unittest.cc ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/public/test/test_download_request_handler.h" 5 #include "content/public/test/test_download_request_handler.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 static net::URLRequestJob* Factory(const Parameters& parameters, 101 static net::URLRequestJob* Factory(const Parameters& parameters,
102 net::URLRequest* request, 102 net::URLRequest* request,
103 net::NetworkDelegate* delegate, 103 net::NetworkDelegate* delegate,
104 base::WeakPtr<Interceptor> interceptor); 104 base::WeakPtr<Interceptor> interceptor);
105 105
106 // URLRequestJob 106 // URLRequestJob
107 void Start() override; 107 void Start() override;
108 void GetResponseInfo(net::HttpResponseInfo* response_info) override; 108 void GetResponseInfo(net::HttpResponseInfo* response_info) override;
109 int64_t GetTotalReceivedBytes() const override; 109 int64_t GetTotalReceivedBytes() const override;
110 bool GetMimeType(std::string* mime_type) const override; 110 bool GetMimeType(std::string* mime_type) const override;
111 int GetResponseCode() const override;
112 int ReadRawData(net::IOBuffer* buf, int buf_size) override; 111 int ReadRawData(net::IOBuffer* buf, int buf_size) override;
113 112
114 private: 113 private:
115 PartialResponseJob(std::unique_ptr<Parameters> parameters, 114 PartialResponseJob(std::unique_ptr<Parameters> parameters,
116 base::WeakPtr<Interceptor> interceptor, 115 base::WeakPtr<Interceptor> interceptor,
117 net::URLRequest* url_request, 116 net::URLRequest* url_request,
118 net::NetworkDelegate* network_delegate); 117 net::NetworkDelegate* network_delegate);
119 118
120 ~PartialResponseJob() override; 119 ~PartialResponseJob() override;
121 void ReportCompletedRequest(); 120 void ReportCompletedRequest();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 const { 266 const {
268 return offset_of_next_read_ - requested_range_begin_; 267 return offset_of_next_read_ - requested_range_begin_;
269 } 268 }
270 269
271 bool TestDownloadRequestHandler::PartialResponseJob::GetMimeType( 270 bool TestDownloadRequestHandler::PartialResponseJob::GetMimeType(
272 std::string* mime_type) const { 271 std::string* mime_type) const {
273 *mime_type = parameters_->content_type; 272 *mime_type = parameters_->content_type;
274 return !parameters_->content_type.empty(); 273 return !parameters_->content_type.empty();
275 } 274 }
276 275
277 int TestDownloadRequestHandler::PartialResponseJob::GetResponseCode() const {
278 return response_info_.headers.get() ? response_info_.headers->response_code()
279 : 0;
280 }
281
282 int TestDownloadRequestHandler::PartialResponseJob::ReadRawData( 276 int TestDownloadRequestHandler::PartialResponseJob::ReadRawData(
283 net::IOBuffer* buf, 277 net::IOBuffer* buf,
284 int buf_size) { 278 int buf_size) {
285 DVLOG(1) << "Preparing to read " << buf_size << " bytes"; 279 DVLOG(1) << "Preparing to read " << buf_size << " bytes";
286 280
287 // requested_range_begin_ == -1 implies that the body was empty. 281 // requested_range_begin_ == -1 implies that the body was empty.
288 if (offset_of_next_read_ > requested_range_end_ || 282 if (offset_of_next_read_ > requested_range_end_ ||
289 requested_range_begin_ == -1) { 283 requested_range_begin_ == -1) {
290 DVLOG(1) << "Done reading."; 284 DVLOG(1) << "Done reading.";
291 return 0; 285 return 0;
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 base::RunLoop run_loop; 683 base::RunLoop run_loop;
690 BrowserThread::PostTaskAndReply( 684 BrowserThread::PostTaskAndReply(
691 BrowserThread::IO, FROM_HERE, 685 BrowserThread::IO, FROM_HERE,
692 base::Bind(&Interceptor::GetAndResetCompletedRequests, interceptor_, 686 base::Bind(&Interceptor::GetAndResetCompletedRequests, interceptor_,
693 requests), 687 requests),
694 run_loop.QuitClosure()); 688 run_loop.QuitClosure());
695 run_loop.Run(); 689 run_loop.Run();
696 } 690 }
697 691
698 } // namespace content 692 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/fileapi/file_writer_delegate_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698