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

Side by Side Diff: webkit/fileapi/external_mount_points.h

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « webkit/fileapi/cross_operation_delegate.cc ('k') | webkit/fileapi/external_mount_points.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ 5 #ifndef WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_H_
6 #define WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ 6 #define WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_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/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "webkit/fileapi/file_system_types.h" 14 #include "webkit/fileapi/file_system_types.h"
15 #include "webkit/fileapi/mount_points.h" 15 #include "webkit/fileapi/mount_points.h"
16 #include "webkit/storage/webkit_storage_export.h" 16 #include "webkit/storage/webkit_storage_export.h"
17 17
18 namespace base {
18 class FilePath; 19 class FilePath;
20 }
19 21
20 namespace fileapi { 22 namespace fileapi {
21 class FileSystemURL; 23 class FileSystemURL;
22 class RemoteFileSystemProxyInterface; 24 class RemoteFileSystemProxyInterface;
23 } 25 }
24 26
25 namespace fileapi { 27 namespace fileapi {
26 28
27 // Manages external filesystem namespaces that are identified by 'mount name' 29 // Manages external filesystem namespaces that are identified by 'mount name'
28 // and are persisted until RevokeFileSystem is called. 30 // and are persisted until RevokeFileSystem is called.
(...skipping 24 matching lines...) Expand all
53 // Adding mount point whose path overlaps with an existing mount point will 55 // Adding mount point whose path overlaps with an existing mount point will
54 // fail. 56 // fail.
55 // 57 //
56 // If not empty, |path| must be absolute. It is allowed for the path to be 58 // If not empty, |path| must be absolute. It is allowed for the path to be
57 // empty, but |GetVirtualPath| will not work for those mount points. 59 // empty, but |GetVirtualPath| will not work for those mount points.
58 // 60 //
59 // An external file system registered by this method can be revoked 61 // An external file system registered by this method can be revoked
60 // by calling RevokeFileSystem with |mount_name|. 62 // by calling RevokeFileSystem with |mount_name|.
61 bool RegisterFileSystem(const std::string& mount_name, 63 bool RegisterFileSystem(const std::string& mount_name,
62 FileSystemType type, 64 FileSystemType type,
63 const FilePath& path); 65 const base::FilePath& path);
64 66
65 // Same as |RegisterExternalFileSystem|, but also registers a remote file 67 // Same as |RegisterExternalFileSystem|, but also registers a remote file
66 // system proxy for the file system. 68 // system proxy for the file system.
67 bool RegisterRemoteFileSystem(const std::string& mount_name, 69 bool RegisterRemoteFileSystem(const std::string& mount_name,
68 FileSystemType type, 70 FileSystemType type,
69 RemoteFileSystemProxyInterface* remote_proxy, 71 RemoteFileSystemProxyInterface* remote_proxy,
70 const FilePath& path); 72 const base::FilePath& path);
71 73
72 // MountPoints overrides. 74 // MountPoints overrides.
73 virtual bool HandlesFileSystemMountType(FileSystemType type) const OVERRIDE; 75 virtual bool HandlesFileSystemMountType(FileSystemType type) const OVERRIDE;
74 virtual bool RevokeFileSystem(const std::string& mount_name) OVERRIDE; 76 virtual bool RevokeFileSystem(const std::string& mount_name) OVERRIDE;
75 virtual bool GetRegisteredPath(const std::string& mount_name, 77 virtual bool GetRegisteredPath(const std::string& mount_name,
76 FilePath* path) const OVERRIDE; 78 base::FilePath* path) const OVERRIDE;
77 virtual bool CrackVirtualPath(const FilePath& virtual_path, 79 virtual bool CrackVirtualPath(const base::FilePath& virtual_path,
78 std::string* mount_name, 80 std::string* mount_name,
79 FileSystemType* type, 81 FileSystemType* type,
80 FilePath* path) const OVERRIDE; 82 base::FilePath* path) const OVERRIDE;
81 virtual FileSystemURL CrackURL(const GURL& url) const OVERRIDE; 83 virtual FileSystemURL CrackURL(const GURL& url) const OVERRIDE;
82 virtual FileSystemURL CreateCrackedFileSystemURL( 84 virtual FileSystemURL CreateCrackedFileSystemURL(
83 const GURL& origin, 85 const GURL& origin,
84 FileSystemType type, 86 FileSystemType type,
85 const FilePath& path) const OVERRIDE; 87 const base::FilePath& path) const OVERRIDE;
86 88
87 // Retrieves the remote file system proxy for the registered file system. 89 // Retrieves the remote file system proxy for the registered file system.
88 // Returns NULL if there is no file system with the given name, or if the file 90 // Returns NULL if there is no file system with the given name, or if the file
89 // system does not have a remote file system proxy. 91 // system does not have a remote file system proxy.
90 RemoteFileSystemProxyInterface* GetRemoteFileSystemProxy( 92 RemoteFileSystemProxyInterface* GetRemoteFileSystemProxy(
91 const std::string& mount_name) const; 93 const std::string& mount_name) const;
92 94
93 // Returns a list of registered MountPointInfos (of <mount_name, path>). 95 // Returns a list of registered MountPointInfos (of <mount_name, path>).
94 void AddMountPointInfosTo(std::vector<MountPointInfo>* mount_points) const; 96 void AddMountPointInfosTo(std::vector<MountPointInfo>* mount_points) const;
95 97
96 // Converts a path on a registered file system to virtual path relative to the 98 // Converts a path on a registered file system to virtual path relative to the
97 // file system root. E.g. if 'Downloads' file system is mapped to 99 // file system root. E.g. if 'Downloads' file system is mapped to
98 // '/usr/local/home/Downloads', and |absolute| path is set to 100 // '/usr/local/home/Downloads', and |absolute| path is set to
99 // '/usr/local/home/Downloads/foo', the method will set |virtual_path| to 101 // '/usr/local/home/Downloads/foo', the method will set |virtual_path| to
100 // 'Downloads/foo'. 102 // 'Downloads/foo'.
101 // Returns false if the path cannot be resolved (e.g. if the path is not 103 // Returns false if the path cannot be resolved (e.g. if the path is not
102 // part of any registered filesystem). 104 // part of any registered filesystem).
103 // 105 //
104 // Returned virtual_path will have normalized path separators. 106 // Returned virtual_path will have normalized path separators.
105 bool GetVirtualPath(const FilePath& absolute_path, FilePath* virtual_path); 107 bool GetVirtualPath(const base::FilePath& absolute_path,
108 base::FilePath* virtual_path);
106 109
107 // Returns the virtual root path that looks like /<mount_name>. 110 // Returns the virtual root path that looks like /<mount_name>.
108 FilePath CreateVirtualRootPath(const std::string& mount_name) const; 111 base::FilePath CreateVirtualRootPath(const std::string& mount_name) const;
109 112
110 private: 113 private:
111 friend class base::RefCountedThreadSafe<ExternalMountPoints>; 114 friend class base::RefCountedThreadSafe<ExternalMountPoints>;
112 115
113 // Represents each file system instance (defined in the .cc). 116 // Represents each file system instance (defined in the .cc).
114 class Instance; 117 class Instance;
115 118
116 typedef std::map<std::string, Instance*> NameToInstance; 119 typedef std::map<std::string, Instance*> NameToInstance;
117 120
118 // Reverse map from registered path to its corresponding mount name. 121 // Reverse map from registered path to its corresponding mount name.
119 typedef std::map<FilePath, std::string> PathToName; 122 typedef std::map<base::FilePath, std::string> PathToName;
120 123
121 // Use |GetSystemInstance| of |CreateRefCounted| to get an instance. 124 // Use |GetSystemInstance| of |CreateRefCounted| to get an instance.
122 ExternalMountPoints(); 125 ExternalMountPoints();
123 virtual ~ExternalMountPoints(); 126 virtual ~ExternalMountPoints();
124 127
125 // Performs sanity checks on the new mount point. 128 // Performs sanity checks on the new mount point.
126 // Checks the following: 129 // Checks the following:
127 // - there is no registered mount point with mount_name 130 // - there is no registered mount point with mount_name
128 // - path does not contain a reference to a parent 131 // - path does not contain a reference to a parent
129 // - path is absolute 132 // - path is absolute
130 // - path does not overlap with an existing mount point path. 133 // - path does not overlap with an existing mount point path.
131 // 134 //
132 // |lock_| should be taken before calling this method. 135 // |lock_| should be taken before calling this method.
133 bool ValidateNewMountPoint(const std::string& mount_name, 136 bool ValidateNewMountPoint(const std::string& mount_name,
134 const FilePath& path); 137 const base::FilePath& path);
135 138
136 // This lock needs to be obtained when accessing the instance_map_. 139 // This lock needs to be obtained when accessing the instance_map_.
137 mutable base::Lock lock_; 140 mutable base::Lock lock_;
138 141
139 NameToInstance instance_map_; 142 NameToInstance instance_map_;
140 PathToName path_to_name_map_; 143 PathToName path_to_name_map_;
141 144
142 DISALLOW_COPY_AND_ASSIGN(ExternalMountPoints); 145 DISALLOW_COPY_AND_ASSIGN(ExternalMountPoints);
143 }; 146 };
144 147
145 // Registers a scoped external filesystem which gets revoked when it scopes out. 148 // Registers a scoped external filesystem which gets revoked when it scopes out.
146 class WEBKIT_STORAGE_EXPORT ScopedExternalFileSystem { 149 class WEBKIT_STORAGE_EXPORT ScopedExternalFileSystem {
147 public: 150 public:
148 ScopedExternalFileSystem(const std::string& mount_name, 151 ScopedExternalFileSystem(const std::string& mount_name,
149 FileSystemType type, 152 FileSystemType type,
150 const FilePath& path); 153 const base::FilePath& path);
151 ~ScopedExternalFileSystem(); 154 ~ScopedExternalFileSystem();
152 155
153 FilePath GetVirtualRootPath() const; 156 base::FilePath GetVirtualRootPath() const;
154 157
155 private: 158 private:
156 const std::string mount_name_; 159 const std::string mount_name_;
157 }; 160 };
158 161
159 } // namespace fileapi 162 } // namespace fileapi
160 163
161 #endif // WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_H_ 164 #endif // WEBKIT_FILEAPI_EXTERNAL_MOUNT_POINTS_H_
162 165
OLDNEW
« no previous file with comments | « webkit/fileapi/cross_operation_delegate.cc ('k') | webkit/fileapi/external_mount_points.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698