| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 int render_view_id, | 42 int render_view_id, |
| 43 int request_id, | 43 int request_id, |
| 44 const GURL& url, | 44 const GURL& url, |
| 45 DownloadId dl_id, | 45 DownloadId dl_id, |
| 46 DownloadFileManager* download_file_manager, | 46 DownloadFileManager* download_file_manager, |
| 47 net::URLRequest* request, | 47 net::URLRequest* request, |
| 48 bool save_as, | 48 bool save_as, |
| 49 const OnStartedCallback& started_cb, | 49 const OnStartedCallback& started_cb, |
| 50 const DownloadSaveInfo& save_info); | 50 const DownloadSaveInfo& save_info); |
| 51 | 51 |
| 52 virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size); | 52 virtual bool OnUploadProgress(int request_id, |
| 53 uint64 position, |
| 54 uint64 size) OVERRIDE; |
| 53 | 55 |
| 54 // Not needed, as this event handler ought to be the final resource. | 56 // Not needed, as this event handler ought to be the final resource. |
| 55 virtual bool OnRequestRedirected(int request_id, const GURL& url, | 57 virtual bool OnRequestRedirected(int request_id, |
| 56 ResourceResponse* response, bool* defer); | 58 const GURL& url, |
| 59 ResourceResponse* response, |
| 60 bool* defer) OVERRIDE; |
| 57 | 61 |
| 58 // Send the download creation information to the download thread. | 62 // Send the download creation information to the download thread. |
| 59 virtual bool OnResponseStarted(int request_id, ResourceResponse* response); | 63 virtual bool OnResponseStarted(int request_id, |
| 64 ResourceResponse* response) OVERRIDE; |
| 60 | 65 |
| 61 // Pass-through implementation. | 66 // Pass-through implementation. |
| 62 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer); | 67 virtual bool OnWillStart(int request_id, |
| 68 const GURL& url, |
| 69 bool* defer) OVERRIDE; |
| 63 | 70 |
| 64 // Create a new buffer, which will be handed to the download thread for file | 71 // Create a new buffer, which will be handed to the download thread for file |
| 65 // writing and deletion. | 72 // writing and deletion. |
| 66 virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, | 73 virtual bool OnWillRead(int request_id, |
| 67 int min_size); | 74 net::IOBuffer** buf, |
| 75 int* buf_size, |
| 76 int min_size) OVERRIDE; |
| 68 | 77 |
| 69 virtual bool OnReadCompleted(int request_id, int* bytes_read); | 78 virtual bool OnReadCompleted(int request_id, int* bytes_read) OVERRIDE; |
| 70 | 79 |
| 71 virtual bool OnResponseCompleted(int request_id, | 80 virtual bool OnResponseCompleted(int request_id, |
| 72 const net::URLRequestStatus& status, | 81 const net::URLRequestStatus& status, |
| 73 const std::string& security_info); | 82 const std::string& security_info) OVERRIDE; |
| 74 virtual void OnRequestClosed(); | 83 virtual void OnRequestClosed() OVERRIDE; |
| 75 | 84 |
| 76 // If the content-length header is not present (or contains something other | 85 // If the content-length header is not present (or contains something other |
| 77 // than numbers), the incoming content_length is -1 (unknown size). | 86 // than numbers), the incoming content_length is -1 (unknown size). |
| 78 // Set the content length to 0 to indicate unknown size to DownloadManager. | 87 // Set the content length to 0 to indicate unknown size to DownloadManager. |
| 79 void set_content_length(const int64& content_length); | 88 void set_content_length(const int64& content_length); |
| 80 | 89 |
| 81 void set_content_disposition(const std::string& content_disposition); | 90 void set_content_disposition(const std::string& content_disposition); |
| 82 | 91 |
| 83 void CheckWriteProgress(); | 92 void CheckWriteProgress(); |
| 84 | 93 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 108 base::TimeTicks download_start_time_; // used to collect stats. | 117 base::TimeTicks download_start_time_; // used to collect stats. |
| 109 base::TimeTicks last_read_time_; // used to collect stats. | 118 base::TimeTicks last_read_time_; // used to collect stats. |
| 110 size_t last_buffer_size_; // used to collect stats. | 119 size_t last_buffer_size_; // used to collect stats. |
| 111 static const int kReadBufSize = 32768; // bytes | 120 static const int kReadBufSize = 32768; // bytes |
| 112 static const int kThrottleTimeMs = 200; // milliseconds | 121 static const int kThrottleTimeMs = 200; // milliseconds |
| 113 | 122 |
| 114 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 123 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
| 115 }; | 124 }; |
| 116 | 125 |
| 117 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ | 126 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
| OLD | NEW |