| 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 #include "content/public/browser/download_item.h" |
| 18 | 18 |
| 19 class GURL; | 19 class GURL; |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 class ByteStreamReader; | 23 class ByteStreamReader; |
| 24 | 24 |
| 25 // These objects live exclusively on the file thread and handle the writing | 25 // These objects live exclusively on the download sequence and handle the |
| 26 // operations for one download. These objects live only for the duration that | 26 // writing operations for one download. These objects live only for the duration |
| 27 // the download is 'in progress': once the download has been completed or | 27 // that the download is 'in progress': once the download has been completed or |
| 28 // cancelled, the DownloadFile is destroyed. | 28 // cancelled, the DownloadFile is destroyed. |
| 29 class CONTENT_EXPORT DownloadFile { | 29 class CONTENT_EXPORT DownloadFile { |
| 30 public: | 30 public: |
| 31 // Callback used with Initialize. On a successful initialize, |reason| will | 31 // Callback used with Initialize. On a successful initialize, |reason| will |
| 32 // be DOWNLOAD_INTERRUPT_REASON_NONE; on a failed initialize, it will be | 32 // be DOWNLOAD_INTERRUPT_REASON_NONE; on a failed initialize, it will be |
| 33 // set to the reason for the failure. | 33 // set to the reason for the failure. |
| 34 typedef base::Callback<void(DownloadInterruptReason reason)> | 34 typedef base::Callback<void(DownloadInterruptReason reason)> |
| 35 InitializeCallback; | 35 InitializeCallback; |
| 36 | 36 |
| 37 // Callback used with Rename*(). On a successful rename |reason| will be | 37 // Callback used with Rename*(). On a successful rename |reason| will be |
| 38 // DOWNLOAD_INTERRUPT_REASON_NONE and |path| the path the rename | 38 // DOWNLOAD_INTERRUPT_REASON_NONE and |path| the path the rename |
| 39 // was done to. On a failed rename, |reason| will contain the | 39 // was done to. On a failed rename, |reason| will contain the |
| 40 // error. | 40 // error. |
| 41 typedef base::Callback<void(DownloadInterruptReason reason, | 41 typedef base::Callback<void(DownloadInterruptReason reason, |
| 42 const base::FilePath& path)> | 42 const base::FilePath& path)> |
| 43 RenameCompletionCallback; | 43 RenameCompletionCallback; |
| 44 | 44 |
| 45 // Used to drop the request, when the byte stream reader should be closed on | 45 // Used to drop the request, when the byte stream reader should be closed on |
| 46 // FILE thread. | 46 // download sequence. |
| 47 typedef base::Callback<void(int64_t offset)> CancelRequestCallback; | 47 typedef base::Callback<void(int64_t offset)> CancelRequestCallback; |
| 48 | 48 |
| 49 virtual ~DownloadFile() {} | 49 virtual ~DownloadFile() {} |
| 50 | 50 |
| 51 // Upon completion, |initialize_callback| will be called on the UI | 51 // Upon completion, |initialize_callback| will be called on the UI |
| 52 // thread as per the comment above, passing DOWNLOAD_INTERRUPT_REASON_NONE | 52 // thread as per the comment above, passing DOWNLOAD_INTERRUPT_REASON_NONE |
| 53 // on success, or a network download interrupt reason on failure. | 53 // on success, or a network download interrupt reason on failure. |
| 54 virtual void Initialize(const InitializeCallback& initialize_callback, | 54 virtual void Initialize(const InitializeCallback& initialize_callback, |
| 55 const CancelRequestCallback& cancel_request_callback, | 55 const CancelRequestCallback& cancel_request_callback, |
| 56 const DownloadItem::ReceivedSlices& received_slices, | 56 const DownloadItem::ReceivedSlices& received_slices, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 virtual void SetPotentialFileLength(int64_t length) = 0; | 92 virtual void SetPotentialFileLength(int64_t length) = 0; |
| 93 | 93 |
| 94 virtual const base::FilePath& FullPath() const = 0; | 94 virtual const base::FilePath& FullPath() const = 0; |
| 95 virtual bool InProgress() const = 0; | 95 virtual bool InProgress() const = 0; |
| 96 virtual void WasPaused() = 0; | 96 virtual void WasPaused() = 0; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 } // namespace content | 99 } // namespace content |
| 100 | 100 |
| 101 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ | 101 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ |
| OLD | NEW |