OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_DATABASE_DATABASE_TRACKER_H_ | 5 #ifndef WEBKIT_DATABASE_DATABASE_TRACKER_H_ |
6 #define WEBKIT_DATABASE_DATABASE_TRACKER_H_ | 6 #define WEBKIT_DATABASE_DATABASE_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 bool IsIncognitoProfile() const { return is_incognito_; } | 158 bool IsIncognitoProfile() const { return is_incognito_; } |
159 | 159 |
160 void GetIncognitoFileHandle(const string16& vfs_file_path, | 160 void GetIncognitoFileHandle(const string16& vfs_file_path, |
161 base::PlatformFile* file_handle) const; | 161 base::PlatformFile* file_handle) const; |
162 void SaveIncognitoFileHandle(const string16& vfs_file_path, | 162 void SaveIncognitoFileHandle(const string16& vfs_file_path, |
163 const base::PlatformFile& file_handle); | 163 const base::PlatformFile& file_handle); |
164 bool CloseIncognitoFileHandle(const string16& vfs_file_path); | 164 bool CloseIncognitoFileHandle(const string16& vfs_file_path); |
165 bool HasSavedIncognitoFileHandle(const string16& vfs_file_path) const; | 165 bool HasSavedIncognitoFileHandle(const string16& vfs_file_path) const; |
166 | 166 |
167 // Shutdown the database tracker, deleting database files if the tracker is | 167 // Shutdown the database tracker, deleting database files if the tracker is |
168 // used for an incognito profile or |clear_local_state_on_exit_| is true. | 168 // used for an incognito profile. |
169 void Shutdown(); | 169 void Shutdown(); |
170 void SetClearLocalStateOnExit(bool clear_local_state_on_exit); | 170 // Disables the exit-time deletion of session-only data. |
171 // Disables the exit-time deletion for all data (also session-only data). | 171 void SetForceKeepSessionState(); |
172 void SaveSessionState(); | |
173 | 172 |
174 private: | 173 private: |
175 friend class base::RefCountedThreadSafe<DatabaseTracker>; | 174 friend class base::RefCountedThreadSafe<DatabaseTracker>; |
176 friend class MockDatabaseTracker; // for testing | 175 friend class MockDatabaseTracker; // for testing |
177 | 176 |
178 typedef std::map<string16, std::set<string16> > DatabaseSet; | 177 typedef std::map<string16, std::set<string16> > DatabaseSet; |
179 typedef std::vector<std::pair<net::CompletionCallback, DatabaseSet> > | 178 typedef std::vector<std::pair<net::CompletionCallback, DatabaseSet> > |
180 PendingDeletionCallbacks; | 179 PendingDeletionCallbacks; |
181 typedef std::map<string16, base::PlatformFile> FileHandlesMap; | 180 typedef std::map<string16, base::PlatformFile> FileHandlesMap; |
182 typedef std::map<string16, string16> OriginDirectoriesMap; | 181 typedef std::map<string16, string16> OriginDirectoriesMap; |
(...skipping 15 matching lines...) Expand all Loading... |
198 database_info_[database_name].second = description; | 197 database_info_[database_name].second = description; |
199 } | 198 } |
200 }; | 199 }; |
201 | 200 |
202 // virtual for unit-testing only. | 201 // virtual for unit-testing only. |
203 virtual ~DatabaseTracker(); | 202 virtual ~DatabaseTracker(); |
204 | 203 |
205 // Deletes the directory that stores all DBs in incognito mode, if it exists. | 204 // Deletes the directory that stores all DBs in incognito mode, if it exists. |
206 void DeleteIncognitoDBDirectory(); | 205 void DeleteIncognitoDBDirectory(); |
207 | 206 |
208 // If clear_all_databases is true, deletes all databases not protected by | 207 // Deletes session-only databases. Blocks databases from being created/opened. |
209 // special storage policy. Otherwise deletes session-only databases. Blocks | 208 void ClearSessionOnlyOrigins(); |
210 // databases from being created/opened. | |
211 void ClearLocalState(bool clear_all_databases); | |
212 | 209 |
213 bool DeleteClosedDatabase(const string16& origin_identifier, | 210 bool DeleteClosedDatabase(const string16& origin_identifier, |
214 const string16& database_name); | 211 const string16& database_name); |
215 | 212 |
216 // Delete all files belonging to the given origin given that no database | 213 // Delete all files belonging to the given origin given that no database |
217 // connections within this origin are open, or if |force| is true, delete | 214 // connections within this origin are open, or if |force| is true, delete |
218 // the meta data and rename the associated directory. | 215 // the meta data and rename the associated directory. |
219 bool DeleteOrigin(const string16& origin_identifier, bool force); | 216 bool DeleteOrigin(const string16& origin_identifier, bool force); |
220 void DeleteDatabaseIfNeeded(const string16& origin_identifier, | 217 void DeleteDatabaseIfNeeded(const string16& origin_identifier, |
221 const string16& database_name); | 218 const string16& database_name); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // Schedule a set of open databases for deletion. If non-null, callback is | 251 // Schedule a set of open databases for deletion. If non-null, callback is |
255 // invoked upon completion. | 252 // invoked upon completion. |
256 void ScheduleDatabasesForDeletion(const DatabaseSet& databases, | 253 void ScheduleDatabasesForDeletion(const DatabaseSet& databases, |
257 const net::CompletionCallback& callback); | 254 const net::CompletionCallback& callback); |
258 | 255 |
259 // Returns the directory where all DB files for the given origin are stored. | 256 // Returns the directory where all DB files for the given origin are stored. |
260 string16 GetOriginDirectory(const string16& origin_identifier); | 257 string16 GetOriginDirectory(const string16& origin_identifier); |
261 | 258 |
262 bool is_initialized_; | 259 bool is_initialized_; |
263 const bool is_incognito_; | 260 const bool is_incognito_; |
264 bool clear_local_state_on_exit_; | 261 bool force_keep_session_state_; |
265 bool save_session_state_; | |
266 bool shutting_down_; | 262 bool shutting_down_; |
267 const FilePath profile_path_; | 263 const FilePath profile_path_; |
268 const FilePath db_dir_; | 264 const FilePath db_dir_; |
269 scoped_ptr<sql::Connection> db_; | 265 scoped_ptr<sql::Connection> db_; |
270 scoped_ptr<DatabasesTable> databases_table_; | 266 scoped_ptr<DatabasesTable> databases_table_; |
271 scoped_ptr<sql::MetaTable> meta_table_; | 267 scoped_ptr<sql::MetaTable> meta_table_; |
272 ObserverList<Observer, true> observers_; | 268 ObserverList<Observer, true> observers_; |
273 std::map<string16, CachedOriginInfo> origins_info_map_; | 269 std::map<string16, CachedOriginInfo> origins_info_map_; |
274 DatabaseConnections database_connections_; | 270 DatabaseConnections database_connections_; |
275 | 271 |
(...skipping 22 matching lines...) Expand all Loading... |
298 // this map to assign directory names that do not reveal this information. | 294 // this map to assign directory names that do not reveal this information. |
299 OriginDirectoriesMap incognito_origin_directories_; | 295 OriginDirectoriesMap incognito_origin_directories_; |
300 int incognito_origin_directories_generator_; | 296 int incognito_origin_directories_generator_; |
301 | 297 |
302 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); | 298 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); |
303 }; | 299 }; |
304 | 300 |
305 } // namespace webkit_database | 301 } // namespace webkit_database |
306 | 302 |
307 #endif // WEBKIT_DATABASE_DATABASE_TRACKER_H_ | 303 #endif // WEBKIT_DATABASE_DATABASE_TRACKER_H_ |
OLD | NEW |