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