content_directory_loader_factory.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2019 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 FUCHSIA_WEB_WEBENGINE_BROWSER_CONTENT_DIRECTORY_LOADER_FACTORY_H_
  5. #define FUCHSIA_WEB_WEBENGINE_BROWSER_CONTENT_DIRECTORY_LOADER_FACTORY_H_
  6. #include <fuchsia/io/cpp/fidl.h>
  7. #include <fuchsia/web/cpp/fidl.h>
  8. #include <lib/fidl/cpp/interface_handle.h>
  9. #include "fuchsia_web/webengine/web_engine_export.h"
  10. #include "mojo/public/cpp/bindings/pending_receiver.h"
  11. #include "mojo/public/cpp/bindings/pending_remote.h"
  12. #include "mojo/public/cpp/bindings/receiver_set.h"
  13. #include "services/network/public/cpp/self_deleting_url_loader_factory.h"
  14. #include "services/network/public/mojom/url_loader_factory.mojom.h"
  15. // URLLoaderFactory which services requests for resources stored under named
  16. // directories. The directories are accessed using the fuchsia-dir:// scheme.
  17. class ContentDirectoryLoaderFactory
  18. : public network::SelfDeletingURLLoaderFactory {
  19. public:
  20. // Path in the browser process' namespace at which content directories
  21. // should be mounted.
  22. static WEB_ENGINE_EXPORT const char kContentDirectoriesPath[];
  23. // Returns mojo::PendingRemote to a newly constructed
  24. // ContentDirectoryLoaderFactory. The factory is self-owned - it will delete
  25. // itself once there are no more receivers (including the receiver associated
  26. // with the returned mojo::PendingRemote and the receivers bound by the Clone
  27. // method).
  28. static mojo::PendingRemote<network::mojom::URLLoaderFactory> Create();
  29. ContentDirectoryLoaderFactory(const ContentDirectoryLoaderFactory&) = delete;
  30. ContentDirectoryLoaderFactory& operator=(
  31. const ContentDirectoryLoaderFactory&) = delete;
  32. private:
  33. explicit ContentDirectoryLoaderFactory(
  34. mojo::PendingReceiver<network::mojom::URLLoaderFactory> factory_receiver);
  35. ~ContentDirectoryLoaderFactory() override;
  36. // network::mojom::URLLoaderFactory:
  37. void CreateLoaderAndStart(
  38. mojo::PendingReceiver<network::mojom::URLLoader> loader,
  39. int32_t request_id,
  40. uint32_t options,
  41. const network::ResourceRequest& request,
  42. mojo::PendingRemote<network::mojom::URLLoaderClient> client,
  43. const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) final;
  44. // Used for executing blocking URLLoader routines.
  45. const scoped_refptr<base::SequencedTaskRunner> task_runner_;
  46. };
  47. #endif // FUCHSIA_WEB_WEBENGINE_BROWSER_CONTENT_DIRECTORY_LOADER_FACTORY_H_