Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: webkit/chromeos/fileapi/cros_mount_point_provider.h

Issue 11648027: Extract external file systems handling from isolated context. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/content_tests.gypi ('k') | webkit/chromeos/fileapi/cros_mount_point_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ 5 #ifndef WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_
6 #define WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ 6 #define WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "webkit/fileapi/file_system_mount_point_provider.h" 16 #include "webkit/fileapi/file_system_mount_point_provider.h"
17 #include "webkit/quota/special_storage_policy.h" 17 #include "webkit/quota/special_storage_policy.h"
18 #include "webkit/storage/webkit_storage_export.h" 18 #include "webkit/storage/webkit_storage_export.h"
19 19
20 namespace fileapi { 20 namespace fileapi {
21 class ExternalMountPoints;
21 class FileSystemFileUtil; 22 class FileSystemFileUtil;
22 class FileSystemURL; 23 class FileSystemURL;
23 class IsolatedContext; 24 class IsolatedContext;
24 class LocalFileUtil; 25 class LocalFileUtil;
25 } 26 }
26 27
27 namespace chromeos { 28 namespace chromeos {
28 29
29 class FileAccessPermissions; 30 class FileAccessPermissions;
30 31
31 // An interface to provide local filesystem paths. 32 // An interface to provide local filesystem paths.
32 class WEBKIT_STORAGE_EXPORT CrosMountPointProvider 33 class WEBKIT_STORAGE_EXPORT CrosMountPointProvider
33 : public fileapi::ExternalFileSystemMountPointProvider { 34 : public fileapi::ExternalFileSystemMountPointProvider {
34 public: 35 public:
35 using fileapi::FileSystemMountPointProvider::ValidateFileSystemCallback; 36 using fileapi::FileSystemMountPointProvider::ValidateFileSystemCallback;
36 using fileapi::FileSystemMountPointProvider::DeleteFileSystemCallback; 37 using fileapi::FileSystemMountPointProvider::DeleteFileSystemCallback;
37 38
39 // CrosMountPointProvider will take an ownership of a |mount_points|
40 // reference. On the other hand, |system_mount_points| will be kept as a raw
41 // pointer and it should outlive CrosMountPointProvider instance.
38 CrosMountPointProvider( 42 CrosMountPointProvider(
39 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); 43 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
44 scoped_refptr<fileapi::ExternalMountPoints> mount_points,
45 fileapi::ExternalMountPoints* system_mount_points);
40 virtual ~CrosMountPointProvider(); 46 virtual ~CrosMountPointProvider();
41 47
42 // Returns true if CrosMountpointProvider can handle |url|, i.e. its 48 // Returns true if CrosMountpointProvider can handle |url|, i.e. its
43 // file system type matches with what this provider supports. 49 // file system type matches with what this provider supports.
44 // This could be called on any threads. 50 // This could be called on any threads.
45 static bool CanHandleURL(const fileapi::FileSystemURL& url); 51 static bool CanHandleURL(const fileapi::FileSystemURL& url);
46 52
47 // fileapi::FileSystemMountPointProvider overrides. 53 // fileapi::FileSystemMountPointProvider overrides.
48 virtual void ValidateFileSystemRoot( 54 virtual void ValidateFileSystemRoot(
49 const GURL& origin_url, 55 const GURL& origin_url,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 const DeleteFileSystemCallback& callback) OVERRIDE; 87 const DeleteFileSystemCallback& callback) OVERRIDE;
82 88
83 // fileapi::ExternalFileSystemMountPointProvider overrides. 89 // fileapi::ExternalFileSystemMountPointProvider overrides.
84 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE; 90 virtual std::vector<FilePath> GetRootDirectories() const OVERRIDE;
85 virtual void GrantFullAccessToExtension( 91 virtual void GrantFullAccessToExtension(
86 const std::string& extension_id) OVERRIDE; 92 const std::string& extension_id) OVERRIDE;
87 virtual void GrantFileAccessToExtension( 93 virtual void GrantFileAccessToExtension(
88 const std::string& extension_id, const FilePath& virtual_path) OVERRIDE; 94 const std::string& extension_id, const FilePath& virtual_path) OVERRIDE;
89 virtual void RevokeAccessForExtension( 95 virtual void RevokeAccessForExtension(
90 const std::string& extension_id) OVERRIDE; 96 const std::string& extension_id) OVERRIDE;
91 virtual bool HasMountPoint(const FilePath& mount_point) OVERRIDE; 97 // Note: This will ignore |system_mount_points_|. The reasoning behind this is
92 virtual void AddLocalMountPoint(const FilePath& mount_point) OVERRIDE; 98 // the method should be used paired with Add/RemoveMountPoint methods, which
93 virtual void AddRestrictedLocalMountPoint( 99 // don't affect |system_mount_points_|.
100 virtual bool HasMountPoint(const FilePath& mount_point) const OVERRIDE;
101 virtual bool AddLocalMountPoint(const FilePath& mount_point) OVERRIDE;
102 virtual bool AddRestrictedLocalMountPoint(
94 const FilePath& mount_point) OVERRIDE; 103 const FilePath& mount_point) OVERRIDE;
95 virtual void AddRemoteMountPoint( 104 virtual bool AddRemoteMountPoint(
96 const FilePath& mount_point, 105 const FilePath& mount_point,
97 fileapi::RemoteFileSystemProxyInterface* remote_proxy) OVERRIDE; 106 fileapi::RemoteFileSystemProxyInterface* remote_proxy) OVERRIDE;
98 virtual void RemoveMountPoint(const FilePath& mount_point) OVERRIDE; 107 virtual void RemoveMountPoint(const FilePath& mount_point) OVERRIDE;
99 virtual bool GetVirtualPath(const FilePath& filesystem_path, 108 virtual bool GetVirtualPath(const FilePath& filesystem_path,
100 FilePath* virtual_path) OVERRIDE; 109 FilePath* virtual_path) OVERRIDE;
101 110
102 private: 111 private:
103 typedef scoped_refptr<fileapi::RemoteFileSystemProxyInterface> RemoteProxy; 112 fileapi::RemoteFileSystemProxyInterface* GetRemoteProxy(
104 typedef std::map<FilePath::StringType, RemoteProxy> RemoteProxyMap; 113 const std::string& mount_name) const;
105
106 fileapi::IsolatedContext* isolated_context() const;
107
108 // Represents a map from mount point name to a remote proxy.
109 RemoteProxyMap remote_proxy_map_;
110
111 // Reverse map for GetVirtualPath.
112 std::map<FilePath, FilePath> local_to_virtual_map_;
113
114 mutable base::Lock mount_point_map_lock_;
115 114
116 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; 115 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
117 scoped_ptr<FileAccessPermissions> file_access_permissions_; 116 scoped_ptr<FileAccessPermissions> file_access_permissions_;
118 scoped_ptr<fileapi::LocalFileUtil> local_file_util_; 117 scoped_ptr<fileapi::LocalFileUtil> local_file_util_;
118
119 // Mount points specific to the owning context.
120 //
121 // Add/Remove MountPoints will affect only these mount points.
122 //
123 // It is legal to have mount points with the same name as in
124 // system_mount_points_. Also, mount point paths may overlap with mount point
125 // paths in system_mount_points_. In both cases mount points in
126 // |mount_points_| will have a priority.
127 // E.g. if |mount_points_| map 'foo1' to '/foo/foo1' and
128 // |file_system_mount_points_| map 'xxx' to '/foo/foo1/xxx', |GetVirtualPaths|
129 // will resolve '/foo/foo1/xxx/yyy' as 'foo1/xxx/yyy' (i.e. the mapping from
130 // |mount_points_| will be used).
131 scoped_refptr<fileapi::ExternalMountPoints> mount_points_;
132
133 // Globally visible mount points. System MountPonts instance should outlive
134 // all CrosMountPointProvider instances, so raw pointer is safe.
135 fileapi::ExternalMountPoints* system_mount_points_;
136
119 DISALLOW_COPY_AND_ASSIGN(CrosMountPointProvider); 137 DISALLOW_COPY_AND_ASSIGN(CrosMountPointProvider);
120 }; 138 };
121 139
122 } // namespace chromeos 140 } // namespace chromeos
123 141
124 #endif // WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ 142 #endif // WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | webkit/chromeos/fileapi/cros_mount_point_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698