| 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_FILE_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/public/browser/download_interrupt_reasons.h" | 16 #include "content/public/browser/download_interrupt_reasons.h" |
| 17 #include "content/public/browser/download_item.h" |
| 17 | 18 |
| 18 class GURL; | 19 class GURL; |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 | 22 |
| 22 class ByteStreamReader; | 23 class ByteStreamReader; |
| 23 | 24 |
| 24 // These objects live exclusively on the file thread and handle the writing | 25 // These objects live exclusively on the file thread and handle the writing |
| 25 // operations for one download. These objects live only for the duration that | 26 // operations for one download. These objects live only for the duration that |
| 26 // the download is 'in progress': once the download has been completed or | 27 // the download is 'in progress': once the download has been completed or |
| (...skipping 12 matching lines...) Expand all Loading... |
| 39 // error. | 40 // error. |
| 40 typedef base::Callback<void(DownloadInterruptReason reason, | 41 typedef base::Callback<void(DownloadInterruptReason reason, |
| 41 const base::FilePath& path)> | 42 const base::FilePath& path)> |
| 42 RenameCompletionCallback; | 43 RenameCompletionCallback; |
| 43 | 44 |
| 44 virtual ~DownloadFile() {} | 45 virtual ~DownloadFile() {} |
| 45 | 46 |
| 46 // Upon completion, |callback| will be called on the UI | 47 // Upon completion, |callback| will be called on the UI |
| 47 // thread as per the comment above, passing DOWNLOAD_INTERRUPT_REASON_NONE | 48 // thread as per the comment above, passing DOWNLOAD_INTERRUPT_REASON_NONE |
| 48 // on success, or a network download interrupt reason on failure. | 49 // on success, or a network download interrupt reason on failure. |
| 49 virtual void Initialize(const InitializeCallback& callback) = 0; | 50 virtual void Initialize( |
| 51 const InitializeCallback& callback, |
| 52 const DownloadItem::ReceivedSlices& received_slices) = 0; |
| 50 | 53 |
| 51 // Add a byte stream reader to write into a slice of the file, used for | 54 // Add a byte stream reader to write into a slice of the file, used for |
| 52 // parallel download. Called on the file thread. | 55 // parallel download. Called on the file thread. |
| 53 virtual void AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader, | 56 virtual void AddByteStream(std::unique_ptr<ByteStreamReader> stream_reader, |
| 54 int64_t offset, | 57 int64_t offset, |
| 55 int64_t length) = 0; | 58 int64_t length) = 0; |
| 56 | 59 |
| 57 // Rename the download file to |full_path|. If that file exists | 60 // Rename the download file to |full_path|. If that file exists |
| 58 // |full_path| will be uniquified by suffixing " (<number>)" to the | 61 // |full_path| will be uniquified by suffixing " (<number>)" to the |
| 59 // file name before the extension. | 62 // file name before the extension. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 84 virtual void SetPotentialFileLength(int64_t length) = 0; | 87 virtual void SetPotentialFileLength(int64_t length) = 0; |
| 85 | 88 |
| 86 virtual const base::FilePath& FullPath() const = 0; | 89 virtual const base::FilePath& FullPath() const = 0; |
| 87 virtual bool InProgress() const = 0; | 90 virtual bool InProgress() const = 0; |
| 88 virtual void WasPaused() = 0; | 91 virtual void WasPaused() = 0; |
| 89 }; | 92 }; |
| 90 | 93 |
| 91 } // namespace content | 94 } // namespace content |
| 92 | 95 |
| 93 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ | 96 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ |
| OLD | NEW |