fake_device_metadata_http_fetcher.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2022 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. #ifndef ASH_QUICK_PAIR_REPOSITORY_FAKE_DEVICE_METADATA_HTTP_FETCHER_H_
  5. #define ASH_QUICK_PAIR_REPOSITORY_FAKE_DEVICE_METADATA_HTTP_FETCHER_H_
  6. #include "ash/quick_pair/repository/http_fetcher.h"
  7. namespace ash {
  8. namespace quick_pair {
  9. class FakeDeviceMetadataHttpFetcher : public HttpFetcher {
  10. public:
  11. FakeDeviceMetadataHttpFetcher();
  12. FakeDeviceMetadataHttpFetcher(const FakeDeviceMetadataHttpFetcher&) = delete;
  13. FakeDeviceMetadataHttpFetcher& operator=(
  14. const FakeDeviceMetadataHttpFetcher&) = delete;
  15. ~FakeDeviceMetadataHttpFetcher() override;
  16. // Performs a GET request to the desired URL and returns the response, if
  17. // available, as a string to the provided |callback|.
  18. void ExecuteGetRequest(const GURL& url,
  19. FetchCompleteCallback callback) override;
  20. int num_gets() { return num_gets_; }
  21. void set_network_error(bool error) { has_network_error_ = error; }
  22. private:
  23. int num_gets_ = 0;
  24. bool has_network_error_ = false;
  25. };
  26. } // namespace quick_pair
  27. } // namespace ash
  28. #endif // ASH_QUICK_PAIR_REPOSITORY_FAKE_DEVICE_METADATA_HTTP_FETCHER_H_