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

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

Issue 2670013002: net: remove GetNormalizedHeaders() function (Closed)
Patch Set: n 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 | « no previous file | google_apis/drive/base_requests.cc » ('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 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>
11 11
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/sequenced_task_runner.h" 18 #include "base/sequenced_task_runner.h"
19 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/threading/sequenced_task_runner_handle.h" 21 #include "base/threading/sequenced_task_runner_handle.h"
22 #include "base/threading/thread_task_runner_handle.h" 22 #include "base/threading/thread_task_runner_handle.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "net/base/io_buffer.h" 24 #include "net/base/io_buffer.h"
25 #include "net/http/http_request_headers.h" 25 #include "net/http/http_request_headers.h"
26 #include "net/http/http_response_headers.h" 26 #include "net/http/http_response_headers.h"
27 #include "net/http/http_util.h"
27 #include "net/url_request/url_request_filter.h" 28 #include "net/url_request/url_request_filter.h"
28 #include "net/url_request/url_request_interceptor.h" 29 #include "net/url_request/url_request_interceptor.h"
29 30
30 namespace content { 31 namespace content {
31 32
32 // Intercepts URLRequests on behalf of TestDownloadRequestHandler. Necessarily 33 // Intercepts URLRequests on behalf of TestDownloadRequestHandler. Necessarily
33 // lives on the IO thread since that's where net::URLRequestFilter invokes the 34 // lives on the IO thread since that's where net::URLRequestFilter invokes the
34 // URLRequestInterceptor. 35 // URLRequestInterceptor.
35 class TestDownloadRequestHandler::Interceptor 36 class TestDownloadRequestHandler::Interceptor
36 : public net::URLRequestInterceptor { 37 : public net::URLRequestInterceptor {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 response_info_.headers->AddHeader( 471 response_info_.headers->AddHeader(
471 base::StringPrintf("ETag: %s", parameters_->etag.c_str())); 472 base::StringPrintf("ETag: %s", parameters_->etag.c_str()));
472 473
473 if (!parameters_->last_modified.empty()) 474 if (!parameters_->last_modified.empty())
474 response_info_.headers->AddHeader(base::StringPrintf( 475 response_info_.headers->AddHeader(base::StringPrintf(
475 "Last-Modified: %s", parameters_->last_modified.c_str())); 476 "Last-Modified: %s", parameters_->last_modified.c_str()));
476 } 477 }
477 478
478 void TestDownloadRequestHandler::PartialResponseJob:: 479 void TestDownloadRequestHandler::PartialResponseJob::
479 NotifyHeadersCompleteAndPrepareToRead() { 480 NotifyHeadersCompleteAndPrepareToRead() {
480 std::string normalized_headers; 481 std::string normalized_headers =
481 response_info_.headers->GetNormalizedHeaders(&normalized_headers); 482 net::HttpUtil::ConvertHeadersBackToHTTPResponse(
483 response_info_.headers->raw_headers());
482 DVLOG(1) << "Notify ready with headers:\n" << normalized_headers; 484 DVLOG(1) << "Notify ready with headers:\n" << normalized_headers;
483 485
484 offset_of_next_read_ = requested_range_begin_; 486 offset_of_next_read_ = requested_range_begin_;
485 487
486 // Flush out injected_errors that no longer apply. We are going to skip over 488 // Flush out injected_errors that no longer apply. We are going to skip over
487 // ones where the |offset| == |requested_range_begin_| as well. While it 489 // ones where the |offset| == |requested_range_begin_| as well. While it
488 // prevents injecting an error at offset 0, it makes it much easier to set up 490 // prevents injecting an error at offset 0, it makes it much easier to set up
489 // parameter sets for download resumption. It means that when a request is 491 // parameter sets for download resumption. It means that when a request is
490 // interrupted at offset O, a subsequent request for the range O-<end> won't 492 // interrupted at offset O, a subsequent request for the range O-<end> won't
491 // immediately interrupt as well. If we don't exclude interruptions at 493 // immediately interrupt as well. If we don't exclude interruptions at
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 base::RunLoop run_loop; 691 base::RunLoop run_loop;
690 BrowserThread::PostTaskAndReply( 692 BrowserThread::PostTaskAndReply(
691 BrowserThread::IO, FROM_HERE, 693 BrowserThread::IO, FROM_HERE,
692 base::Bind(&Interceptor::GetAndResetCompletedRequests, interceptor_, 694 base::Bind(&Interceptor::GetAndResetCompletedRequests, interceptor_,
693 requests), 695 requests),
694 run_loop.QuitClosure()); 696 run_loop.QuitClosure());
695 run_loop.Run(); 697 run_loop.Run();
696 } 698 }
697 699
698 } // namespace content 700 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | google_apis/drive/base_requests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698