| 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 "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 bool save_as); | 25 bool save_as); |
| 26 | 26 |
| 27 // Not needed, as this event handler ought to be the final resource. | 27 // Not needed, as this event handler ought to be the final resource. |
| 28 bool OnRequestRedirected(int request_id, const GURL& url); | 28 bool OnRequestRedirected(int request_id, const GURL& url); |
| 29 | 29 |
| 30 // Send the download creation information to the download thread. | 30 // Send the download creation information to the download thread. |
| 31 bool OnResponseStarted(int request_id, ResourceResponse* response); | 31 bool OnResponseStarted(int request_id, ResourceResponse* response); |
| 32 | 32 |
| 33 // Create a new buffer, which will be handed to the download thread for file | 33 // Create a new buffer, which will be handed to the download thread for file |
| 34 // writing and deletion. | 34 // writing and deletion. |
| 35 bool OnWillRead(int request_id, char** buf, int* buf_size, int min_size); | 35 bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, |
| 36 int min_size); |
| 36 | 37 |
| 37 bool OnReadCompleted(int request_id, int* bytes_read); | 38 bool OnReadCompleted(int request_id, int* bytes_read); |
| 38 | 39 |
| 39 bool OnResponseCompleted(int request_id, const URLRequestStatus& status); | 40 bool OnResponseCompleted(int request_id, const URLRequestStatus& status); |
| 40 | 41 |
| 41 // If the content-length header is not present (or contains something other | 42 // If the content-length header is not present (or contains something other |
| 42 // than numbers), the incoming content_length is -1 (unknown size). | 43 // than numbers), the incoming content_length is -1 (unknown size). |
| 43 // Set the content length to 0 to indicate unknown size to DownloadManager. | 44 // Set the content length to 0 to indicate unknown size to DownloadManager. |
| 44 void set_content_length(const int64& content_length); | 45 void set_content_length(const int64& content_length); |
| 45 | 46 |
| 46 void set_content_disposition(const std::string& content_disposition); | 47 void set_content_disposition(const std::string& content_disposition); |
| 47 | 48 |
| 48 void CheckWriteProgress(); | 49 void CheckWriteProgress(); |
| 49 | 50 |
| 50 private: | 51 private: |
| 51 void StartPauseTimer(); | 52 void StartPauseTimer(); |
| 52 | 53 |
| 53 int download_id_; | 54 int download_id_; |
| 54 ResourceDispatcherHost::GlobalRequestID global_id_; | 55 ResourceDispatcherHost::GlobalRequestID global_id_; |
| 55 int render_view_id_; | 56 int render_view_id_; |
| 56 char* read_buffer_; | 57 scoped_refptr<net::IOBuffer> read_buffer_; |
| 57 std::string content_disposition_; | 58 std::string content_disposition_; |
| 58 std::wstring url_; | 59 std::wstring url_; |
| 59 int64 content_length_; | 60 int64 content_length_; |
| 60 DownloadFileManager* download_manager_; | 61 DownloadFileManager* download_manager_; |
| 61 URLRequest* request_; | 62 URLRequest* request_; |
| 62 bool save_as_; // Request was initiated via "Save As" by the user. | 63 bool save_as_; // Request was initiated via "Save As" by the user. |
| 63 DownloadBuffer* buffer_; | 64 DownloadBuffer* buffer_; |
| 64 ResourceDispatcherHost* rdh_; | 65 ResourceDispatcherHost* rdh_; |
| 65 bool is_paused_; | 66 bool is_paused_; |
| 66 base::OneShotTimer<DownloadResourceHandler> pause_timer_; | 67 base::OneShotTimer<DownloadResourceHandler> pause_timer_; |
| 67 | 68 |
| 68 static const int kReadBufSize = 32768; // bytes | 69 static const int kReadBufSize = 32768; // bytes |
| 69 static const size_t kLoadsToWrite = 100; // number of data buffers queued | 70 static const size_t kLoadsToWrite = 100; // number of data buffers queued |
| 70 static const int kThrottleTimeMs = 200; // milliseconds | 71 static const int kThrottleTimeMs = 200; // milliseconds |
| 71 | 72 |
| 72 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 73 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ | 76 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ |
| OLD | NEW |