OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_DRIVER_H_ |
| 6 #define COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_DRIVER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/optional.h" |
| 11 #include "components/download/internal/driver_entry.h" |
| 12 |
| 13 namespace base { |
| 14 class FilePath; |
| 15 } // namespace base |
| 16 |
| 17 namespace download { |
| 18 |
| 19 struct DownloadParams; |
| 20 |
| 21 // The interface that includes all the operations to interact with low level |
| 22 // download library functionalities. |
| 23 class DownloadDriver { |
| 24 public: |
| 25 // The client to receive updates from content download library. |
| 26 // The update events for all downloads will pass through, so it's the |
| 27 // client's responsibility to filter the events it needs to handle. |
| 28 class Client { |
| 29 public: |
| 30 // Called when the low level download library is ready. |
| 31 virtual void OnDriverReady() = 0; |
| 32 |
| 33 // Called when any download is created. |
| 34 virtual void OnDownloadCreated(const DriverEntry& download) = 0; |
| 35 |
| 36 // Called when any download is failed. |
| 37 virtual void OnDownloadFailed(const DriverEntry& download, int reason) = 0; |
| 38 |
| 39 // Called when any download is successfully completed. |
| 40 virtual void OnDownloadSucceeded(const DriverEntry& download, |
| 41 const base::FilePath& path) = 0; |
| 42 |
| 43 // Called when any download is updated. |
| 44 virtual void OnDownloadUpdated(const DriverEntry& download) = 0; |
| 45 }; |
| 46 |
| 47 // Initialize the driver to receive download updates. |
| 48 virtual void Initialize(Client* client) = 0; |
| 49 |
| 50 // Starts a new download. |
| 51 virtual void Start(const DownloadParams& params) = 0; |
| 52 |
| 53 // Cancels an existing download, all data associated with this download should |
| 54 // be removed. |
| 55 virtual void Cancel(const std::string& guid) = 0; |
| 56 |
| 57 // Pauses the download. |
| 58 virtual void Pause(const std::string& guid) = 0; |
| 59 |
| 60 // Resumes the download |
| 61 virtual void Resume(const std::string& guid) = 0; |
| 62 |
| 63 // Find a download record from low level download library. |
| 64 virtual base::Optional<DriverEntry> Find(const std::string& guid) = 0; |
| 65 }; |
| 66 |
| 67 } // namespace download |
| 68 |
| 69 #endif // COMPONENTS_DOWNLOAD_INTERNAL_DOWNLOAD_DRIVER_H_ |
OLD | NEW |