| 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 CHROMEOS_COMPONENTS_TETHER_FAKE_TETHER_HOST_FETCHER_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_FAKE_TETHER_HOST_FETCHER_H_ |
| 6 #define CHROMEOS_COMPONENTS_TETHER_FAKE_TETHER_HOST_FETCHER_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_FAKE_TETHER_HOST_FETCHER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "chromeos/components/tether/tether_host_fetcher.h" | 11 #include "chromeos/components/tether/tether_host_fetcher.h" |
| 12 #include "components/cryptauth/remote_device.h" | 12 #include "components/cryptauth/remote_device.h" |
| 13 | 13 |
| 14 namespace chromeos { | 14 namespace chromeos { |
| 15 | 15 |
| 16 namespace tether { | 16 namespace tether { |
| 17 | 17 |
| 18 // Test double for TetherHostFetcher. | 18 // Test double for TetherHostFetcher. |
| 19 class FakeTetherHostFetcher : public TetherHostFetcher { | 19 class FakeTetherHostFetcher : public TetherHostFetcher { |
| 20 public: | 20 public: |
| 21 FakeTetherHostFetcher(std::vector<cryptauth::RemoteDevice> tether_hosts, | 21 FakeTetherHostFetcher(std::vector<cryptauth::RemoteDevice> tether_hosts, |
| 22 bool synchronously_reply_with_results); | 22 bool synchronously_reply_with_results); |
| 23 FakeTetherHostFetcher(bool synchronously_reply_with_results); | 23 explicit FakeTetherHostFetcher(bool synchronously_reply_with_results); |
| 24 ~FakeTetherHostFetcher() override; | 24 ~FakeTetherHostFetcher() override; |
| 25 | 25 |
| 26 void set_synchronously_reply_with_results( |
| 27 bool synchronously_reply_with_results) { |
| 28 synchronously_reply_with_results_ = synchronously_reply_with_results; |
| 29 } |
| 30 |
| 26 void SetTetherHosts(const std::vector<cryptauth::RemoteDevice> tether_hosts); | 31 void SetTetherHosts(const std::vector<cryptauth::RemoteDevice> tether_hosts); |
| 27 | 32 |
| 28 // If |sychronously_reply_with_results| is false, calling this method will | 33 // If |synchronously_reply_with_results_| is false, calling this method will |
| 29 // actually invoke the callbacks. | 34 // actually invoke the callbacks. |
| 30 void InvokePendingCallbacks(); | 35 void InvokePendingCallbacks(); |
| 31 | 36 |
| 32 // TetherHostFetcher: | 37 // TetherHostFetcher: |
| 33 void FetchAllTetherHosts( | 38 void FetchAllTetherHosts( |
| 34 const TetherHostFetcher::TetherHostListCallback& callback) override; | 39 const TetherHostFetcher::TetherHostListCallback& callback) override; |
| 35 void FetchTetherHost( | 40 void FetchTetherHost( |
| 36 const std::string& device_id, | 41 const std::string& device_id, |
| 37 const TetherHostFetcher::TetherHostCallback& callback) override; | 42 const TetherHostFetcher::TetherHostCallback& callback) override; |
| 38 | 43 |
| 39 private: | 44 private: |
| 40 std::vector<cryptauth::RemoteDevice> tether_hosts_; | 45 std::vector<cryptauth::RemoteDevice> tether_hosts_; |
| 41 bool synchronously_reply_with_results_; | 46 bool synchronously_reply_with_results_; |
| 42 | 47 |
| 43 DISALLOW_COPY_AND_ASSIGN(FakeTetherHostFetcher); | 48 DISALLOW_COPY_AND_ASSIGN(FakeTetherHostFetcher); |
| 44 }; | 49 }; |
| 45 | 50 |
| 46 } // namespace tether | 51 } // namespace tether |
| 47 | 52 |
| 48 } // namespace chromeos | 53 } // namespace chromeos |
| 49 | 54 |
| 50 #endif // CHROMEOS_COMPONENTS_TETHER_FAKE_TETHER_HOST_FETCHER_H_ | 55 #endif // CHROMEOS_COMPONENTS_TETHER_FAKE_TETHER_HOST_FETCHER_H_ |
| OLD | NEW |