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

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

Issue 7793003: Revert 98656 - Make a new integer field in sql::MetaTable (a per-profile db) containing a counter... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 12 matching lines...) Expand all
23 #include "net/base/io_buffer.h" 23 #include "net/base/io_buffer.h"
24 #include "net/http/http_response_headers.h" 24 #include "net/http/http_response_headers.h"
25 #include "net/url_request/url_request_context.h" 25 #include "net/url_request/url_request_context.h"
26 26
27 DownloadResourceHandler::DownloadResourceHandler( 27 DownloadResourceHandler::DownloadResourceHandler(
28 ResourceDispatcherHost* rdh, 28 ResourceDispatcherHost* rdh,
29 int render_process_host_id, 29 int render_process_host_id,
30 int render_view_id, 30 int render_view_id,
31 int request_id, 31 int request_id,
32 const GURL& url, 32 const GURL& url,
33 DownloadId dl_id,
34 DownloadFileManager* download_file_manager, 33 DownloadFileManager* download_file_manager,
35 net::URLRequest* request, 34 net::URLRequest* request,
36 bool save_as, 35 bool save_as,
37 const DownloadSaveInfo& save_info) 36 const DownloadSaveInfo& save_info)
38 : download_id_(dl_id), 37 : download_id_(-1),
39 global_id_(render_process_host_id, request_id), 38 global_id_(render_process_host_id, request_id),
40 render_view_id_(render_view_id), 39 render_view_id_(render_view_id),
41 content_length_(0), 40 content_length_(0),
42 download_file_manager_(download_file_manager), 41 download_file_manager_(download_file_manager),
43 request_(request), 42 request_(request),
44 save_as_(save_as), 43 save_as_(save_as),
45 save_info_(save_info), 44 save_info_(save_info),
46 buffer_(new DownloadBuffer), 45 buffer_(new DownloadBuffer),
47 rdh_(rdh), 46 rdh_(rdh),
48 is_paused_(false) { 47 is_paused_(false) {
49 DCHECK(dl_id.IsValid());
50 download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT); 48 download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT);
51 } 49 }
52 50
53 bool DownloadResourceHandler::OnUploadProgress(int request_id, 51 bool DownloadResourceHandler::OnUploadProgress(int request_id,
54 uint64 position, 52 uint64 position,
55 uint64 size) { 53 uint64 size) {
56 return true; 54 return true;
57 } 55 }
58 56
59 // Not needed, as this event handler ought to be the final resource. 57 // Not needed, as this event handler ought to be the final resource.
60 bool DownloadResourceHandler::OnRequestRedirected(int request_id, 58 bool DownloadResourceHandler::OnRequestRedirected(int request_id,
61 const GURL& url, 59 const GURL& url,
62 ResourceResponse* response, 60 ResourceResponse* response,
63 bool* defer) { 61 bool* defer) {
64 return true; 62 return true;
65 } 63 }
66 64
67 // Send the download creation information to the download thread. 65 // Send the download creation information to the download thread.
68 bool DownloadResourceHandler::OnResponseStarted(int request_id, 66 bool DownloadResourceHandler::OnResponseStarted(int request_id,
69 ResourceResponse* response) { 67 ResourceResponse* response) {
70 DCHECK(download_id_.IsValid());
71 VLOG(20) << __FUNCTION__ << "()" << DebugString() 68 VLOG(20) << __FUNCTION__ << "()" << DebugString()
72 << " request_id = " << request_id; 69 << " request_id = " << request_id;
73 download_start_time_ = base::TimeTicks::Now(); 70 download_start_time_ = base::TimeTicks::Now();
74 std::string content_disposition; 71 std::string content_disposition;
75 request_->GetResponseHeaderByName("content-disposition", 72 request_->GetResponseHeaderByName("content-disposition",
76 &content_disposition); 73 &content_disposition);
77 set_content_disposition(content_disposition); 74 set_content_disposition(content_disposition);
78 set_content_length(response->response_head.content_length); 75 set_content_length(response->response_head.content_length);
79 76
80 const ResourceDispatcherHostRequestInfo* request_info = 77 const ResourceDispatcherHostRequestInfo* request_info =
81 ResourceDispatcherHost::InfoForRequest(request_); 78 ResourceDispatcherHost::InfoForRequest(request_);
82 79
80 download_id_ = download_file_manager_->GetNextId();
81
83 // Deleted in DownloadManager. 82 // Deleted in DownloadManager.
84 DownloadCreateInfo* info = new DownloadCreateInfo; 83 DownloadCreateInfo* info = new DownloadCreateInfo;
85 info->url_chain = request_->url_chain(); 84 info->url_chain = request_->url_chain();
86 info->referrer_url = GURL(request_->referrer()); 85 info->referrer_url = GURL(request_->referrer());
87 info->start_time = base::Time::Now(); 86 info->start_time = base::Time::Now();
88 info->received_bytes = 0; 87 info->received_bytes = 0;
89 info->total_bytes = content_length_; 88 info->total_bytes = content_length_;
90 info->state = DownloadItem::IN_PROGRESS; 89 info->state = DownloadItem::IN_PROGRESS;
91 info->download_id = download_id_.local(); 90 info->download_id = download_id_;
92 info->has_user_gesture = request_info->has_user_gesture(); 91 info->has_user_gesture = request_info->has_user_gesture();
93 info->request_handle = DownloadRequestHandle(rdh_, 92 info->request_handle = DownloadRequestHandle(rdh_,
94 global_id_.child_id, 93 global_id_.child_id,
95 render_view_id_, 94 render_view_id_,
96 global_id_.request_id); 95 global_id_.request_id);
97 info->content_disposition = content_disposition_; 96 info->content_disposition = content_disposition_;
98 info->mime_type = response->response_head.mime_type; 97 info->mime_type = response->response_head.mime_type;
99 download_stats::RecordDownloadMimeType(info->mime_type); 98 download_stats::RecordDownloadMimeType(info->mime_type);
100 // TODO(ahendrickson) -- Get the last modified time and etag, so we can 99 // TODO(ahendrickson) -- Get the last modified time and etag, so we can
101 // resume downloading. 100 // resume downloading.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 " url_ = " "\"%s\"" 250 " url_ = " "\"%s\""
252 " download_id_ = " "%d" 251 " download_id_ = " "%d"
253 " global_id_ = {" 252 " global_id_ = {"
254 " child_id = " "%d" 253 " child_id = " "%d"
255 " request_id = " "%d" 254 " request_id = " "%d"
256 " }" 255 " }"
257 " render_view_id_ = " "%d" 256 " render_view_id_ = " "%d"
258 " save_info_.file_path = \"%" PRFilePath "\"" 257 " save_info_.file_path = \"%" PRFilePath "\""
259 " }", 258 " }",
260 request_->url().spec().c_str(), 259 request_->url().spec().c_str(),
261 download_id_.local(), 260 download_id_,
262 global_id_.child_id, 261 global_id_.child_id,
263 global_id_.request_id, 262 global_id_.request_id,
264 render_view_id_, 263 render_view_id_,
265 save_info_.file_path.value().c_str()); 264 save_info_.file_path.value().c_str());
266 } 265 }
OLDNEW
« no previous file with comments | « content/browser/download/download_resource_handler.h ('k') | content/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698