blob: c3bde3ea1556201627f46912f10fc91883212399 [file] [log] [blame]
[email protected]e7e46732012-01-05 11:45:551// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]073a04f2011-03-24 00:49:402// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]f19bbf62013-07-09 01:22:325#ifndef WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_
6#define WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_
[email protected]073a04f2011-03-24 00:49:407
[email protected]5caeb202011-05-17 07:42:078#include <set>
[email protected]073a04f2011-03-24 00:49:409#include <string>
[email protected]073a04f2011-03-24 00:49:4010
[email protected]b7d38af72012-05-23 02:51:0911#include "base/compiler_specific.h"
[email protected]57999812013-02-24 05:40:5212#include "base/files/file_path.h"
[email protected]b7d38af72012-05-23 02:51:0913#include "base/memory/ref_counted.h"
[email protected]3cfc10f2012-05-24 01:20:4114#include "base/memory/scoped_ptr.h"
[email protected]f19bbf62013-07-09 01:22:3215#include "webkit/browser/fileapi/file_system_backend.h"
[email protected]20c2df62013-05-21 08:26:3616#include "webkit/browser/fileapi/file_system_quota_util.h"
[email protected]639772f2013-08-15 05:55:3717#include "webkit/browser/fileapi/sandbox_file_system_backend_delegate.h"
[email protected]f25e1132013-05-24 13:58:0418#include "webkit/browser/fileapi/task_runner_bound_observer_list.h"
[email protected]7660ec92013-05-30 05:12:3919#include "webkit/browser/quota/special_storage_policy.h"
[email protected]e5bf2fd2013-06-13 02:59:1820#include "webkit/browser/webkit_storage_browser_export.h"
[email protected]073a04f2011-03-24 00:49:4021
[email protected]073a04f2011-03-24 00:49:4022namespace fileapi {
23
[email protected]4f9b1432011-12-20 11:10:1624// An interface to construct or crack sandboxed filesystem paths for
25// TEMPORARY or PERSISTENT filesystems, which are placed under the user's
26// profile directory in a sandboxed way.
27// This interface also lets one enumerate and remove storage for the origins
28// that use the filesystem.
[email protected]f19bbf62013-07-09 01:22:3229class WEBKIT_STORAGE_BROWSER_EXPORT SandboxFileSystemBackend
[email protected]18141c322013-08-22 10:33:0430 : public FileSystemBackend {
[email protected]073a04f2011-03-24 00:49:4031 public:
[email protected]639772f2013-08-15 05:55:3732 explicit SandboxFileSystemBackend(SandboxFileSystemBackendDelegate* delegate);
[email protected]f19bbf62013-07-09 01:22:3233 virtual ~SandboxFileSystemBackend();
[email protected]3c48b532011-12-20 12:42:4434
[email protected]f19bbf62013-07-09 01:22:3235 // FileSystemBackend overrides.
[email protected]420fb562013-04-18 01:46:3436 virtual bool CanHandleType(FileSystemType type) const OVERRIDE;
[email protected]3fc17aed2013-07-24 10:01:5037 virtual void Initialize(FileSystemContext* context) OVERRIDE;
38 virtual void OpenFileSystem(
[email protected]60f60f82012-01-11 10:26:1039 const GURL& origin_url,
40 FileSystemType type,
[email protected]22dea52c2013-05-29 07:44:4041 OpenFileSystemMode mode,
[email protected]3fc17aed2013-07-24 10:01:5042 const OpenFileSystemCallback& callback) OVERRIDE;
[email protected]25b697992013-01-29 07:10:0543 virtual AsyncFileUtil* GetAsyncFileUtil(FileSystemType type) OVERRIDE;
[email protected]98407ee2013-04-04 08:52:1744 virtual CopyOrMoveFileValidatorFactory* GetCopyOrMoveFileValidatorFactory(
45 FileSystemType type,
[email protected]141bcc52014-01-27 21:36:0046 base::File::Error* error_code) OVERRIDE;
[email protected]8e3bc3e2012-08-24 13:12:5347 virtual FileSystemOperation* CreateFileSystemOperation(
[email protected]949f25a2012-06-27 01:53:0948 const FileSystemURL& url,
[email protected]d23a00cc2012-09-11 17:38:1349 FileSystemContext* context,
[email protected]141bcc52014-01-27 21:36:0050 base::File::Error* error_code) const OVERRIDE;
[email protected]3ee9eb02013-04-10 09:17:0551 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader(
[email protected]949f25a2012-06-27 01:53:0952 const FileSystemURL& url,
53 int64 offset,
[email protected]a1057832012-10-15 13:28:0654 const base::Time& expected_modification_time,
[email protected]949f25a2012-06-27 01:53:0955 FileSystemContext* context) const OVERRIDE;
[email protected]3ee9eb02013-04-10 09:17:0556 virtual scoped_ptr<FileStreamWriter> CreateFileStreamWriter(
[email protected]949f25a2012-06-27 01:53:0957 const FileSystemURL& url,
58 int64 offset,
59 FileSystemContext* context) const OVERRIDE;
[email protected]6faad822012-05-11 12:58:2960 virtual FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE;
[email protected]3c48b532011-12-20 12:42:4461
[email protected]f19bbf62013-07-09 01:22:3262 // Returns an origin enumerator of this backend.
[email protected]054702d2011-05-28 01:12:1863 // This method can only be called on the file thread.
[email protected]639772f2013-08-15 05:55:3764 SandboxFileSystemBackendDelegate::OriginEnumerator* CreateOriginEnumerator();
[email protected]073a04f2011-03-24 00:49:4065
[email protected]9cf2d7c72013-04-24 13:54:1366 void set_enable_temporary_file_system_in_incognito(bool enable) {
67 enable_temporary_file_system_in_incognito_ = enable;
68 }
[email protected]190dbb5c2013-09-06 10:19:2469 bool enable_temporary_file_system_in_incognito() const {
70 return enable_temporary_file_system_in_incognito_;
71 }
72
[email protected]9cf2d7c72013-04-24 13:54:1373
[email protected]073a04f2011-03-24 00:49:4074 private:
[email protected]639772f2013-08-15 05:55:3775 SandboxFileSystemBackendDelegate* delegate_; // Not owned.
[email protected]073a04f2011-03-24 00:49:4076
[email protected]9cf2d7c72013-04-24 13:54:1377 bool enable_temporary_file_system_in_incognito_;
[email protected]e7e46732012-01-05 11:45:5578
[email protected]f19bbf62013-07-09 01:22:3279 DISALLOW_COPY_AND_ASSIGN(SandboxFileSystemBackend);
[email protected]073a04f2011-03-24 00:49:4080};
81
82} // namespace fileapi
83
[email protected]f19bbf62013-07-09 01:22:3284#endif // WEBKIT_BROWSER_FILEAPI_SANDBOX_FILE_SYSTEM_BACKEND_H_