filesystem_proxy_factory.cc 976 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2020 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. #include "components/services/storage/filesystem_proxy_factory.h"
  5. #include <utility>
  6. #include "base/bind.h"
  7. #include "base/no_destructor.h"
  8. namespace storage {
  9. namespace {
  10. std::unique_ptr<FilesystemProxy> CreateUnrestrictedFilesystemProxy() {
  11. return std::make_unique<FilesystemProxy>(FilesystemProxy::UNRESTRICTED,
  12. base::FilePath());
  13. }
  14. FilesystemProxyFactory& GetFactory() {
  15. static base::NoDestructor<FilesystemProxyFactory> factory{
  16. base::BindRepeating(&CreateUnrestrictedFilesystemProxy)};
  17. return *factory;
  18. }
  19. } // namespace
  20. void SetFilesystemProxyFactory(FilesystemProxyFactory factory) {
  21. GetFactory() = std::move(factory);
  22. }
  23. std::unique_ptr<FilesystemProxy> CreateFilesystemProxy() {
  24. return GetFactory().Run();
  25. }
  26. } // namespace storage