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

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: remove too strict DCHECK 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/fileapi/fileapi_export.h"
17 #include "webkit/quota/special_storage_policy.h" 18 #include "webkit/quota/special_storage_policy.h"
18 19
19 namespace fileapi { 20 namespace fileapi {
20 class FileSystemFileUtil; 21 class FileSystemFileUtil;
22 class IsolatedContext;
23 class LocalFileUtil;
21 } 24 }
22 25
23 namespace chromeos { 26 namespace chromeos {
24 27
25 class FileAccessPermissions; 28 class FileAccessPermissions;
26 29
27 // An interface to provide local filesystem paths. 30 // An interface to provide local filesystem paths.
28 class CrosMountPointProvider 31 class FILEAPI_EXPORT CrosMountPointProvider
29 : public fileapi::ExternalFileSystemMountPointProvider { 32 : public fileapi::ExternalFileSystemMountPointProvider {
30 public: 33 public:
31 using fileapi::FileSystemMountPointProvider::ValidateFileSystemCallback; 34 using fileapi::FileSystemMountPointProvider::ValidateFileSystemCallback;
32 using fileapi::FileSystemMountPointProvider::DeleteFileSystemCallback; 35 using fileapi::FileSystemMountPointProvider::DeleteFileSystemCallback;
33 36
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( 37 CrosMountPointProvider(
43 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy); 38 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy);
44 virtual ~CrosMountPointProvider(); 39 virtual ~CrosMountPointProvider();
45 40
41 // Returns true if CrosMountpointProvider can handle |url|, i.e. its
42 // file system type matches with what this provider supports.
43 // This could be called on any threads.
44 static bool CanHandleURL(const fileapi::FileSystemURL& url);
45
46 // fileapi::FileSystemMountPointProvider overrides. 46 // fileapi::FileSystemMountPointProvider overrides.
47 virtual void ValidateFileSystemRoot( 47 virtual void ValidateFileSystemRoot(
48 const GURL& origin_url, 48 const GURL& origin_url,
49 fileapi::FileSystemType type, 49 fileapi::FileSystemType type,
50 bool create, 50 bool create,
51 const ValidateFileSystemCallback& callback) OVERRIDE; 51 const ValidateFileSystemCallback& callback) OVERRIDE;
52 virtual FilePath GetFileSystemRootPathOnFileThread( 52 virtual FilePath GetFileSystemRootPathOnFileThread(
53 const GURL& origin_url, 53 const GURL& origin_url,
54 fileapi::FileSystemType type, 54 fileapi::FileSystemType type,
55 const FilePath& virtual_path, 55 const FilePath& virtual_path,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 virtual bool HasMountPoint(const FilePath& mount_point) OVERRIDE; 92 virtual bool HasMountPoint(const FilePath& mount_point) OVERRIDE;
93 virtual void AddLocalMountPoint(const FilePath& mount_point) OVERRIDE; 93 virtual void AddLocalMountPoint(const FilePath& mount_point) OVERRIDE;
94 virtual void AddRemoteMountPoint( 94 virtual void AddRemoteMountPoint(
95 const FilePath& mount_point, 95 const FilePath& mount_point,
96 fileapi::RemoteFileSystemProxyInterface* remote_proxy) OVERRIDE; 96 fileapi::RemoteFileSystemProxyInterface* remote_proxy) OVERRIDE;
97 virtual void RemoveMountPoint(const FilePath& mount_point) OVERRIDE; 97 virtual void RemoveMountPoint(const FilePath& mount_point) OVERRIDE;
98 virtual bool GetVirtualPath(const FilePath& filesystem_path, 98 virtual bool GetVirtualPath(const FilePath& filesystem_path,
99 FilePath* virtual_path) OVERRIDE; 99 FilePath* virtual_path) OVERRIDE;
100 100
101 private: 101 private:
102 // Representation of a mount point exposed by this external mount point 102 typedef scoped_refptr<fileapi::RemoteFileSystemProxyInterface> RemoteProxy;
103 // provider. 103 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 104
124 typedef std::map<std::string, MountPoint> MountPointMap; 105 fileapi::IsolatedContext* isolated_context() const;
125 106
126 // Gives the real file system's |root_path| for given |virtual_path|. Returns 107 // Represents a map from mount point name to a remote proxy.
127 // false when |virtual_path| cannot be mapped to the real file system. 108 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 109
133 base::Lock mount_point_map_lock_; 110 // Reverse map for GetVirtualPath.
134 MountPointMap mount_point_map_; 111 std::map<FilePath, FilePath> local_to_virtual_map_;
112
113 mutable base::Lock mount_point_map_lock_;
114
135 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; 115 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_;
136 scoped_ptr<FileAccessPermissions> file_access_permissions_; 116 scoped_ptr<FileAccessPermissions> file_access_permissions_;
137 scoped_ptr<fileapi::LocalFileUtil> local_file_util_; 117 scoped_ptr<fileapi::LocalFileUtil> local_file_util_;
138 DISALLOW_COPY_AND_ASSIGN(CrosMountPointProvider); 118 DISALLOW_COPY_AND_ASSIGN(CrosMountPointProvider);
139 }; 119 };
140 120
141 } // namespace chromeos 121 } // namespace chromeos
142 122
143 #endif // WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_ 123 #endif // WEBKIT_CHROMEOS_FILEAPI_CROS_MOUNT_POINT_PROVIDER_H_
OLDNEW
« no previous file with comments | « content/browser/fileapi/fileapi_message_filter.cc ('k') | webkit/chromeos/fileapi/cros_mount_point_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698