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

Side by Side Diff: android_webview/browser/net/android_stream_reader_url_request_job.cc

Issue 2824813002: Remove URLRequestJob::GetResponseCode implementations. (Closed)
Patch Set: Fix more stuff Created 3 years, 8 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 "android_webview/browser/net/android_stream_reader_url_request_job.h" 5 #include "android_webview/browser/net/android_stream_reader_url_request_job.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "android_webview/browser/input_stream.h" 10 #include "android_webview/browser/input_stream.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 342
343 // Indicate that the response had been obtained via shouldInterceptRequest. 343 // Indicate that the response had been obtained via shouldInterceptRequest.
344 headers->AddHeader(kResponseHeaderViaShouldInterceptRequest); 344 headers->AddHeader(kResponseHeaderViaShouldInterceptRequest);
345 345
346 response_info_.reset(new net::HttpResponseInfo()); 346 response_info_.reset(new net::HttpResponseInfo());
347 response_info_->headers = headers; 347 response_info_->headers = headers;
348 348
349 NotifyHeadersComplete(); 349 NotifyHeadersComplete();
350 } 350 }
351 351
352 int AndroidStreamReaderURLRequestJob::GetResponseCode() const {
353 if (response_info_)
354 return response_info_->headers->response_code();
355 return URLRequestJob::GetResponseCode();
356 }
357
358 void AndroidStreamReaderURLRequestJob::GetResponseInfo( 352 void AndroidStreamReaderURLRequestJob::GetResponseInfo(
359 net::HttpResponseInfo* info) { 353 net::HttpResponseInfo* info) {
360 if (response_info_) 354 if (response_info_)
361 *info = *response_info_; 355 *info = *response_info_;
362 } 356 }
363 357
364 void AndroidStreamReaderURLRequestJob::SetExtraRequestHeaders( 358 void AndroidStreamReaderURLRequestJob::SetExtraRequestHeaders(
365 const net::HttpRequestHeaders& headers) { 359 const net::HttpRequestHeaders& headers) {
366 std::string range_header; 360 std::string range_header;
367 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) { 361 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) {
368 // This job only cares about the Range header so that we know how many bytes 362 // This job only cares about the Range header so that we know how many bytes
369 // in the stream to skip and how many to read after that. Note that 363 // in the stream to skip and how many to read after that. Note that
370 // validation is deferred to DoStart(), because NotifyStartError() is not 364 // validation is deferred to DoStart(), because NotifyStartError() is not
371 // legal to call since the job has not started. 365 // legal to call since the job has not started.
372 std::vector<net::HttpByteRange> ranges; 366 std::vector<net::HttpByteRange> ranges;
373 if (net::HttpUtil::ParseRangeHeader(range_header, &ranges)) { 367 if (net::HttpUtil::ParseRangeHeader(range_header, &ranges)) {
374 if (ranges.size() == 1) 368 if (ranges.size() == 1)
375 byte_range_ = ranges[0]; 369 byte_range_ = ranges[0];
376 } else { 370 } else {
377 // We don't support multiple range requests in one single URL request, 371 // We don't support multiple range requests in one single URL request,
378 // because we need to do multipart encoding here. 372 // because we need to do multipart encoding here.
379 range_parse_result_ = net::ERR_REQUEST_RANGE_NOT_SATISFIABLE; 373 range_parse_result_ = net::ERR_REQUEST_RANGE_NOT_SATISFIABLE;
380 } 374 }
381 } 375 }
382 } 376 }
383 377
384 } // namespace android_webview 378 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698