Add signalSyncPoint to the WebGraphicsContext3D command buffer impls.
[chromium-blink-merge.git] / webkit / chromeos / fileapi / cros_mount_point_provider.h
blob698825aabb49a0d79445c6564c497184eb87622c
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.
5 #ifndef WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_
6 #define WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/synchronization/lock.h"
16 #include "webkit/fileapi/file_system_mount_point_provider.h"
17 #include "webkit/fileapi/file_system_types.h"
18 #include "webkit/quota/special_storage_policy.h"
19 #include "webkit/storage/webkit_storage_export.h"
21 namespace fileapi {
22 class AsyncFileUtilAdapter;
23 class CopyOrMoveFileValidatorFactory;
24 class ExternalMountPoints;
25 class FileSystemFileUtil;
26 class FileSystemURL;
27 class IsolatedContext;
30 namespace chromeos {
32 class FileAccessPermissions;
34 // An interface to provide local filesystem paths.
35 class WEBKIT_STORAGE_EXPORT CrosMountPointProvider
36 : public fileapi::ExternalFileSystemMountPointProvider {
37 public:
38 using fileapi::FileSystemMountPointProvider::ValidateFileSystemCallback;
39 using fileapi::FileSystemMountPointProvider::DeleteFileSystemCallback;
41 // CrosMountPointProvider will take an ownership of a |mount_points|
42 // reference. On the other hand, |system_mount_points| will be kept as a raw
43 // pointer and it should outlive CrosMountPointProvider instance.
44 CrosMountPointProvider(
45 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
46 scoped_refptr<fileapi::ExternalMountPoints> mount_points,
47 fileapi::ExternalMountPoints* system_mount_points);
48 virtual ~CrosMountPointProvider();
50 // Returns true if CrosMountpointProvider can handle |url|, i.e. its
51 // file system type matches with what this provider supports.
52 // This could be called on any threads.
53 static bool CanHandleURL(const fileapi::FileSystemURL& url);
55 // fileapi::FileSystemMountPointProvider overrides.
56 virtual bool CanHandleType(fileapi::FileSystemType type) const OVERRIDE;
57 virtual void ValidateFileSystemRoot(
58 const GURL& origin_url,
59 fileapi::FileSystemType type,
60 bool create,
61 const ValidateFileSystemCallback& callback) OVERRIDE;
62 virtual base::FilePath GetFileSystemRootPathOnFileThread(
63 const fileapi::FileSystemURL& url,
64 bool create) OVERRIDE;
65 virtual fileapi::FileSystemFileUtil* GetFileUtil(
66 fileapi::FileSystemType type) OVERRIDE;
67 virtual fileapi::AsyncFileUtil* GetAsyncFileUtil(
68 fileapi::FileSystemType type) OVERRIDE;
69 virtual fileapi::CopyOrMoveFileValidatorFactory*
70 GetCopyOrMoveFileValidatorFactory(
71 fileapi::FileSystemType type,
72 base::PlatformFileError* error_code) OVERRIDE;
73 virtual void InitializeCopyOrMoveFileValidatorFactory(
74 fileapi::FileSystemType type,
75 scoped_ptr<fileapi::CopyOrMoveFileValidatorFactory> factory) OVERRIDE;
76 virtual fileapi::FilePermissionPolicy GetPermissionPolicy(
77 const fileapi::FileSystemURL& url,
78 int permissions) const OVERRIDE;
79 virtual fileapi::FileSystemOperation* CreateFileSystemOperation(
80 const fileapi::FileSystemURL& url,
81 fileapi::FileSystemContext* context,
82 base::PlatformFileError* error_code) const OVERRIDE;
83 virtual scoped_ptr<webkit_blob::FileStreamReader> CreateFileStreamReader(
84 const fileapi::FileSystemURL& path,
85 int64 offset,
86 const base::Time& expected_modification_time,
87 fileapi::FileSystemContext* context) const OVERRIDE;
88 virtual scoped_ptr<fileapi::FileStreamWriter> CreateFileStreamWriter(
89 const fileapi::FileSystemURL& url,
90 int64 offset,
91 fileapi::FileSystemContext* context) const OVERRIDE;
92 virtual fileapi::FileSystemQuotaUtil* GetQuotaUtil() OVERRIDE;
93 virtual void DeleteFileSystem(
94 const GURL& origin_url,
95 fileapi::FileSystemType type,
96 fileapi::FileSystemContext* context,
97 const DeleteFileSystemCallback& callback) OVERRIDE;
99 // fileapi::ExternalFileSystemMountPointProvider overrides.
100 virtual bool IsAccessAllowed(const fileapi::FileSystemURL& url)
101 const OVERRIDE;
102 virtual std::vector<base::FilePath> GetRootDirectories() const OVERRIDE;
103 virtual void GrantFullAccessToExtension(
104 const std::string& extension_id) OVERRIDE;
105 virtual void GrantFileAccessToExtension(
106 const std::string& extension_id,
107 const base::FilePath& virtual_path) OVERRIDE;
108 virtual void RevokeAccessForExtension(
109 const std::string& extension_id) OVERRIDE;
110 virtual bool GetVirtualPath(const base::FilePath& filesystem_path,
111 base::FilePath* virtual_path) OVERRIDE;
113 private:
114 fileapi::RemoteFileSystemProxyInterface* GetRemoteProxy(
115 const std::string& mount_name) const;
117 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
118 scoped_ptr<FileAccessPermissions> file_access_permissions_;
119 scoped_ptr<fileapi::AsyncFileUtilAdapter> local_file_util_;
121 // Mount points specific to the owning context.
123 // Add/Remove MountPoints will affect only these mount points.
125 // It is legal to have mount points with the same name as in
126 // system_mount_points_. Also, mount point paths may overlap with mount point
127 // paths in system_mount_points_. In both cases mount points in
128 // |mount_points_| will have a priority.
129 // E.g. if |mount_points_| map 'foo1' to '/foo/foo1' and
130 // |file_system_mount_points_| map 'xxx' to '/foo/foo1/xxx', |GetVirtualPaths|
131 // will resolve '/foo/foo1/xxx/yyy' as 'foo1/xxx/yyy' (i.e. the mapping from
132 // |mount_points_| will be used).
133 scoped_refptr<fileapi::ExternalMountPoints> mount_points_;
135 // Globally visible mount points. System MountPonts instance should outlive
136 // all CrosMountPointProvider instances, so raw pointer is safe.
137 fileapi::ExternalMountPoints* system_mount_points_;
139 DISALLOW_COPY_AND_ASSIGN(CrosMountPointProvider);
142 } // namespace chromeos
144 #endif // WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_