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

Side by Side Diff: content/child/resource_dispatcher_unittest.cc

Issue 398903002: Plumb redirect info out of net, through content, and into child processes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a TODO 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 | Annotate | Revision Log
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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 received_response_(false), 52 received_response_(false),
53 total_encoded_data_length_(0), 53 total_encoded_data_length_(0),
54 total_downloaded_data_length_(0), 54 total_downloaded_data_length_(0),
55 complete_(false), 55 complete_(false),
56 bridge_(bridge) { 56 bridge_(bridge) {
57 } 57 }
58 58
59 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE { 59 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE {
60 } 60 }
61 61
62 virtual bool OnReceivedRedirect(const GURL& new_url, 62 virtual bool OnReceivedRedirect(const net::RedirectInfo& redirect_info,
63 const GURL& new_first_party_for_cookies,
64 const ResourceResponseInfo& info) OVERRIDE { 63 const ResourceResponseInfo& info) OVERRIDE {
65 ++seen_redirects_; 64 ++seen_redirects_;
66 if (defer_on_redirect_) 65 if (defer_on_redirect_)
67 bridge_->SetDefersLoading(true); 66 bridge_->SetDefersLoading(true);
68 return follow_redirects_; 67 return follow_redirects_;
69 } 68 }
70 69
71 virtual void OnReceivedResponse(const ResourceResponseInfo& info) OVERRIDE { 70 virtual void OnReceivedResponse(const ResourceResponseInfo& info) OVERRIDE {
72 EXPECT_FALSE(received_response_); 71 EXPECT_FALSE(received_response_);
73 received_response_ = true; 72 received_response_ = true;
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 EXPECT_EQ(expected_request_id, args.a); 244 EXPECT_EQ(expected_request_id, args.a);
246 message_queue_.erase(message_queue_.begin()); 245 message_queue_.erase(message_queue_.begin());
247 } 246 }
248 247
249 void NotifyReceivedRedirect(int request_id) { 248 void NotifyReceivedRedirect(int request_id) {
250 ResourceResponseHead head; 249 ResourceResponseHead head;
251 std::string raw_headers(kTestRedirectHeaders); 250 std::string raw_headers(kTestRedirectHeaders);
252 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0'); 251 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0');
253 head.headers = new net::HttpResponseHeaders(raw_headers); 252 head.headers = new net::HttpResponseHeaders(raw_headers);
254 head.error_code = net::OK; 253 head.error_code = net::OK;
254 net::RedirectInfo redirect_info;
255 redirect_info.status_code = 302;
256 redirect_info.method = "GET";
257 redirect_info.url = GURL(kTestPageUrl);
258 redirect_info.first_party_for_cookies = GURL(kTestPageUrl);
255 EXPECT_EQ(true, dispatcher_.OnMessageReceived( 259 EXPECT_EQ(true, dispatcher_.OnMessageReceived(
256 ResourceMsg_ReceivedRedirect(request_id, GURL(kTestPageUrl), 260 ResourceMsg_ReceivedRedirect(request_id, redirect_info, head)));
257 GURL(kTestPageUrl), head)));
258 } 261 }
259 262
260 void NotifyReceivedResponse(int request_id) { 263 void NotifyReceivedResponse(int request_id) {
261 ResourceResponseHead head; 264 ResourceResponseHead head;
262 std::string raw_headers(kTestPageHeaders); 265 std::string raw_headers(kTestPageHeaders);
263 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0'); 266 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0');
264 head.headers = new net::HttpResponseHeaders(raw_headers); 267 head.headers = new net::HttpResponseHeaders(raw_headers);
265 head.mime_type = kTestPageMimeType; 268 head.mime_type = kTestPageMimeType;
266 head.charset = kTestPageCharset; 269 head.charset = kTestPageCharset;
267 head.error_code = net::OK; 270 head.error_code = net::OK;
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 bridge->Start(this); 718 bridge->Start(this);
716 719
717 dispatcher()->OnMessageReceived( 720 dispatcher()->OnMessageReceived(
718 ResourceMsg_ReceivedResponse(0, response_head)); 721 ResourceMsg_ReceivedResponse(0, response_head));
719 } 722 }
720 723
721 // RequestPeer methods. 724 // RequestPeer methods.
722 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE { 725 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE {
723 } 726 }
724 727
725 virtual bool OnReceivedRedirect(const GURL& new_url, 728 virtual bool OnReceivedRedirect(const net::RedirectInfo& redirect_info,
726 const GURL& new_first_party_for_cookies,
727 const ResourceResponseInfo& info) OVERRIDE { 729 const ResourceResponseInfo& info) OVERRIDE {
728 return true; 730 return true;
729 } 731 }
730 732
731 virtual void OnReceivedResponse(const ResourceResponseInfo& info) OVERRIDE { 733 virtual void OnReceivedResponse(const ResourceResponseInfo& info) OVERRIDE {
732 response_info_ = info; 734 response_info_ = info;
733 } 735 }
734 736
735 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE { 737 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE {
736 } 738 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 response_head.error_code = net::OK; 796 response_head.error_code = net::OK;
795 797
796 PerformTest(response_head); 798 PerformTest(response_head);
797 799
798 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start); 800 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start);
799 EXPECT_EQ(base::TimeTicks(), 801 EXPECT_EQ(base::TimeTicks(),
800 response_info().load_timing.connect_timing.dns_start); 802 response_info().load_timing.connect_timing.dns_start);
801 } 803 }
802 804
803 } // namespace content 805 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698