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_INTERNAL_TEST_TEST_DOWNLOAD_DRIVER_H_ | 5 #ifndef COMPONENTS_DOWNLOAD_INTERNAL_TEST_TEST_DOWNLOAD_DRIVER_H_ |
6 #define COMPONENTS_DOWNLOAD_INTERNAL_TEST_TEST_DOWNLOAD_DRIVER_H_ | 6 #define COMPONENTS_DOWNLOAD_INTERNAL_TEST_TEST_DOWNLOAD_DRIVER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "components/download/internal/download_driver.h" | 12 #include "components/download/internal/download_driver.h" |
| 13 #include "net/traffic_annotation/network_traffic_annotation.h" |
13 | 14 |
14 namespace download { | 15 namespace download { |
15 | 16 |
16 // Download driver that simulates content layer download logic. | 17 // Download driver that simulates content layer download logic. |
17 class TestDownloadDriver : public DownloadDriver { | 18 class TestDownloadDriver : public DownloadDriver { |
18 public: | 19 public: |
19 TestDownloadDriver(); | 20 TestDownloadDriver(); |
20 ~TestDownloadDriver(); | 21 ~TestDownloadDriver(); |
21 | 22 |
22 // Marks download driver as ready, used to test logic that depends on | 23 // Marks download driver as ready, used to test logic that depends on |
23 // data initialization. | 24 // data initialization. |
24 void MakeReady(); | 25 void MakeReady(); |
25 | 26 |
26 // Simulates download events from content layer. | 27 // Simulates download events from content layer. |
27 void NotifyDownloadUpdate(const DriverEntry& entry); | 28 void NotifyDownloadUpdate(const DriverEntry& entry); |
28 void NotifyDownloadFailed(const DriverEntry& entry, int reason); | 29 void NotifyDownloadFailed(const DriverEntry& entry, int reason); |
29 void NotifyDownloadSucceeded(const DriverEntry& entry, | 30 void NotifyDownloadSucceeded(const DriverEntry& entry, |
30 const base::FilePath& path); | 31 const base::FilePath& path); |
31 | 32 |
32 // DownloadDriver implementation. | 33 // DownloadDriver implementation. |
33 void Initialize(DownloadDriver::Client* client) override; | 34 void Initialize(DownloadDriver::Client* client) override; |
34 bool IsReady() const override; | 35 bool IsReady() const override; |
35 void Start(const DownloadParams& params) override; | 36 void Start( |
| 37 const DownloadParams& params, |
| 38 const net::NetworkTrafficAnnotationTag& traffic_annotation) override; |
36 void Cancel(const std::string& guid) override; | 39 void Cancel(const std::string& guid) override; |
37 void Pause(const std::string& guid) override; | 40 void Pause(const std::string& guid) override; |
38 void Resume(const std::string& guid) override; | 41 void Resume(const std::string& guid) override; |
39 base::Optional<DriverEntry> Find(const std::string& guid) override; | 42 base::Optional<DriverEntry> Find(const std::string& guid) override; |
40 | 43 |
41 private: | 44 private: |
42 bool is_ready_; | 45 bool is_ready_; |
43 DownloadDriver::Client* client_; | 46 DownloadDriver::Client* client_; |
44 | 47 |
45 // Map of guid --> DriverEntry. | 48 // Map of guid --> DriverEntry. |
46 std::map<std::string, DriverEntry> entries_; | 49 std::map<std::string, DriverEntry> entries_; |
47 | 50 |
48 DISALLOW_COPY_AND_ASSIGN(TestDownloadDriver); | 51 DISALLOW_COPY_AND_ASSIGN(TestDownloadDriver); |
49 }; | 52 }; |
50 | 53 |
51 } // namespace download | 54 } // namespace download |
52 | 55 |
53 #endif // COMPONENTS_DOWNLOAD_CONTENT_TEST_TEST_DOWNLOAD_DRIVER_H_ | 56 #endif // COMPONENTS_DOWNLOAD_CONTENT_TEST_TEST_DOWNLOAD_DRIVER_H_ |
OLD | NEW |