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