mojo_backend_file_operations_factory.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 SERVICES_NETWORK_DISK_CACHE_MOJO_BACKEND_FILE_OPERATIONS_FACTORY_H_
  5. #define SERVICES_NETWORK_DISK_CACHE_MOJO_BACKEND_FILE_OPERATIONS_FACTORY_H_
  6. #include <memory>
  7. #include "base/component_export.h"
  8. #include "base/memory/ref_counted.h"
  9. #include "mojo/public/cpp/bindings/pending_remote.h"
  10. #include "mojo/public/cpp/bindings/remote.h"
  11. #include "net/disk_cache/disk_cache.h"
  12. #include "services/network/public/mojom/http_cache_backend_file_operations.mojom.h"
  13. namespace base {
  14. class SequencedTaskRunner;
  15. } // namespace base
  16. namespace network {
  17. // A BackendFileOperationsFactory implementation that creates
  18. // MojoBackendFileOperations on Create.
  19. class COMPONENT_EXPORT(NETWORK_SERVICE) MojoBackendFileOperationsFactory final
  20. : public disk_cache::BackendFileOperationsFactory {
  21. public:
  22. explicit MojoBackendFileOperationsFactory(
  23. mojo::PendingRemote<mojom::HttpCacheBackendFileOperationsFactory>
  24. pending_remote);
  25. // BackendFileOperationsFactory implementation:
  26. std::unique_ptr<disk_cache::BackendFileOperations> Create(
  27. scoped_refptr<base::SequencedTaskRunner> task_runner) override;
  28. std::unique_ptr<disk_cache::UnboundBackendFileOperations> CreateUnbound()
  29. override;
  30. private:
  31. ~MojoBackendFileOperationsFactory() override;
  32. mojo::Remote<mojom::HttpCacheBackendFileOperationsFactory> remote_;
  33. };
  34. } // namespace network
  35. #endif // SERVICES_NETWORK_DISK_CACHE_MOJO_BACKEND_FILE_OPERATIONS_FACTORY_H_