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

Side by Side Diff: content/browser/loader/sync_resource_handler.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: darin comments Created 6 years, 4 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 "content/browser/loader/sync_resource_handler.h" 5 #include "content/browser/loader/sync_resource_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/devtools/devtools_netlog_observer.h" 8 #include "content/browser/devtools/devtools_netlog_observer.h"
9 #include "content/browser/loader/resource_dispatcher_host_impl.h" 9 #include "content/browser/loader/resource_dispatcher_host_impl.h"
10 #include "content/browser/loader/resource_message_filter.h" 10 #include "content/browser/loader/resource_message_filter.h"
11 #include "content/browser/loader/resource_request_info_impl.h" 11 #include "content/browser/loader/resource_request_info_impl.h"
12 #include "content/common/resource_messages.h" 12 #include "content/common/resource_messages.h"
13 #include "content/public/browser/resource_dispatcher_host_delegate.h" 13 #include "content/public/browser/resource_dispatcher_host_delegate.h"
14 #include "content/public/browser/resource_request_info.h" 14 #include "content/public/browser/resource_request_info.h"
15 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
16 #include "net/http/http_response_headers.h" 16 #include "net/http/http_response_headers.h"
17 #include "net/url_request/redirect_info.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 SyncResourceHandler::SyncResourceHandler( 21 SyncResourceHandler::SyncResourceHandler(
21 net::URLRequest* request, 22 net::URLRequest* request,
22 IPC::Message* result_message, 23 IPC::Message* result_message,
23 ResourceDispatcherHostImpl* resource_dispatcher_host) 24 ResourceDispatcherHostImpl* resource_dispatcher_host)
24 : ResourceHandler(request), 25 : ResourceHandler(request),
25 read_buffer_(new net::IOBuffer(kReadBufSize)), 26 read_buffer_(new net::IOBuffer(kReadBufSize)),
26 result_message_(result_message), 27 result_message_(result_message),
(...skipping 11 matching lines...) Expand all
38 if (filter) 39 if (filter)
39 filter->Send(result_message_); 40 filter->Send(result_message_);
40 } 41 }
41 } 42 }
42 43
43 bool SyncResourceHandler::OnUploadProgress(uint64 position, uint64 size) { 44 bool SyncResourceHandler::OnUploadProgress(uint64 position, uint64 size) {
44 return true; 45 return true;
45 } 46 }
46 47
47 bool SyncResourceHandler::OnRequestRedirected( 48 bool SyncResourceHandler::OnRequestRedirected(
48 const GURL& new_url, 49 const net::RedirectInfo& redirect_info,
49 ResourceResponse* response, 50 ResourceResponse* response,
50 bool* defer) { 51 bool* defer) {
51 if (rdh_->delegate()) { 52 if (rdh_->delegate()) {
52 rdh_->delegate()->OnRequestRedirected( 53 rdh_->delegate()->OnRequestRedirected(
53 new_url, request(), GetRequestInfo()->GetContext(), response); 54 redirect_info.new_url, request(), GetRequestInfo()->GetContext(),
55 response);
54 } 56 }
55 57
56 DevToolsNetLogObserver::PopulateResponseInfo(request(), response); 58 DevToolsNetLogObserver::PopulateResponseInfo(request(), response);
57 // TODO(darin): It would be much better if this could live in WebCore, but 59 // TODO(darin): It would be much better if this could live in WebCore, but
58 // doing so requires API changes at all levels. Similar code exists in 60 // doing so requires API changes at all levels. Similar code exists in
59 // WebCore/platform/network/cf/ResourceHandleCFNet.cpp :-( 61 // WebCore/platform/network/cf/ResourceHandleCFNet.cpp :-(
60 if (new_url.GetOrigin() != result_.final_url.GetOrigin()) { 62 if (redirect_info.new_url.GetOrigin() != result_.final_url.GetOrigin()) {
61 LOG(ERROR) << "Cross origin redirect denied"; 63 LOG(ERROR) << "Cross origin redirect denied";
62 return false; 64 return false;
63 } 65 }
64 result_.final_url = new_url; 66 result_.final_url = redirect_info.new_url;
65 67
66 total_transfer_size_ += request()->GetTotalReceivedBytes(); 68 total_transfer_size_ += request()->GetTotalReceivedBytes();
67 return true; 69 return true;
68 } 70 }
69 71
70 bool SyncResourceHandler::OnResponseStarted( 72 bool SyncResourceHandler::OnResponseStarted(
71 ResourceResponse* response, 73 ResourceResponse* response,
72 bool* defer) { 74 bool* defer) {
73 const ResourceRequestInfoImpl* info = GetRequestInfo(); 75 const ResourceRequestInfoImpl* info = GetRequestInfo();
74 if (!info->filter()) 76 if (!info->filter())
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 result_message_ = NULL; 137 result_message_ = NULL;
136 return; 138 return;
137 } 139 }
138 140
139 void SyncResourceHandler::OnDataDownloaded(int bytes_downloaded) { 141 void SyncResourceHandler::OnDataDownloaded(int bytes_downloaded) {
140 // Sync requests don't involve ResourceMsg_DataDownloaded messages 142 // Sync requests don't involve ResourceMsg_DataDownloaded messages
141 // being sent back to renderers as progress is made. 143 // being sent back to renderers as progress is made.
142 } 144 }
143 145
144 } // namespace content 146 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/sync_resource_handler.h ('k') | content/browser/loader/throttling_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698