| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/timer.h" | 12 #include "base/timer.h" |
| 13 #include "chrome/browser/download/download_file.h" | 13 #include "chrome/browser/download/download_file.h" |
| 14 #include "chrome/browser/renderer_host/global_request_id.h" | 14 #include "chrome/browser/renderer_host/global_request_id.h" |
| 15 #include "chrome/browser/renderer_host/resource_handler.h" | 15 #include "chrome/browser/renderer_host/resource_handler.h" |
| 16 | 16 |
| 17 class DownloadFileManager; | 17 class DownloadFileManager; |
| 18 class ResourceDispatcherHost; | 18 class ResourceDispatcherHost; |
| 19 class URLRequest; | 19 class URLRequest; |
| 20 struct DownloadBuffer; | 20 struct DownloadBuffer; |
| 21 | 21 |
| 22 // Forwards data to the download thread. | 22 // Forwards data to the download thread. |
| 23 class DownloadResourceHandler : public ResourceHandler { | 23 class DownloadResourceHandler : public ResourceHandler { |
| 24 public: | 24 public: |
| 25 DownloadResourceHandler(ResourceDispatcherHost* rdh, | 25 DownloadResourceHandler(ResourceDispatcherHost* rdh, |
| 26 int render_process_host_id, | 26 int render_process_host_id, |
| 27 int render_view_id, | 27 int render_view_id, |
| 28 int request_id, | 28 int request_id, |
| 29 const GURL& url, | 29 const GURL& url, |
| 30 DownloadFileManager* manager, | 30 DownloadFileManager* download_file_manager, |
| 31 URLRequest* request, | 31 URLRequest* request, |
| 32 bool save_as, | 32 bool save_as, |
| 33 const DownloadSaveInfo& save_info); | 33 const DownloadSaveInfo& save_info); |
| 34 | 34 |
| 35 bool OnUploadProgress(int request_id, uint64 position, uint64 size); | 35 bool OnUploadProgress(int request_id, uint64 position, uint64 size); |
| 36 | 36 |
| 37 // Not needed, as this event handler ought to be the final resource. | 37 // Not needed, as this event handler ought to be the final resource. |
| 38 bool OnRequestRedirected(int request_id, const GURL& url, | 38 bool OnRequestRedirected(int request_id, const GURL& url, |
| 39 ResourceResponse* response, bool* defer); | 39 ResourceResponse* response, bool* defer); |
| 40 | 40 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 70 | 70 |
| 71 void StartPauseTimer(); | 71 void StartPauseTimer(); |
| 72 | 72 |
| 73 int download_id_; | 73 int download_id_; |
| 74 GlobalRequestID global_id_; | 74 GlobalRequestID global_id_; |
| 75 int render_view_id_; | 75 int render_view_id_; |
| 76 scoped_refptr<net::IOBuffer> read_buffer_; | 76 scoped_refptr<net::IOBuffer> read_buffer_; |
| 77 std::string content_disposition_; | 77 std::string content_disposition_; |
| 78 GURL url_; | 78 GURL url_; |
| 79 int64 content_length_; | 79 int64 content_length_; |
| 80 DownloadFileManager* download_manager_; | 80 DownloadFileManager* download_file_manager_; |
| 81 URLRequest* request_; | 81 URLRequest* request_; |
| 82 bool save_as_; // Request was initiated via "Save As" by the user. | 82 bool save_as_; // Request was initiated via "Save As" by the user. |
| 83 DownloadSaveInfo save_info_; | 83 DownloadSaveInfo save_info_; |
| 84 DownloadBuffer* buffer_; | 84 DownloadBuffer* buffer_; |
| 85 ResourceDispatcherHost* rdh_; | 85 ResourceDispatcherHost* rdh_; |
| 86 bool is_paused_; | 86 bool is_paused_; |
| 87 base::OneShotTimer<DownloadResourceHandler> pause_timer_; | 87 base::OneShotTimer<DownloadResourceHandler> pause_timer_; |
| 88 | 88 |
| 89 static const int kReadBufSize = 32768; // bytes | 89 static const int kReadBufSize = 32768; // bytes |
| 90 static const size_t kLoadsToWrite = 100; // number of data buffers queued | 90 static const size_t kLoadsToWrite = 100; // number of data buffers queued |
| 91 static const int kThrottleTimeMs = 200; // milliseconds | 91 static const int kThrottleTimeMs = 200; // milliseconds |
| 92 | 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 93 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ | 96 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ |
| OLD | NEW |