sandbox_file_system_backend.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright (c) 2012 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 STORAGE_BROWSER_FILE_SYSTEM_SANDBOX_FILE_SYSTEM_BACKEND_H_
  5. #define STORAGE_BROWSER_FILE_SYSTEM_SANDBOX_FILE_SYSTEM_BACKEND_H_
  6. #include <stdint.h>
  7. #include <memory>
  8. #include <set>
  9. #include <string>
  10. #include "base/compiler_specific.h"
  11. #include "base/component_export.h"
  12. #include "base/memory/raw_ptr.h"
  13. #include "base/memory/ref_counted.h"
  14. #include "storage/browser/file_system/file_system_backend.h"
  15. #include "storage/browser/file_system/file_system_quota_util.h"
  16. #include "storage/browser/file_system/sandbox_file_system_backend_delegate.h"
  17. #include "storage/browser/file_system/task_runner_bound_observer_list.h"
  18. #include "storage/browser/quota/special_storage_policy.h"
  19. namespace storage {
  20. // TEMPORARY or PERSISTENT filesystems, which are placed under the user's
  21. // profile directory in a sandboxed way.
  22. // This interface also lets one enumerate and remove storage for the origins
  23. // that use the filesystem.
  24. class COMPONENT_EXPORT(STORAGE_BROWSER) SandboxFileSystemBackend
  25. : public FileSystemBackend {
  26. public:
  27. explicit SandboxFileSystemBackend(SandboxFileSystemBackendDelegate* delegate);
  28. SandboxFileSystemBackend(const SandboxFileSystemBackend&) = delete;
  29. SandboxFileSystemBackend& operator=(const SandboxFileSystemBackend&) = delete;
  30. ~SandboxFileSystemBackend() override;
  31. // FileSystemBackend overrides.
  32. bool CanHandleType(FileSystemType type) const override;
  33. void Initialize(FileSystemContext* context) override;
  34. void ResolveURL(const FileSystemURL& url,
  35. OpenFileSystemMode mode,
  36. ResolveURLCallback callback) override;
  37. AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) override;
  38. WatcherManager* GetWatcherManager(FileSystemType type) override;
  39. CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
  40. FileSystemType type,
  41. base::File::Error* error_code) override;
  42. std::unique_ptr<FileSystemOperation> CreateFileSystemOperation(
  43. const FileSystemURL& url,
  44. FileSystemContext* context,
  45. base::File::Error* error_code) const override;
  46. bool SupportsStreaming(const FileSystemURL& url) const override;
  47. bool HasInplaceCopyImplementation(FileSystemType type) const override;
  48. std::unique_ptr<FileStreamReader> CreateFileStreamReader(
  49. const FileSystemURL& url,
  50. int64_t offset,
  51. int64_t max_bytes_to_read,
  52. const base::Time& expected_modification_time,
  53. FileSystemContext* context) const override;
  54. std::unique_ptr<FileStreamWriter> CreateFileStreamWriter(
  55. const FileSystemURL& url,
  56. int64_t offset,
  57. FileSystemContext* context) const override;
  58. FileSystemQuotaUtil* GetQuotaUtil() override;
  59. const UpdateObserverList* GetUpdateObservers(
  60. FileSystemType type) const override;
  61. const ChangeObserverList* GetChangeObservers(
  62. FileSystemType type) const override;
  63. const AccessObserverList* GetAccessObservers(
  64. FileSystemType type) const override;
  65. // Returns a StorageKey enumerator of this backend.
  66. // This method can only be called on the file thread.
  67. SandboxFileSystemBackendDelegate::StorageKeyEnumerator*
  68. CreateStorageKeyEnumerator();
  69. private:
  70. raw_ptr<SandboxFileSystemBackendDelegate> delegate_; // Not owned.
  71. };
  72. } // namespace storage
  73. #endif // STORAGE_BROWSER_FILE_SYSTEM_SANDBOX_FILE_SYSTEM_BACKEND_H_