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

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

Issue 10823273: Integrate external mount points to IsolatedContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cros test fix Created 8 years, 4 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
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/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
15 #include "webkit/fileapi/file_system_mount_point_provider.h" 16 #include "webkit/fileapi/file_system_mount_point_provider.h"
16 #include "webkit/fileapi/local_file_util.h"
17 #include "webkit/quota/special_storage_policy.h" 17 #include "webkit/quota/special_storage_policy.h"
18 18
19 namespace fileapi { 19 namespace fileapi {
20 class FileSystemFileUtil; 20 class FileSystemFileUtil;
21 class IsolatedContext;
22 class LocalFileUtil;
21 } 23 }
22 24
23 namespace chromeos { 25 namespace chromeos {
24 26
25 class FileAccessPermissions; 27 class FileAccessPermissions;
26 28
27 // An interface to provide local filesystem paths. 29 // An interface to provide local filesystem paths.
28 class CrosMountPointProvider 30 class CrosMountPointProvider
29 : public fileapi::ExternalFileSystemMountPointProvider { 31 : public fileapi::ExternalFileSystemMountPointProvider {
30 public: 32 public:
31 using fileapi::FileSystemMountPointProvider::ValidateFileSystemCallback; 33 using fileapi::FileSystemMountPointProvider::ValidateFileSystemCallback;
32 using fileapi::FileSystemMountPointProvider::DeleteFileSystemCallback; 34 using fileapi::FileSystemMountPointProvider::DeleteFileSystemCallback;
33 35
34 // Mount point file system location enum.
35 enum FileSystemLocation {
36 // File system that is locally mounted by the underlying OS.
37 LOCAL,
38 // File system that is remotely hosted on the net.
39 REMOTE,
40 };
41
42 CrosMountPointProvider( 36 CrosMountPointProvider(
43 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); 37 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy);
44 virtual ~CrosMountPointProvider(); 38 virtual ~CrosMountPointProvider();
45 39
46 // fileapi::FileSystemMountPointProvider overrides. 40 // fileapi::FileSystemMountPointProvider overrides.
47 virtual void ValidateFileSystemRoot( 41 virtual void ValidateFileSystemRoot(
48 const GURL& origin_url, 42 const GURL& origin_url,
49 fileapi::FileSystemType type, 43 fileapi::FileSystemType type,
50 bool create, 44 bool create,
51 const ValidateFileSystemCallback& callback) OVERRIDE; 45 const ValidateFileSystemCallback& callback) OVERRIDE;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 virtual bool HasMountPoint(const FilePath& mount_point) OVERRIDE; 86 virtual bool HasMountPoint(const FilePath& mount_point) OVERRIDE;
93 virtual void AddLocalMountPoint(const FilePath& mount_point) OVERRIDE; 87 virtual void AddLocalMountPoint(const FilePath& mount_point) OVERRIDE;
94 virtual void AddRemoteMountPoint( 88 virtual void AddRemoteMountPoint(
95 const FilePath& mount_point, 89 const FilePath& mount_point,
96 fileapi::RemoteFileSystemProxyInterface* remote_proxy) OVERRIDE; 90 fileapi::RemoteFileSystemProxyInterface* remote_proxy) OVERRIDE;
97 virtual void RemoveMountPoint(const FilePath& mount_point) OVERRIDE; 91 virtual void RemoveMountPoint(const FilePath& mount_point) OVERRIDE;
98 virtual bool GetVirtualPath(const FilePath& filesystem_path, 92 virtual bool GetVirtualPath(const FilePath& filesystem_path,
99 FilePath* virtual_path) OVERRIDE; 93 FilePath* virtual_path) OVERRIDE;
100 94
101 private: 95 private:
102 // Representation of a mount point exposed by this external mount point 96 typedef scoped_refptr<fileapi::RemoteFileSystemProxyInterface> RemoteProxy;
103 // provider. 97 typedef std::map<FilePath::StringType, RemoteProxy> RemoteProxyMap;
104 struct MountPoint {
105 MountPoint(const FilePath& web_path,
106 const FilePath& local_path,
107 FileSystemLocation loc,
108 fileapi::RemoteFileSystemProxyInterface* proxy);
109 virtual ~MountPoint();
110 // Virtual web path, relative to external root in filesystem URLs.
111 // For example, in "filesystem://.../external/foo/bar/" this path would
112 // map to "foo/bar/".
113 const FilePath web_root_path;
114 // Parent directory for the exposed file system path. For example,
115 // mount point that exposes "/media/removable" would have this
116 // root path as "/media".
117 const FilePath local_root_path;
118 // File system location.
119 const FileSystemLocation location;
120 // Remote file system proxy for remote mount points.
121 scoped_refptr<fileapi::RemoteFileSystemProxyInterface> remote_proxy;
122 };
123 98
124 typedef std::map<std::string, MountPoint> MountPointMap; 99 fileapi::IsolatedContext* isolated_context() const;
125 100
126 // Gives the real file system's |root_path| for given |virtual_path|. Returns 101 // Represents a map from mount point name to a remote proxy.
127 // false when |virtual_path| cannot be mapped to the real file system. 102 RemoteProxyMap remote_proxy_map_;
128 bool GetRootForVirtualPath(const FilePath& virtual_path, FilePath* root_path);
129 // Returns mount point info for a given |virtual_path|, NULL if the path is
130 // not part of the mounted file systems exposed through this provider.
131 const MountPoint* GetMountPoint(const FilePath& virtual_path) const;
132 103
133 base::Lock mount_point_map_lock_; 104 // Reverse map for GetVirtualPath.
134 MountPointMap mount_point_map_; 105 std::map<FilePath, FilePath> local_to_virtual_map_;
106
107 mutable base::Lock mount_point_map_lock_;
108
135 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; 109 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
136 scoped_ptr<FileAccessPermissions> file_access_permissions_; 110 scoped_ptr<FileAccessPermissions> file_access_permissions_;
137 scoped_ptr<fileapi::LocalFileUtil> local_file_util_; 111 scoped_ptr<fileapi::LocalFileUtil> local_file_util_;
138 DISALLOW_COPY_AND_ASSIGN(CrosMountPointProvider); 112 DISALLOW_COPY_AND_ASSIGN(CrosMountPointProvider);
139 }; 113 };
140 114
141 } // namespace chromeos 115 } // namespace chromeos
142 116
143 #endif // WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ 117 #endif // WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698