| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 std::string DebugString() const; | 88 std::string DebugString() const; |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 virtual ~DownloadResourceHandler(); | 91 virtual ~DownloadResourceHandler(); |
| 92 | 92 |
| 93 // Arrange for started_cb_ to be called on the UI thread with the | 93 // Arrange for started_cb_ to be called on the UI thread with the |
| 94 // below values, nulling out started_cb_. Should only be called | 94 // below values, nulling out started_cb_. Should only be called |
| 95 // on the IO thread. | 95 // on the IO thread. |
| 96 void CallStartedCB(DownloadItem* item, net::Error error); | 96 void CallStartedCB(DownloadItem* item, net::Error error); |
| 97 | 97 |
| 98 // If the content-length header is not present (or contains something other | |
| 99 // than numbers), the incoming content_length is -1 (unknown size). | |
| 100 // Set the content length to 0 to indicate unknown size to DownloadManager. | |
| 101 void SetContentLength(const int64& content_length); | |
| 102 | |
| 103 void SetContentDisposition(const std::string& content_disposition); | |
| 104 | |
| 105 uint32 download_id_; | 98 uint32 download_id_; |
| 106 std::string content_disposition_; | |
| 107 int64 content_length_; | |
| 108 // This is read only on the IO thread, but may only | 99 // This is read only on the IO thread, but may only |
| 109 // be called on the UI thread. | 100 // be called on the UI thread. |
| 110 DownloadUrlParameters::OnStartedCallback started_cb_; | 101 DownloadUrlParameters::OnStartedCallback started_cb_; |
| 111 scoped_ptr<DownloadSaveInfo> save_info_; | 102 scoped_ptr<DownloadSaveInfo> save_info_; |
| 112 | 103 |
| 113 // Data flow | 104 // Data flow |
| 114 scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest. | 105 scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest. |
| 115 scoped_ptr<ByteStreamWriter> stream_writer_; // To rest of system. | 106 scoped_ptr<ByteStreamWriter> stream_writer_; // To rest of system. |
| 116 | 107 |
| 117 // The following are used to collect stats. | 108 // The following are used to collect stats. |
| 118 base::TimeTicks download_start_time_; | 109 base::TimeTicks download_start_time_; |
| 119 base::TimeTicks last_read_time_; | 110 base::TimeTicks last_read_time_; |
| 120 base::TimeTicks last_stream_pause_time_; | 111 base::TimeTicks last_stream_pause_time_; |
| 121 base::TimeDelta total_pause_time_; | 112 base::TimeDelta total_pause_time_; |
| 122 size_t last_buffer_size_; | 113 size_t last_buffer_size_; |
| 123 int64 bytes_read_; | 114 int64 bytes_read_; |
| 124 std::string accept_ranges_; | |
| 125 std::string etag_; | |
| 126 | 115 |
| 127 int pause_count_; | 116 int pause_count_; |
| 128 bool was_deferred_; | 117 bool was_deferred_; |
| 129 | 118 |
| 130 // For DCHECKing | 119 // For DCHECKing |
| 131 bool on_response_started_called_; | 120 bool on_response_started_called_; |
| 132 | 121 |
| 133 static const int kReadBufSize = 32768; // bytes | 122 static const int kReadBufSize = 32768; // bytes |
| 134 static const int kThrottleTimeMs = 200; // milliseconds | 123 static const int kThrottleTimeMs = 200; // milliseconds |
| 135 | 124 |
| 136 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); | 125 DISALLOW_COPY_AND_ASSIGN(DownloadResourceHandler); |
| 137 }; | 126 }; |
| 138 | 127 |
| 139 } // namespace content | 128 } // namespace content |
| 140 | 129 |
| 141 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ | 130 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_RESOURCE_HANDLER_H_ |
| OLD | NEW |