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_CONTENT_DOWNLOAD_DRIVER_IMPL_H_ |
| 6 #define COMPONENTS_DOWNLOAD_CONTENT_DOWNLOAD_DRIVER_IMPL_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/files/file_path.h" |
| 11 #include "components/download/internal/download_driver.h" |
| 12 #include "components/download/public/download_params.h" |
| 13 #include "content/public/browser/browser_context.h" |
| 14 #include "content/public/browser/download_manager.h" |
| 15 |
| 16 namespace download { |
| 17 |
| 18 struct DriverEntry; |
| 19 |
| 20 // Aggregates and handles all interaction between download service and content |
| 21 // download logic. |
| 22 class DownloadDriverImpl : public DownloadDriver, |
| 23 public content::DownloadManager::Observer, |
| 24 public content::DownloadItem::Observer { |
| 25 public: |
| 26 // Creates a driver entry based on a download item. |
| 27 static DriverEntry CreateDriverEntry(const content::DownloadItem* item); |
| 28 |
| 29 // Create the driver. All files downloaded will be saved to |dir|. |
| 30 DownloadDriverImpl(content::DownloadManager* manager, |
| 31 const base::FilePath& dir); |
| 32 ~DownloadDriverImpl() override; |
| 33 |
| 34 // DownloadDriver implementation. |
| 35 void Initialize(DownloadDriver::Client* client) override; |
| 36 bool IsReady() const override; |
| 37 void Start(const DownloadParams& params) override; |
| 38 void Cancel(const std::string& guid) override; |
| 39 void Pause(const std::string& guid) override; |
| 40 void Resume(const std::string& guid) override; |
| 41 base::Optional<DriverEntry> Find(const std::string& guid) override; |
| 42 |
| 43 private: |
| 44 // content::DownloadItem::Observer implementation. |
| 45 void OnDownloadUpdated(content::DownloadItem* item) override; |
| 46 |
| 47 // content::DownloadManager::Observer implementation. |
| 48 void OnDownloadCreated(content::DownloadManager* manager, |
| 49 content::DownloadItem* item) override; |
| 50 void OnManagerInitialized() override; |
| 51 void ManagerGoingDown(content::DownloadManager* manager) override; |
| 52 |
| 53 // Low level download handle. |
| 54 content::DownloadManager* download_manager_; |
| 55 |
| 56 // Target directory of download files. |
| 57 base::FilePath file_dir_; |
| 58 |
| 59 // The client that receives updates from low level download logic. |
| 60 DownloadDriver::Client* client_; |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(DownloadDriverImpl); |
| 63 }; |
| 64 |
| 65 } // namespace download |
| 66 |
| 67 #endif // COMPONENTS_DOWNLOAD_CONTENT_DOWNLOAD_DRIVER_IMPL_H_ |
OLD | NEW |