Chromium Code Reviews| 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_DESTINATION_OBSERVER_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_DESTINATION_OBSERVER_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_DESTINATION_OBSERVER_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_DESTINATION_OBSERVER_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 "content/public/browser/download_interrupt_reasons.h" | 13 #include "content/public/browser/download_interrupt_reasons.h" |
| 14 #include "content/public/browser/download_item.h" | |
| 14 #include "crypto/secure_hash.h" | 15 #include "crypto/secure_hash.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 // Class that receives asynchronous events from a DownloadDestination about | 19 // Class that receives asynchronous events from a DownloadDestination about |
| 19 // downloading progress and completion. These should report status when the | 20 // downloading progress and completion. These should report status when the |
| 20 // data arrives at its final location; i.e. DestinationUpdate should be | 21 // data arrives at its final location; i.e. DestinationUpdate should be |
| 21 // called after the destination is finished with whatever operation it | 22 // called after the destination is finished with whatever operation it |
| 22 // is doing on the data described by |bytes_so_far| and DestinationCompleted | 23 // is doing on the data described by |bytes_so_far| and DestinationCompleted |
| 23 // should only be called once that is true for all data. | 24 // should only be called once that is true for all data. |
| 24 // | 25 // |
| 25 // All methods are invoked on the UI thread. | 26 // All methods are invoked on the UI thread. |
| 26 // | 27 // |
| 27 // Note that this interface does not deal with cross-thread lifetime issues. | 28 // Note that this interface does not deal with cross-thread lifetime issues. |
| 28 class DownloadDestinationObserver { | 29 class DownloadDestinationObserver { |
| 29 public: | 30 public: |
| 30 virtual void DestinationUpdate(int64_t bytes_so_far, | 31 virtual void DestinationUpdate( |
| 31 int64_t bytes_per_sec) = 0; | 32 int64_t bytes_so_far, |
| 33 int64_t bytes_per_sec, | |
| 34 const std::vector<DownloadItem::ReceivedSlice>& received_slices) = 0; | |
|
xingliu
2017/02/28 22:36:00
This is called every 0.5 second, is received_slice
qinmin
2017/02/28 22:38:21
yes, we need to keep the history db up-to-date.
| |
| 32 | 35 |
| 33 virtual void DestinationError( | 36 virtual void DestinationError( |
| 34 DownloadInterruptReason reason, | 37 DownloadInterruptReason reason, |
| 35 int64_t bytes_so_far, | 38 int64_t bytes_so_far, |
| 36 std::unique_ptr<crypto::SecureHash> hash_state) = 0; | 39 std::unique_ptr<crypto::SecureHash> hash_state) = 0; |
| 37 | 40 |
| 38 virtual void DestinationCompleted( | 41 virtual void DestinationCompleted( |
| 39 int64_t total_bytes, | 42 int64_t total_bytes, |
| 40 std::unique_ptr<crypto::SecureHash> hash_state) = 0; | 43 std::unique_ptr<crypto::SecureHash> hash_state) = 0; |
| 41 }; | 44 }; |
| 42 | 45 |
| 43 } // namespace content | 46 } // namespace content |
| 44 | 47 |
| 45 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_DESTINATION_OBSERVER_H_ | 48 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_DESTINATION_OBSERVER_H_ |
| OLD | NEW |