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