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