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

Side by Side Diff: content/browser/download/download_resource_handler.cc

Issue 10310124: Implement a ResourceThrottle for URL overriding in Chrome on Android. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix build (Referrer is a struct, not a class) Created 8 years, 6 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 | « chrome/chrome_tests.gypi ('k') | content/browser/renderer_host/render_view_host_impl.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 (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/download/download_resource_handler.h" 5 #include "content/browser/download/download_resource_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 &content_disposition); 137 &content_disposition);
138 SetContentDisposition(content_disposition); 138 SetContentDisposition(content_disposition);
139 SetContentLength(response->content_length); 139 SetContentLength(response->content_length);
140 140
141 const ResourceRequestInfoImpl* request_info = 141 const ResourceRequestInfoImpl* request_info =
142 ResourceRequestInfoImpl::ForRequest(request_); 142 ResourceRequestInfoImpl::ForRequest(request_);
143 143
144 // Deleted in DownloadManager. 144 // Deleted in DownloadManager.
145 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo( 145 scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo(
146 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, 146 base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS,
147 request_->net_log(), request_info->has_user_gesture(), 147 request_->net_log(), request_info->HasUserGesture(),
148 request_info->transition_type())); 148 request_info->transition_type()));
149 149
150 // Create the ByteStream for sending data to the download sink. 150 // Create the ByteStream for sending data to the download sink.
151 scoped_ptr<content::ByteStreamReader> stream_reader; 151 scoped_ptr<content::ByteStreamReader> stream_reader;
152 CreateByteStream( 152 CreateByteStream(
153 base::MessageLoopProxy::current(), 153 base::MessageLoopProxy::current(),
154 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), 154 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE),
155 kDownloadByteStreamSize, &stream_writer_, &stream_reader); 155 kDownloadByteStreamSize, &stream_writer_, &stream_reader);
156 stream_writer_->RegisterCallback( 156 stream_writer_->RegisterCallback(
157 base::Bind(&DownloadResourceHandler::ResumeRequest, AsWeakPtr())); 157 base::Bind(&DownloadResourceHandler::ResumeRequest, AsWeakPtr()));
158 158
159 info->url_chain = request_->url_chain(); 159 info->url_chain = request_->url_chain();
160 info->referrer_url = GURL(request_->referrer()); 160 info->referrer_url = GURL(request_->referrer());
161 info->start_time = base::Time::Now(); 161 info->start_time = base::Time::Now();
162 info->received_bytes = save_info_.offset; 162 info->received_bytes = save_info_.offset;
163 info->total_bytes = content_length_; 163 info->total_bytes = content_length_;
164 info->state = DownloadItem::IN_PROGRESS; 164 info->state = DownloadItem::IN_PROGRESS;
165 info->has_user_gesture = request_info->has_user_gesture(); 165 info->has_user_gesture = request_info->HasUserGesture();
166 info->content_disposition = content_disposition_; 166 info->content_disposition = content_disposition_;
167 info->mime_type = response->mime_type; 167 info->mime_type = response->mime_type;
168 info->remote_address = request_->GetSocketAddress().host(); 168 info->remote_address = request_->GetSocketAddress().host();
169 download_stats::RecordDownloadMimeType(info->mime_type); 169 download_stats::RecordDownloadMimeType(info->mime_type);
170 170
171 info->request_handle = 171 info->request_handle =
172 DownloadRequestHandle(AsWeakPtr(), global_id_.child_id, 172 DownloadRequestHandle(AsWeakPtr(), global_id_.child_id,
173 render_view_id_, global_id_.request_id); 173 render_view_id_, global_id_.request_id);
174 174
175 // Get the last modified time and etag. 175 // Get the last modified time and etag.
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 // false somewhere in the chain of resource handlers. 446 // false somewhere in the chain of resource handlers.
447 CallStartedCB(DownloadId(), net::ERR_ACCESS_DENIED); 447 CallStartedCB(DownloadId(), net::ERR_ACCESS_DENIED);
448 448
449 // Remove output stream callback if a stream exists. 449 // Remove output stream callback if a stream exists.
450 if (stream_writer_.get()) 450 if (stream_writer_.get())
451 stream_writer_->RegisterCallback(base::Closure()); 451 stream_writer_->RegisterCallback(base::Closure());
452 452
453 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration", 453 UMA_HISTOGRAM_TIMES("SB2.DownloadDuration",
454 base::TimeTicks::Now() - download_start_time_); 454 base::TimeTicks::Now() - download_start_time_);
455 } 455 }
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | content/browser/renderer_host/render_view_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698