| 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 scoped_refptr<net::IOBuffer>* buf, | 70 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_; |
| 108 // This is read only on the IO thread, but may only | 109 // This is read only on the IO thread, but may only |
| 109 // be called on the UI thread. | 110 // be called on the UI thread. |
| 110 DownloadUrlParameters::OnStartedCallback started_cb_; | 111 DownloadUrlParameters::OnStartedCallback started_cb_; |
| 111 scoped_ptr<DownloadSaveInfo> save_info_; | 112 scoped_ptr<DownloadSaveInfo> save_info_; |
| 112 | 113 |
| 113 // Data flow | 114 // Data flow |
| 114 scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest. | 115 scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest. |
| 115 scoped_ptr<ByteStreamWriter> stream_writer_; // To rest of system. | 116 scoped_ptr<ByteStreamWriter> stream_writer_; // To rest of system. |
| 116 | 117 |
| 117 // The following are used to collect stats. | 118 // The following are used to collect stats. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 132 | 133 |
| 133 static const int kReadBufSize = 32768; // bytes | 134 static const int kReadBufSize = 32768; // bytes |
| 134 static const int kThrottleTimeMs = 200; // milliseconds | 135 static const int kThrottleTimeMs = 200; // milliseconds |
| 135 | 136 |
| 136 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 137 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
| 137 }; | 138 }; |
| 138 | 139 |
| 139 } // namespace content | 140 } // namespace content |
| 140 | 141 |
| 141 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ | 142 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
| OLD | NEW |