| 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 #include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h" | 21 #include "device/wake_lock/public/interfaces/wake_lock.mojom.h" |
| 22 #include "net/traffic_annotation/network_traffic_annotation.h" | 22 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 23 | 23 |
| 24 namespace net { | 24 namespace net { |
| 25 class HttpResponseHeaders; | 25 class HttpResponseHeaders; |
| 26 class URLRequest; | 26 class URLRequest; |
| 27 class URLRequestStatus; | 27 class URLRequestStatus; |
| 28 } // namespace net | 28 } // namespace net |
| 29 | 29 |
| 30 namespace content { | 30 namespace content { |
| 31 class ByteStreamReader; | 31 class ByteStreamReader; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 bool transient_; | 141 bool transient_; |
| 142 DownloadUrlParameters::OnStartedCallback on_started_callback_; | 142 DownloadUrlParameters::OnStartedCallback on_started_callback_; |
| 143 | 143 |
| 144 // Data flow | 144 // Data flow |
| 145 scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest. | 145 scoped_refptr<net::IOBuffer> read_buffer_; // From URLRequest. |
| 146 std::unique_ptr<ByteStreamWriter> stream_writer_; // To rest of system. | 146 std::unique_ptr<ByteStreamWriter> stream_writer_; // To rest of system. |
| 147 | 147 |
| 148 // Used to keep the system from sleeping while a download is ongoing. If the | 148 // Used to keep the system from sleeping while a download is ongoing. If the |
| 149 // system enters power saving mode while a URLRequest is alive, it can cause | 149 // system enters power saving mode while a URLRequest is alive, it can cause |
| 150 // URLRequest to fail and the associated download will be interrupted. | 150 // URLRequest to fail and the associated download will be interrupted. |
| 151 device::mojom::WakeLockServicePtr wake_lock_; | 151 device::mojom::WakeLockPtr wake_lock_; |
| 152 | 152 |
| 153 // The following are used to collect stats. | 153 // The following are used to collect stats. |
| 154 base::TimeTicks download_start_time_; | 154 base::TimeTicks download_start_time_; |
| 155 base::TimeTicks last_stream_pause_time_; | 155 base::TimeTicks last_stream_pause_time_; |
| 156 base::TimeDelta total_pause_time_; | 156 base::TimeDelta total_pause_time_; |
| 157 | 157 |
| 158 int64_t bytes_read_; | 158 int64_t bytes_read_; |
| 159 | 159 |
| 160 int pause_count_; | 160 int pause_count_; |
| 161 bool was_deferred_; | 161 bool was_deferred_; |
| 162 bool is_partial_request_; | 162 bool is_partial_request_; |
| 163 bool started_; | 163 bool started_; |
| 164 | 164 |
| 165 // When DownloadRequestCore initiates an abort (by blocking a redirect, for | 165 // When DownloadRequestCore initiates an abort (by blocking a redirect, for |
| 166 // example) it expects to eventually receive a OnResponseCompleted() with a | 166 // example) it expects to eventually receive a OnResponseCompleted() with a |
| 167 // status indicating that the request was aborted. When this happens, the | 167 // status indicating that the request was aborted. When this happens, the |
| 168 // interrupt reason in |abort_reason_| will be used instead of USER_CANCELED | 168 // interrupt reason in |abort_reason_| will be used instead of USER_CANCELED |
| 169 // which is vague. | 169 // which is vague. |
| 170 DownloadInterruptReason abort_reason_; | 170 DownloadInterruptReason abort_reason_; |
| 171 | 171 |
| 172 // Each successful OnWillRead will yield a buffer of this size. | 172 // Each successful OnWillRead will yield a buffer of this size. |
| 173 static const int kReadBufSize = 32768; // bytes | 173 static const int kReadBufSize = 32768; // bytes |
| 174 | 174 |
| 175 DISALLOW_COPY_AND_ASSIGN(DownloadRequestCore); | 175 DISALLOW_COPY_AND_ASSIGN(DownloadRequestCore); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 } // namespace content | 178 } // namespace content |
| 179 | 179 |
| 180 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_CORE_H_ | 180 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_REQUEST_CORE_H_ |
| OLD | NEW |