OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 bool* defer) OVERRIDE; | 60 bool* defer) OVERRIDE; |
61 | 61 |
62 // Pass-through implementation. | 62 // Pass-through implementation. |
63 virtual bool OnWillStart(int request_id, | 63 virtual bool OnWillStart(int request_id, |
64 const GURL& url, | 64 const GURL& url, |
65 bool* defer) OVERRIDE; | 65 bool* defer) OVERRIDE; |
66 | 66 |
67 // Create a new buffer, which will be handed to the download thread for file | 67 // Create a new buffer, which will be handed to the download thread for file |
68 // writing and deletion. | 68 // writing and deletion. |
69 virtual bool OnWillRead(int request_id, | 69 virtual bool OnWillRead(int request_id, |
70 net::IOBuffer** buf, | 70 scoped_refptr<net::IOBuffer>* buf, |
71 int* buf_size, | 71 int* buf_size, |
72 int min_size) OVERRIDE; | 72 int min_size) OVERRIDE; |
73 | 73 |
74 virtual bool OnReadCompleted(int request_id, int bytes_read, | 74 virtual bool OnReadCompleted(int request_id, int bytes_read, |
75 bool* defer) OVERRIDE; | 75 bool* defer) OVERRIDE; |
76 | 76 |
77 virtual bool OnResponseCompleted(int request_id, | 77 virtual bool OnResponseCompleted(int request_id, |
78 const net::URLRequestStatus& status, | 78 const net::URLRequestStatus& status, |
79 const std::string& security_info) OVERRIDE; | 79 const std::string& security_info) OVERRIDE; |
80 | 80 |
(...skipping 17 matching lines...) Expand all Loading... |
98 // If the content-length header is not present (or contains something other | 98 // If the content-length header is not present (or contains something other |
99 // than numbers), the incoming content_length is -1 (unknown size). | 99 // than numbers), the incoming content_length is -1 (unknown size). |
100 // Set the content length to 0 to indicate unknown size to DownloadManager. | 100 // Set the content length to 0 to indicate unknown size to DownloadManager. |
101 void SetContentLength(const int64& content_length); | 101 void SetContentLength(const int64& content_length); |
102 | 102 |
103 void SetContentDisposition(const std::string& content_disposition); | 103 void SetContentDisposition(const std::string& content_disposition); |
104 | 104 |
105 uint32 download_id_; | 105 uint32 download_id_; |
106 std::string content_disposition_; | 106 std::string content_disposition_; |
107 int64 content_length_; | 107 int64 content_length_; |
108 net::URLRequest* request_; | |
109 // This is read only on the IO thread, but may only | 108 // This is read only on the IO thread, but may only |
110 // be called on the UI thread. | 109 // be called on the UI thread. |
111 DownloadUrlParameters::OnStartedCallback started_cb_; | 110 DownloadUrlParameters::OnStartedCallback started_cb_; |
112 scoped_ptr<DownloadSaveInfo> save_info_; | 111 scoped_ptr<DownloadSaveInfo> save_info_; |
113 | 112 |
114 // Data flow | 113 // Data flow |
115 scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest. | 114 scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest. |
116 scoped_ptr<ByteStreamWriter> stream_writer_; // To rest of system. | 115 scoped_ptr<ByteStreamWriter> stream_writer_; // To rest of system. |
117 | 116 |
118 // The following are used to collect stats. | 117 // The following are used to collect stats. |
(...skipping 14 matching lines...) Expand all Loading... |
133 | 132 |
134 static const int kReadBufSize = 32768; // bytes | 133 static const int kReadBufSize = 32768; // bytes |
135 static const int kThrottleTimeMs = 200; // milliseconds | 134 static const int kThrottleTimeMs = 200; // milliseconds |
136 | 135 |
137 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 136 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
138 }; | 137 }; |
139 | 138 |
140 } // namespace content | 139 } // namespace content |
141 | 140 |
142 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ | 141 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
OLD | NEW |