OLD | NEW |
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_FILEAPI_ISOLATED_CONTEXT_H_ | 5 #ifndef WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_ |
6 #define WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_ | 6 #define WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // |virtual_path| has no <relative_path> part (i.e. pointing to | 70 // |virtual_path| has no <relative_path> part (i.e. pointing to |
71 // the virtual root). | 71 // the virtual root). |
72 bool CrackIsolatedPath(const FilePath& virtual_path, | 72 bool CrackIsolatedPath(const FilePath& virtual_path, |
73 std::string* filesystem_id, | 73 std::string* filesystem_id, |
74 FilePath* root_path, | 74 FilePath* root_path, |
75 FilePath* platform_path) const; | 75 FilePath* platform_path) const; |
76 | 76 |
77 // Returns a vector of the full paths of the top-level entry paths | 77 // Returns a vector of the full paths of the top-level entry paths |
78 // registered for the |filesystem_id|. Returns false if the | 78 // registered for the |filesystem_id|. Returns false if the |
79 // |filesystem_is| is not valid. | 79 // |filesystem_is| is not valid. |
80 bool GetTopLevelPaths(std::string filesystem_id, | 80 bool GetTopLevelPaths(const std::string& filesystem_id, |
81 std::vector<FilePath>* paths) const; | 81 std::vector<FilePath>* paths) const; |
82 | 82 |
83 // Returns the virtual path that looks like /<filesystem_id>/<relative_path>. | 83 // Returns the virtual path that looks like /<filesystem_id>/<relative_path>. |
84 FilePath CreateVirtualPath(const std::string& filesystem_id, | 84 FilePath CreateVirtualPath(const std::string& filesystem_id, |
85 const FilePath& relative_path) const; | 85 const FilePath& relative_path) const; |
86 | 86 |
| 87 // Set the filesystem writable if |writable| is true, non-writable |
| 88 // if it is false. Returns false if the |filesystem_id| is not valid. |
| 89 bool SetWritable(const std::string& filesystem_id, bool writable); |
| 90 |
| 91 // Returns true if the |filesystem_id| is writable. |
| 92 bool IsWritable(const std::string& filesystem_id) const; |
| 93 |
87 private: | 94 private: |
88 friend struct base::DefaultLazyInstanceTraits<IsolatedContext>; | 95 friend struct base::DefaultLazyInstanceTraits<IsolatedContext>; |
89 | 96 |
90 // Maps from filesystem id to a path conversion map for top-level entries. | 97 // Maps from filesystem id to a path conversion map for top-level entries. |
91 typedef std::map<FilePath, FilePath> PathMap; | 98 typedef std::map<FilePath, FilePath> PathMap; |
92 typedef std::map<std::string, PathMap> IDToPathMap; | 99 typedef std::map<std::string, PathMap> IDToPathMap; |
93 | 100 |
94 // Obtain an instance of this class via GetInstance(). | 101 // Obtain an instance of this class via GetInstance(). |
95 IsolatedContext(); | 102 IsolatedContext(); |
96 ~IsolatedContext(); | 103 ~IsolatedContext(); |
97 | 104 |
98 // Returns a new filesystem_id. Called with lock. | 105 // Returns a new filesystem_id. Called with lock. |
99 std::string GetNewFileSystemId() const; | 106 std::string GetNewFileSystemId() const; |
100 | 107 |
101 // This lock needs to be obtained when accessing the toplevel_map_. | 108 // This lock needs to be obtained when accessing the toplevel_map_. |
102 mutable base::Lock lock_; | 109 mutable base::Lock lock_; |
103 | 110 |
104 // Maps the toplevel entries to the filesystem id. | 111 // Maps the toplevel entries to the filesystem id. |
105 IDToPathMap toplevel_map_; | 112 IDToPathMap toplevel_map_; |
106 | 113 |
| 114 // Holds a set of writable ids. |
| 115 // Isolated file systems are created read-only by default, and this set |
| 116 // holds a list of exceptions. |
| 117 // Detailed filesystem permission may be provided by an external |
| 118 // security policy manager, e.g. ChildProcessSecurityPolicy. |
| 119 std::set<std::string> writable_ids_; |
| 120 |
107 DISALLOW_COPY_AND_ASSIGN(IsolatedContext); | 121 DISALLOW_COPY_AND_ASSIGN(IsolatedContext); |
108 }; | 122 }; |
109 | 123 |
110 } // namespace fileapi | 124 } // namespace fileapi |
111 | 125 |
112 #endif // WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_ | 126 #endif // WEBKIT_FILEAPI_ISOLATED_CONTEXT_H_ |
OLD | NEW |