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