Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(114)

Delta Between Two Patch Sets: gears/base/common/permissions_db.h

Issue 800: Database2Versions table, get/set version operations implemented (Closed) SVN Base: http://google-gears.googlecode.com/svn/contrib/dimitri.glazkov/database2/
Left Patch Set: renamed table to Database2Metadata Created 4 months, 2 weeks ago
Right Patch Set: Created 4 months, 3 weeks ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 // Copyright 2007, Google Inc. 1 // Copyright 2007, Google Inc.
2 // 2 //
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met: 4 // modification, are permitted provided that the following conditions are met:
5 // 5 //
6 // 1. Redistributions of source code must retain the above copyright notice, 6 // 1. Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer. 7 // this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright notice, 8 // 2. Redistributions in binary form must reproduce the above copyright notice,
9 // this list of conditions and the following disclaimer in the documentation 9 // this list of conditions and the following disclaimer in the documentation
10 // and/or other materials provided with the distribution. 10 // and/or other materials provided with the distribution.
(...skipping 10 matching lines...) Show
21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 25
26 #ifndef GEARS_BASE_COMMON_PERMISSIONS_DB_H__ 26 #ifndef GEARS_BASE_COMMON_PERMISSIONS_DB_H__
27 #define GEARS_BASE_COMMON_PERMISSIONS_DB_H__ 27 #define GEARS_BASE_COMMON_PERMISSIONS_DB_H__
28 28
29 #include <map> 29 #include <map>
30 #include "gears/base/common/database_name_table.h" 30 #include "gears/base/common/database_name_table.h"
31 #include "gears/base/common/database2_metadata.h" 31 #include "gears/base/common/database2_versions_table.h"
32 #include "gears/base/common/name_value_table.h" 32 #include "gears/base/common/name_value_table.h"
33 #include "gears/base/common/security_model.h" 33 #include "gears/base/common/security_model.h"
34 #include "gears/base/common/shortcut_table.h" 34 #include "gears/base/common/shortcut_table.h"
35 #include "gears/base/common/sqlite_wrapper.h" 35 #include "gears/base/common/sqlite_wrapper.h"
36 36
37 // TODO(cprince): Consider merging this with PermissionsDB::PermissionValue. 37 // TODO(cprince): Consider merging this with PermissionsDB::PermissionValue.
38 // But note the _TEMPORARY values hae no meaning to PermissionsDB. 38 // But note the _TEMPORARY values hae no meaning to PermissionsDB.
39 enum PermissionState { 39 enum PermissionState {
40 NOT_SET, 40 NOT_SET,
41 ALLOWED_PERMANENTLY, 41 ALLOWED_PERMANENTLY,
(...skipping 94 matching lines...) Show 10 above Show 10 below
136 std::string16 *basename); 136 std::string16 *basename);
137 137
138 // Mark the given database basename corrupt so that future calls to 138 // Mark the given database basename corrupt so that future calls to
139 // GetDatabaseBasename will no longer return it. The basename is 139 // GetDatabaseBasename will no longer return it. The basename is
140 // required because another thread of control could have already 140 // required because another thread of control could have already
141 // invalidated the database for the origin. 141 // invalidated the database for the origin.
142 bool MarkDatabaseCorrupt(const SecurityOrigin &origin, 142 bool MarkDatabaseCorrupt(const SecurityOrigin &origin,
143 const char16 *database_name, 143 const char16 *database_name,
144 const char16 *basename); 144 const char16 *basename);
145 145
146 // Get the metadata table for Database2 API. The metadata table stores 146 // Database2 API: get current database version for a given database at the
147 // version information 147 // specified origin
148 Database2Metadata &GetDatabase2Metadata(); 148 bool GetDatabase2Version(const SecurityOrigin &origin,
149 const std::string16 &name,
150 std::string16 *version,
151 bool *found);
152
153 // Database2 API: set or create a version for a given database at the
154 // specified origin
155 bool SetDatabase2Version(const SecurityOrigin &origin,
156 const std::string16 &name,
157 const std::string16 &version);
149 158
150 private: 159 private:
151 // Private constructor, callers must use GetDB(). 160 // Private constructor, callers must use GetDB().
152 PermissionsDB(); 161 PermissionsDB();
153 162
154 // Initializes the database. Must be called before other methods. 163 // Initializes the database. Must be called before other methods.
155 bool Init(); 164 bool Init();
156 165
157 // Creates or upgrades the database to kCurrentVersion. 166 // Creates or upgrades the database to kCurrentVersion.
158 bool CreateOrUpgradeDatabase(); 167 bool CreateOrUpgradeDatabase();
159 168
160 // Creates the database's schema. 169 // Creates the database's schema.
161 bool CreateDatabase(); 170 bool CreateDatabase();
162 171
163 // Schema upgrade functions. Higher-numbered functions call 172 // Schema upgrade functions. Higher-numbered functions call
164 // lower-numbered functions as appropriate. 173 // lower-numbered functions as appropriate.
165 bool UpgradeToVersion8();
166 bool UpgradeToVersion7(); 174 bool UpgradeToVersion7();
167 bool UpgradeToVersion6(); 175 bool UpgradeToVersion6();
168 bool UpgradeToVersion5(); 176 bool UpgradeToVersion5();
169 bool UpgradeToVersion4(); 177 bool UpgradeToVersion4();
170 bool UpgradeToVersion3(); 178 bool UpgradeToVersion3();
171 bool UpgradeToVersion2(); 179 bool UpgradeToVersion2();
172 180
173 // Destructor function called by ThreadLocals to dispose of a thread-specific 181 // Destructor function called by ThreadLocals to dispose of a thread-specific
174 // DB instance when a thread dies. 182 // DB instance when a thread dies.
175 static void DestroyDB(void *context); 183 static void DestroyDB(void *context);
176 184
177 // Database we use to store capabilities information. 185 // Database we use to store capabilities information.
178 SQLDatabase db_; 186 SQLDatabase db_;
179 187
180 // Version metadata for the capabilities database. 188 // Version metadata for the capabilities database.
181 NameValueTable version_table_; 189 NameValueTable version_table_;
182 190
183 // Maps origins to ability to access Gears. 191 // Maps origins to ability to access Gears.
184 NameValueTable access_table_; 192 NameValueTable access_table_;
185 193
186 // Shortcuts origins have defined. 194 // Shortcuts origins have defined.
187 ShortcutTable shortcut_table_; 195 ShortcutTable shortcut_table_;
188 196
189 DatabaseNameTable database_name_table_; 197 DatabaseNameTable database_name_table_;
190 198
191 // database2 metadata 199 // database2 metadata
192 Database2Metadata database2_metadata_table_; 200 Database2VersionsTable database2_versions_table_;
193 201
194 DISALLOW_EVIL_CONSTRUCTORS(PermissionsDB); 202 DISALLOW_EVIL_CONSTRUCTORS(PermissionsDB);
195 DECL_SINGLE_THREAD 203 DECL_SINGLE_THREAD
196 }; 204 };
197 205
198 #endif // GEARS_BASE_COMMON_PERMISSIONS_DB_H__ 206 #endif // GEARS_BASE_COMMON_PERMISSIONS_DB_H__
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r338