| Index: trunk/src/content/browser/download/download_resource_handler.cc
|
| ===================================================================
|
| --- trunk/src/content/browser/download/download_resource_handler.cc (revision 227593)
|
| +++ trunk/src/content/browser/download/download_resource_handler.cc (working copy)
|
| @@ -74,9 +74,9 @@
|
| net::URLRequest* request,
|
| const DownloadUrlParameters::OnStartedCallback& started_cb,
|
| scoped_ptr<DownloadSaveInfo> save_info)
|
| - : ResourceHandler(request),
|
| - download_id_(id),
|
| + : download_id_(id),
|
| content_length_(0),
|
| + request_(request),
|
| started_cb_(started_cb),
|
| save_info_(save_info.Pass()),
|
| last_buffer_size_(0),
|
| @@ -100,7 +100,7 @@
|
| bool* defer) {
|
| // We treat a download as a main frame load, and thus update the policy URL
|
| // on redirects.
|
| - request()->set_first_party_for_cookies(url);
|
| + request_->set_first_party_for_cookies(url);
|
| return true;
|
| }
|
|
|
| @@ -119,24 +119,25 @@
|
| download_start_time_ = base::TimeTicks::Now();
|
|
|
| // If it's a download, we don't want to poison the cache with it.
|
| - request()->StopCaching();
|
| + request_->StopCaching();
|
|
|
| // Lower priority as well, so downloads don't contend for resources
|
| // with main frames.
|
| - request()->SetPriority(net::IDLE);
|
| + request_->SetPriority(net::IDLE);
|
|
|
| std::string content_disposition;
|
| - request()->GetResponseHeaderByName("content-disposition",
|
| - &content_disposition);
|
| + request_->GetResponseHeaderByName("content-disposition",
|
| + &content_disposition);
|
| SetContentDisposition(content_disposition);
|
| SetContentLength(response->head.content_length);
|
|
|
| - const ResourceRequestInfoImpl* request_info = GetRequestInfo();
|
| + const ResourceRequestInfoImpl* request_info =
|
| + ResourceRequestInfoImpl::ForRequest(request_);
|
|
|
| // Deleted in DownloadManager.
|
| scoped_ptr<DownloadCreateInfo> info(new DownloadCreateInfo(
|
| base::Time::Now(), content_length_,
|
| - request()->net_log(), request_info->HasUserGesture(),
|
| + request_->net_log(), request_info->HasUserGesture(),
|
| request_info->GetPageTransition()));
|
|
|
| // Create the ByteStream for sending data to the download sink.
|
| @@ -149,14 +150,14 @@
|
| base::Bind(&DownloadResourceHandler::ResumeRequest, AsWeakPtr()));
|
|
|
| info->download_id = download_id_;
|
| - info->url_chain = request()->url_chain();
|
| - info->referrer_url = GURL(request()->referrer());
|
| + info->url_chain = request_->url_chain();
|
| + info->referrer_url = GURL(request_->referrer());
|
| info->start_time = base::Time::Now();
|
| info->total_bytes = content_length_;
|
| info->has_user_gesture = request_info->HasUserGesture();
|
| info->content_disposition = content_disposition_;
|
| info->mime_type = response->head.mime_type;
|
| - info->remote_address = request()->GetSocketAddress().host();
|
| + info->remote_address = request_->GetSocketAddress().host();
|
| RecordDownloadMimeType(info->mime_type);
|
| RecordDownloadContentDisposition(info->content_disposition);
|
|
|
| @@ -166,7 +167,7 @@
|
| request_info->GetRequestID());
|
|
|
| // Get the last modified time and etag.
|
| - const net::HttpResponseHeaders* headers = request()->response_headers();
|
| + const net::HttpResponseHeaders* headers = request_->response_headers();
|
| if (headers) {
|
| std::string last_modified_hdr;
|
| if (headers->EnumerateHeader(NULL, "Last-Modified", &last_modified_hdr))
|
| @@ -231,10 +232,8 @@
|
|
|
| // Create a new buffer, which will be handed to the download thread for file
|
| // writing and deletion.
|
| -bool DownloadResourceHandler::OnWillRead(int request_id,
|
| - scoped_refptr<net::IOBuffer>* buf,
|
| - int* buf_size,
|
| - int min_size) {
|
| +bool DownloadResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf,
|
| + int* buf_size, int min_size) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| DCHECK(buf && buf_size);
|
| DCHECK(!read_buffer_.get());
|
| @@ -292,7 +291,7 @@
|
| const net::URLRequestStatus& status,
|
| const std::string& security_info) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - int response_code = status.is_success() ? request()->GetResponseCode() : 0;
|
| + int response_code = status.is_success() ? request_->GetResponseCode() : 0;
|
| VLOG(20) << __FUNCTION__ << "()" << DebugString()
|
| << " request_id = " << request_id
|
| << " status.status() = " << status.status()
|
| @@ -336,7 +335,7 @@
|
|
|
| if (status.is_success() &&
|
| reason == DOWNLOAD_INTERRUPT_REASON_NONE &&
|
| - request()->response_headers()) {
|
| + request_->response_headers()) {
|
| // Handle server's response codes.
|
| switch(response_code) {
|
| case -1: // Non-HTTP request.
|
| @@ -448,7 +447,7 @@
|
| void DownloadResourceHandler::CancelRequest() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
|
|
| - const ResourceRequestInfo* info = GetRequestInfo();
|
| + const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_);
|
| ResourceDispatcherHostImpl::Get()->CancelRequest(
|
| info->GetChildID(),
|
| info->GetRequestID(),
|
| @@ -456,7 +455,7 @@
|
| }
|
|
|
| std::string DownloadResourceHandler::DebugString() const {
|
| - const ResourceRequestInfo* info = GetRequestInfo();
|
| + const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_);
|
| return base::StringPrintf("{"
|
| " url_ = " "\"%s\""
|
| " info = {"
|
| @@ -465,8 +464,8 @@
|
| " route_id = " "%d"
|
| " }"
|
| " }",
|
| - request() ?
|
| - request()->url().spec().c_str() :
|
| + request_ ?
|
| + request_->url().spec().c_str() :
|
| "<NULL request>",
|
| info->GetChildID(),
|
| info->GetRequestID(),
|
|
|