OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/download_resource_handler.h" | 5 #include "chrome/browser/renderer_host/download_resource_handler.h" |
6 | 6 |
7 #include "chrome/browser/download/download_file.h" | 7 #include "chrome/browser/download/download_file.h" |
8 #include "chrome/browser/download/download_manager.h" | 8 #include "chrome/browser/download/download_manager.h" |
9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| 11 #include "net/url_request/url_request_context.h" |
11 | 12 |
12 DownloadResourceHandler::DownloadResourceHandler(ResourceDispatcherHost* rdh, | 13 DownloadResourceHandler::DownloadResourceHandler(ResourceDispatcherHost* rdh, |
13 int render_process_host_id, | 14 int render_process_host_id, |
14 int render_view_id, | 15 int render_view_id, |
15 int request_id, | 16 int request_id, |
16 const GURL& url, | 17 const GURL& url, |
17 DownloadFileManager* manager, | 18 DownloadFileManager* manager, |
18 URLRequest* request, | 19 URLRequest* request, |
19 bool save_as) | 20 bool save_as) |
20 : download_id_(-1), | 21 : download_id_(-1), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 info->total_bytes = content_length_; | 58 info->total_bytes = content_length_; |
58 info->state = DownloadItem::IN_PROGRESS; | 59 info->state = DownloadItem::IN_PROGRESS; |
59 info->download_id = download_id_; | 60 info->download_id = download_id_; |
60 info->render_process_id = global_id_.process_id; | 61 info->render_process_id = global_id_.process_id; |
61 info->render_view_id = render_view_id_; | 62 info->render_view_id = render_view_id_; |
62 info->request_id = global_id_.request_id; | 63 info->request_id = global_id_.request_id; |
63 info->content_disposition = content_disposition_; | 64 info->content_disposition = content_disposition_; |
64 info->mime_type = response->response_head.mime_type; | 65 info->mime_type = response->response_head.mime_type; |
65 info->save_as = save_as_; | 66 info->save_as = save_as_; |
66 info->is_dangerous = false; | 67 info->is_dangerous = false; |
| 68 info->referrer_charset = request_->context()->referrer_charset(); |
67 download_manager_->file_loop()->PostTask(FROM_HERE, | 69 download_manager_->file_loop()->PostTask(FROM_HERE, |
68 NewRunnableMethod(download_manager_, | 70 NewRunnableMethod(download_manager_, |
69 &DownloadFileManager::StartDownload, | 71 &DownloadFileManager::StartDownload, |
70 info)); | 72 info)); |
71 return true; | 73 return true; |
72 } | 74 } |
73 | 75 |
74 // Create a new buffer, which will be handed to the download thread for file | 76 // Create a new buffer, which will be handed to the download thread for file |
75 // writing and deletion. | 77 // writing and deletion. |
76 bool DownloadResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, | 78 bool DownloadResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 should_pause); | 166 should_pause); |
165 is_paused_ = should_pause; | 167 is_paused_ = should_pause; |
166 } | 168 } |
167 } | 169 } |
168 | 170 |
169 void DownloadResourceHandler::StartPauseTimer() { | 171 void DownloadResourceHandler::StartPauseTimer() { |
170 if (!pause_timer_.IsRunning()) | 172 if (!pause_timer_.IsRunning()) |
171 pause_timer_.Start(base::TimeDelta::FromMilliseconds(kThrottleTimeMs), this, | 173 pause_timer_.Start(base::TimeDelta::FromMilliseconds(kThrottleTimeMs), this, |
172 &DownloadResourceHandler::CheckWriteProgress); | 174 &DownloadResourceHandler::CheckWriteProgress); |
173 } | 175 } |
OLD | NEW |