OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 DownloadResourceHandler(ResourceDispatcherHost* rdh, | 27 DownloadResourceHandler(ResourceDispatcherHost* rdh, |
28 int render_process_host_id, | 28 int render_process_host_id, |
29 int render_view_id, | 29 int render_view_id, |
30 int request_id, | 30 int request_id, |
31 const GURL& url, | 31 const GURL& url, |
32 DownloadFileManager* download_file_manager, | 32 DownloadFileManager* download_file_manager, |
33 net::URLRequest* request, | 33 net::URLRequest* request, |
34 bool save_as, | 34 bool save_as, |
35 const DownloadSaveInfo& save_info); | 35 const DownloadSaveInfo& save_info); |
36 | 36 |
37 bool OnUploadProgress(int request_id, uint64 position, uint64 size); | 37 virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size); |
38 | 38 |
39 // Not needed, as this event handler ought to be the final resource. | 39 // Not needed, as this event handler ought to be the final resource. |
40 bool OnRequestRedirected(int request_id, const GURL& url, | 40 virtual bool OnRequestRedirected(int request_id, const GURL& url, |
41 ResourceResponse* response, bool* defer); | 41 ResourceResponse* response, bool* defer); |
42 | 42 |
43 // Send the download creation information to the download thread. | 43 // Send the download creation information to the download thread. |
44 bool OnResponseStarted(int request_id, ResourceResponse* response); | 44 virtual bool OnResponseStarted(int request_id, ResourceResponse* response); |
45 | 45 |
46 // Pass-through implementation. | 46 // Pass-through implementation. |
47 bool OnWillStart(int request_id, const GURL& url, bool* defer); | 47 virtual bool OnWillStart(int request_id, const GURL& url, bool* defer); |
48 | 48 |
49 // Create a new buffer, which will be handed to the download thread for file | 49 // Create a new buffer, which will be handed to the download thread for file |
50 // writing and deletion. | 50 // writing and deletion. |
51 bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, | 51 virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, |
52 int min_size); | 52 int min_size); |
53 | 53 |
54 bool OnReadCompleted(int request_id, int* bytes_read); | 54 virtual bool OnReadCompleted(int request_id, int* bytes_read); |
55 | 55 |
56 bool OnResponseCompleted(int request_id, | 56 virtual bool OnResponseCompleted(int request_id, |
57 const URLRequestStatus& status, | 57 const URLRequestStatus& status, |
58 const std::string& security_info); | 58 const std::string& security_info); |
59 void OnRequestClosed(); | 59 virtual void OnRequestClosed(); |
60 | 60 |
61 // If the content-length header is not present (or contains something other | 61 // If the content-length header is not present (or contains something other |
62 // than numbers), the incoming content_length is -1 (unknown size). | 62 // than numbers), the incoming content_length is -1 (unknown size). |
63 // Set the content length to 0 to indicate unknown size to DownloadManager. | 63 // Set the content length to 0 to indicate unknown size to DownloadManager. |
64 void set_content_length(const int64& content_length); | 64 void set_content_length(const int64& content_length); |
65 | 65 |
66 void set_content_disposition(const std::string& content_disposition); | 66 void set_content_disposition(const std::string& content_disposition); |
67 | 67 |
68 void CheckWriteProgress(); | 68 void CheckWriteProgress(); |
69 | 69 |
(...skipping 21 matching lines...) Expand all Loading... |
91 base::OneShotTimer<DownloadResourceHandler> pause_timer_; | 91 base::OneShotTimer<DownloadResourceHandler> pause_timer_; |
92 | 92 |
93 static const int kReadBufSize = 32768; // bytes | 93 static const int kReadBufSize = 32768; // bytes |
94 static const size_t kLoadsToWrite = 100; // number of data buffers queued | 94 static const size_t kLoadsToWrite = 100; // number of data buffers queued |
95 static const int kThrottleTimeMs = 200; // milliseconds | 95 static const int kThrottleTimeMs = 200; // milliseconds |
96 | 96 |
97 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 97 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
98 }; | 98 }; |
99 | 99 |
100 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ | 100 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_RESOURCE_HANDLER_H_ |
OLD | NEW |