| 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 #ifndef CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/file_path.h" |
| 10 #include "base/timer.h" | 11 #include "base/timer.h" |
| 11 #include "chrome/browser/renderer_host/global_request_id.h" | 12 #include "chrome/browser/renderer_host/global_request_id.h" |
| 12 #include "chrome/browser/renderer_host/resource_handler.h" | 13 #include "chrome/browser/renderer_host/resource_handler.h" |
| 13 | 14 |
| 14 class DownloadFileManager; | 15 class DownloadFileManager; |
| 15 class ResourceDispatcherHost; | 16 class ResourceDispatcherHost; |
| 16 class URLRequest; | 17 class URLRequest; |
| 17 struct DownloadBuffer; | 18 struct DownloadBuffer; |
| 18 | 19 |
| 19 // Forwards data to the download thread. | 20 // Forwards data to the download thread. |
| 20 class DownloadResourceHandler : public ResourceHandler { | 21 class DownloadResourceHandler : public ResourceHandler { |
| 21 public: | 22 public: |
| 22 DownloadResourceHandler(ResourceDispatcherHost* rdh, | 23 DownloadResourceHandler(ResourceDispatcherHost* rdh, |
| 23 int render_process_host_id, | 24 int render_process_host_id, |
| 24 int render_view_id, | 25 int render_view_id, |
| 25 int request_id, | 26 int request_id, |
| 26 const GURL& url, | 27 const GURL& url, |
| 27 DownloadFileManager* manager, | 28 DownloadFileManager* manager, |
| 28 URLRequest* request, | 29 URLRequest* request, |
| 29 bool save_as); | 30 bool save_as, |
| 31 const FilePath& save_file_path); |
| 30 | 32 |
| 31 // Not needed, as this event handler ought to be the final resource. | 33 // Not needed, as this event handler ought to be the final resource. |
| 32 bool OnRequestRedirected(int request_id, const GURL& url, | 34 bool OnRequestRedirected(int request_id, const GURL& url, |
| 33 ResourceResponse* response, bool* defer); | 35 ResourceResponse* response, bool* defer); |
| 34 | 36 |
| 35 // Send the download creation information to the download thread. | 37 // Send the download creation information to the download thread. |
| 36 bool OnResponseStarted(int request_id, ResourceResponse* response); | 38 bool OnResponseStarted(int request_id, ResourceResponse* response); |
| 37 | 39 |
| 38 // Create a new buffer, which will be handed to the download thread for file | 40 // Create a new buffer, which will be handed to the download thread for file |
| 39 // writing and deletion. | 41 // writing and deletion. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 63 int download_id_; | 65 int download_id_; |
| 64 GlobalRequestID global_id_; | 66 GlobalRequestID global_id_; |
| 65 int render_view_id_; | 67 int render_view_id_; |
| 66 scoped_refptr<net::IOBuffer> read_buffer_; | 68 scoped_refptr<net::IOBuffer> read_buffer_; |
| 67 std::string content_disposition_; | 69 std::string content_disposition_; |
| 68 GURL url_; | 70 GURL url_; |
| 69 int64 content_length_; | 71 int64 content_length_; |
| 70 DownloadFileManager* download_manager_; | 72 DownloadFileManager* download_manager_; |
| 71 URLRequest* request_; | 73 URLRequest* request_; |
| 72 bool save_as_; // Request was initiated via "Save As" by the user. | 74 bool save_as_; // Request was initiated via "Save As" by the user. |
| 75 FilePath save_file_path_; |
| 73 DownloadBuffer* buffer_; | 76 DownloadBuffer* buffer_; |
| 74 ResourceDispatcherHost* rdh_; | 77 ResourceDispatcherHost* rdh_; |
| 75 bool is_paused_; | 78 bool is_paused_; |
| 76 base::OneShotTimer<DownloadResourceHandler> pause_timer_; | 79 base::OneShotTimer<DownloadResourceHandler> pause_timer_; |
| 77 | 80 |
| 78 static const int kReadBufSize = 32768; // bytes | 81 static const int kReadBufSize = 32768; // bytes |
| 79 static const size_t kLoadsToWrite = 100; // number of data buffers queued | 82 static const size_t kLoadsToWrite = 100; // number of data buffers queued |
| 80 static const int kThrottleTimeMs = 200; // milliseconds | 83 static const int kThrottleTimeMs = 200; // milliseconds |
| 81 | 84 |
| 82 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 85 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
| 83 }; | 86 }; |
| 84 | 87 |
| 85 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ | 88 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ |
| OLD | NEW |