| 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 "chrome/browser/renderer_host/resource_dispatcher_host.h" | 10 #include "base/timer.h" |
| 11 #include "chrome/browser/renderer_host/global_request_id.h" |
| 11 #include "chrome/browser/renderer_host/resource_handler.h" | 12 #include "chrome/browser/renderer_host/resource_handler.h" |
| 12 | 13 |
| 14 class DownloadFileManager; |
| 15 class ResourceDispatcherHost; |
| 16 class URLRequest; |
| 13 struct DownloadBuffer; | 17 struct DownloadBuffer; |
| 14 | 18 |
| 15 // Forwards data to the download thread. | 19 // Forwards data to the download thread. |
| 16 class DownloadResourceHandler : public ResourceHandler { | 20 class DownloadResourceHandler : public ResourceHandler { |
| 17 public: | 21 public: |
| 18 DownloadResourceHandler(ResourceDispatcherHost* rdh, | 22 DownloadResourceHandler(ResourceDispatcherHost* rdh, |
| 19 int render_process_host_id, | 23 int render_process_host_id, |
| 20 int render_view_id, | 24 int render_view_id, |
| 21 int request_id, | 25 int request_id, |
| 22 const GURL& url, | 26 const GURL& url, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 50 void set_content_disposition(const std::string& content_disposition); | 54 void set_content_disposition(const std::string& content_disposition); |
| 51 | 55 |
| 52 void CheckWriteProgress(); | 56 void CheckWriteProgress(); |
| 53 | 57 |
| 54 private: | 58 private: |
| 55 ~DownloadResourceHandler() {} | 59 ~DownloadResourceHandler() {} |
| 56 | 60 |
| 57 void StartPauseTimer(); | 61 void StartPauseTimer(); |
| 58 | 62 |
| 59 int download_id_; | 63 int download_id_; |
| 60 ResourceDispatcherHost::GlobalRequestID global_id_; | 64 GlobalRequestID global_id_; |
| 61 int render_view_id_; | 65 int render_view_id_; |
| 62 scoped_refptr<net::IOBuffer> read_buffer_; | 66 scoped_refptr<net::IOBuffer> read_buffer_; |
| 63 std::string content_disposition_; | 67 std::string content_disposition_; |
| 64 GURL url_; | 68 GURL url_; |
| 65 int64 content_length_; | 69 int64 content_length_; |
| 66 DownloadFileManager* download_manager_; | 70 DownloadFileManager* download_manager_; |
| 67 URLRequest* request_; | 71 URLRequest* request_; |
| 68 bool save_as_; // Request was initiated via "Save As" by the user. | 72 bool save_as_; // Request was initiated via "Save As" by the user. |
| 69 DownloadBuffer* buffer_; | 73 DownloadBuffer* buffer_; |
| 70 ResourceDispatcherHost* rdh_; | 74 ResourceDispatcherHost* rdh_; |
| 71 bool is_paused_; | 75 bool is_paused_; |
| 72 base::OneShotTimer<DownloadResourceHandler> pause_timer_; | 76 base::OneShotTimer<DownloadResourceHandler> pause_timer_; |
| 73 | 77 |
| 74 static const int kReadBufSize = 32768; // bytes | 78 static const int kReadBufSize = 32768; // bytes |
| 75 static const size_t kLoadsToWrite = 100; // number of data buffers queued | 79 static const size_t kLoadsToWrite = 100; // number of data buffers queued |
| 76 static const int kThrottleTimeMs = 200; // milliseconds | 80 static const int kThrottleTimeMs = 200; // milliseconds |
| 77 | 81 |
| 78 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 82 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
| 79 }; | 83 }; |
| 80 | 84 |
| 81 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ | 85 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ |
| OLD | NEW |