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_THROTTLING_RESOURCE_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_THROTTLING_RESOURCE_HANDLER_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_THROTTLING_RESOURCE_HANDLER_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_THROTTLING_RESOURCE_HANDLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/renderer_host/resource_handler.h" | 10 #include "chrome/browser/renderer_host/resource_handler.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 int request_id, | 33 int request_id, |
34 bool in_complete); | 34 bool in_complete); |
35 virtual ~DownloadThrottlingResourceHandler(); | 35 virtual ~DownloadThrottlingResourceHandler(); |
36 | 36 |
37 // ResourceHanlder implementation: | 37 // ResourceHanlder implementation: |
38 virtual bool OnUploadProgress(int request_id, | 38 virtual bool OnUploadProgress(int request_id, |
39 uint64 position, | 39 uint64 position, |
40 uint64 size); | 40 uint64 size); |
41 virtual bool OnRequestRedirected(int request_id, const GURL& url); | 41 virtual bool OnRequestRedirected(int request_id, const GURL& url); |
42 virtual bool OnResponseStarted(int request_id, ResourceResponse* response); | 42 virtual bool OnResponseStarted(int request_id, ResourceResponse* response); |
43 virtual bool OnWillRead(int request_id, | 43 virtual bool OnWillRead(int request_id, net::IOBuffer** buf, int* buf_size, |
44 char** buf, | |
45 int* buf_size, | |
46 int min_size); | 44 int min_size); |
47 virtual bool OnReadCompleted(int request_id, int* bytes_read); | 45 virtual bool OnReadCompleted(int request_id, int* bytes_read); |
48 virtual bool OnResponseCompleted(int request_id, | 46 virtual bool OnResponseCompleted(int request_id, |
49 const URLRequestStatus& status); | 47 const URLRequestStatus& status); |
50 | 48 |
51 // DownloadRequestManager::Callback implementation: | 49 // DownloadRequestManager::Callback implementation: |
52 void CancelDownload(); | 50 void CancelDownload(); |
53 void ContinueDownload(); | 51 void ContinueDownload(); |
54 | 52 |
55 private: | 53 private: |
56 void CopyTmpBufferToDownloadHandler(); | 54 void CopyTmpBufferToDownloadHandler(); |
57 | 55 |
58 ResourceDispatcherHost* host_; | 56 ResourceDispatcherHost* host_; |
59 URLRequest* request_; | 57 URLRequest* request_; |
60 std::string url_; | 58 std::string url_; |
61 int render_process_host_id_; | 59 int render_process_host_id_; |
62 int render_view_id_; | 60 int render_view_id_; |
63 int request_id_; | 61 int request_id_; |
64 | 62 |
65 // Handles the actual download. This is only created if the download is | 63 // Handles the actual download. This is only created if the download is |
66 // allowed to continue. | 64 // allowed to continue. |
67 scoped_refptr<DownloadResourceHandler> download_handler_; | 65 scoped_refptr<DownloadResourceHandler> download_handler_; |
68 | 66 |
69 // Response supplied to OnResponseStarted. Only non-null if OnResponseStarted | 67 // Response supplied to OnResponseStarted. Only non-null if OnResponseStarted |
70 // is invoked. | 68 // is invoked. |
71 scoped_refptr<ResourceResponse> response_; | 69 scoped_refptr<ResourceResponse> response_; |
72 | 70 |
73 // If we're created by way of BufferedEventHandler we'll get one request for | 71 // If we're created by way of BufferedEventHandler we'll get one request for |
74 // a buffer. This is that buffer. | 72 // a buffer. This is that buffer. |
75 scoped_array<char> tmp_buffer_; | 73 scoped_refptr<net::IOBuffer> tmp_buffer_; |
76 int tmp_buffer_length_; | 74 int tmp_buffer_length_; |
77 | 75 |
78 // If true the next call to OnReadCompleted is ignored. This is used if we're | 76 // If true the next call to OnReadCompleted is ignored. This is used if we're |
79 // paused during a call to OnReadCompleted. Pausing during OnReadCompleted | 77 // paused during a call to OnReadCompleted. Pausing during OnReadCompleted |
80 // results in two calls to OnReadCompleted for the same data. This make sure | 78 // results in two calls to OnReadCompleted for the same data. This make sure |
81 // we ignore one of them. | 79 // we ignore one of them. |
82 bool ignore_on_read_complete_; | 80 bool ignore_on_read_complete_; |
83 | 81 |
84 DISALLOW_COPY_AND_ASSIGN(DownloadThrottlingResourceHandler); | 82 DISALLOW_COPY_AND_ASSIGN(DownloadThrottlingResourceHandler); |
85 }; | 83 }; |
86 | 84 |
87 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_THROTTLING_RESOURCE_HANDLER_H_ | 85 #endif // CHROME_BROWSER_RENDERER_HOST_DOWNLOAD_THROTTLING_RESOURCE_HANDLER_H_ |
OLD | NEW |