drivefs_http_client.h 1.3 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_COMPONENTS_DRIVEFS_DRIVEFS_HTTP_CLIENT_H_
  5. #define ASH_COMPONENTS_DRIVEFS_DRIVEFS_HTTP_CLIENT_H_
  6. #include "ash/components/drivefs/mojom/drivefs.mojom.h"
  7. #include "base/component_export.h"
  8. #include "mojo/public/cpp/bindings/unique_receiver_set.h"
  9. #include "services/network/public/cpp/shared_url_loader_factory.h"
  10. namespace drivefs {
  11. // Handles HTTP requests for DriveFS by translating them to a URLLoader
  12. // request and passing the responses back to DriveFS.
  13. class COMPONENT_EXPORT(DRIVEFS) DriveFsHttpClient {
  14. public:
  15. explicit DriveFsHttpClient(
  16. scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
  17. DriveFsHttpClient(const DriveFsHttpClient&) = delete;
  18. DriveFsHttpClient& operator=(const DriveFsHttpClient&) = delete;
  19. ~DriveFsHttpClient();
  20. void ExecuteHttpRequest(mojom::HttpRequestPtr request,
  21. mojo::PendingRemote<mojom::HttpDelegate> delegate);
  22. private:
  23. mojo::UniqueReceiverSet<network::mojom::URLLoaderClient> clients_;
  24. scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
  25. };
  26. } // namespace drivefs
  27. #endif // ASH_COMPONENTS_DRIVEFS_DRIVEFS_HTTP_CLIENT_H_