| 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_REQUEST_CORE_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_CORE_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_CORE_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_CORE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "content/browser/loader/resource_handler.h" | 17 #include "content/browser/loader/resource_handler.h" |
| 18 #include "content/public/browser/download_interrupt_reasons.h" | 18 #include "content/public/browser/download_interrupt_reasons.h" |
| 19 #include "content/public/browser/download_save_info.h" | 19 #include "content/public/browser/download_save_info.h" |
| 20 #include "content/public/browser/download_url_parameters.h" | 20 #include "content/public/browser/download_url_parameters.h" |
| 21 | 21 |
| 22 namespace device { | |
| 23 class PowerSaveBlocker; | |
| 24 } // namespace device | |
| 25 | |
| 26 namespace net { | 22 namespace net { |
| 27 class HttpResponseHeaders; | 23 class HttpResponseHeaders; |
| 28 class URLRequest; | 24 class URLRequest; |
| 29 class URLRequestStatus; | 25 class URLRequestStatus; |
| 30 } // namespace net | 26 } // namespace net |
| 31 | 27 |
| 32 namespace content { | 28 namespace content { |
| 33 class DownloadManagerImpl; | 29 class DownloadManagerImpl; |
| 34 class ByteStreamReader; | 30 class ByteStreamReader; |
| 35 class ByteStreamWriter; | 31 class ByteStreamWriter; |
| 32 class PowerSaveBlocker; |
| 36 struct DownloadCreateInfo; | 33 struct DownloadCreateInfo; |
| 37 | 34 |
| 38 // This class encapsulates the core logic for reading data from a URLRequest and | 35 // This class encapsulates the core logic for reading data from a URLRequest and |
| 39 // writing it into a ByteStream. It's common to both DownloadResourceHandler and | 36 // writing it into a ByteStream. It's common to both DownloadResourceHandler and |
| 40 // UrlDownloader. | 37 // UrlDownloader. |
| 41 // | 38 // |
| 42 // Created, lives on and dies on the IO thread. | 39 // Created, lives on and dies on the IO thread. |
| 43 class CONTENT_EXPORT DownloadRequestCore | 40 class CONTENT_EXPORT DownloadRequestCore |
| 44 : public base::SupportsWeakPtr<DownloadRequestCore> { | 41 : public base::SupportsWeakPtr<DownloadRequestCore> { |
| 45 public: | 42 public: |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 uint32_t download_id_; | 133 uint32_t download_id_; |
| 137 DownloadUrlParameters::OnStartedCallback on_started_callback_; | 134 DownloadUrlParameters::OnStartedCallback on_started_callback_; |
| 138 | 135 |
| 139 // Data flow | 136 // Data flow |
| 140 scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest. | 137 scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest. |
| 141 std::unique_ptr<ByteStreamWriter> stream_writer_; // To rest of system. | 138 std::unique_ptr<ByteStreamWriter> stream_writer_; // To rest of system. |
| 142 | 139 |
| 143 // Keeps the system from sleeping while this is alive. If the | 140 // Keeps the system from sleeping while this is alive. If the |
| 144 // system enters power saving mode while a request is alive, it can cause the | 141 // system enters power saving mode while a request is alive, it can cause the |
| 145 // request to fail and the associated download will be interrupted. | 142 // request to fail and the associated download will be interrupted. |
| 146 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; | 143 std::unique_ptr<PowerSaveBlocker> power_save_blocker_; |
| 147 | 144 |
| 148 // The following are used to collect stats. | 145 // The following are used to collect stats. |
| 149 base::TimeTicks download_start_time_; | 146 base::TimeTicks download_start_time_; |
| 150 base::TimeTicks last_read_time_; | 147 base::TimeTicks last_read_time_; |
| 151 base::TimeTicks last_stream_pause_time_; | 148 base::TimeTicks last_stream_pause_time_; |
| 152 base::TimeDelta total_pause_time_; | 149 base::TimeDelta total_pause_time_; |
| 153 size_t last_buffer_size_; | 150 size_t last_buffer_size_; |
| 154 int64_t bytes_read_; | 151 int64_t bytes_read_; |
| 155 | 152 |
| 156 int pause_count_; | 153 int pause_count_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 167 | 164 |
| 168 // Each successful OnWillRead will yield a buffer of this size. | 165 // Each successful OnWillRead will yield a buffer of this size. |
| 169 static const int kReadBufSize = 32768; // bytes | 166 static const int kReadBufSize = 32768; // bytes |
| 170 | 167 |
| 171 DISALLOW_COPY_AND_ASSIGN(DownloadRequestCore); | 168 DISALLOW_COPY_AND_ASSIGN(DownloadRequestCore); |
| 172 }; | 169 }; |
| 173 | 170 |
| 174 } // namespace content | 171 } // namespace content |
| 175 | 172 |
| 176 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_CORE_H_ | 173 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_CORE_H_ |
| OLD | NEW |