| 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_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 20 matching lines...) Expand all Loading... |
| 31 class MetaTable; | 31 class MetaTable; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace quota { | 34 namespace quota { |
| 35 class QuotaManagerProxy; | 35 class QuotaManagerProxy; |
| 36 class SpecialStoragePolicy; | 36 class SpecialStoragePolicy; |
| 37 } | 37 } |
| 38 | 38 |
| 39 namespace webkit_database { | 39 namespace webkit_database { |
| 40 | 40 |
| 41 WEBKIT_STORAGE_EXPORT extern const FilePath::CharType kDatabaseDirectoryName[]; | 41 WEBKIT_STORAGE_EXPORT extern const base::FilePath::CharType |
| 42 WEBKIT_STORAGE_EXPORT extern const FilePath::CharType | 42 kDatabaseDirectoryName[]; |
| 43 WEBKIT_STORAGE_EXPORT extern const base::FilePath::CharType |
| 43 kTrackerDatabaseFileName[]; | 44 kTrackerDatabaseFileName[]; |
| 44 | 45 |
| 45 class DatabasesTable; | 46 class DatabasesTable; |
| 46 | 47 |
| 47 // This class is used to store information about all databases in an origin. | 48 // This class is used to store information about all databases in an origin. |
| 48 class WEBKIT_STORAGE_EXPORT OriginInfo { | 49 class WEBKIT_STORAGE_EXPORT OriginInfo { |
| 49 public: | 50 public: |
| 50 OriginInfo(); | 51 OriginInfo(); |
| 51 OriginInfo(const OriginInfo& origin_info); | 52 OriginInfo(const OriginInfo& origin_info); |
| 52 ~OriginInfo(); | 53 ~OriginInfo(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 const string16& database_name, | 87 const string16& database_name, |
| 87 int64 database_size) = 0; | 88 int64 database_size) = 0; |
| 88 virtual void OnDatabaseScheduledForDeletion( | 89 virtual void OnDatabaseScheduledForDeletion( |
| 89 const string16& origin_identifier, | 90 const string16& origin_identifier, |
| 90 const string16& database_name) = 0; | 91 const string16& database_name) = 0; |
| 91 | 92 |
| 92 protected: | 93 protected: |
| 93 virtual ~Observer() {} | 94 virtual ~Observer() {} |
| 94 }; | 95 }; |
| 95 | 96 |
| 96 DatabaseTracker(const FilePath& profile_path, | 97 DatabaseTracker(const base::FilePath& profile_path, |
| 97 bool is_incognito, | 98 bool is_incognito, |
| 98 quota::SpecialStoragePolicy* special_storage_policy, | 99 quota::SpecialStoragePolicy* special_storage_policy, |
| 99 quota::QuotaManagerProxy* quota_manager_proxy, | 100 quota::QuotaManagerProxy* quota_manager_proxy, |
| 100 base::MessageLoopProxy* db_tracker_thread); | 101 base::MessageLoopProxy* db_tracker_thread); |
| 101 | 102 |
| 102 void DatabaseOpened(const string16& origin_identifier, | 103 void DatabaseOpened(const string16& origin_identifier, |
| 103 const string16& database_name, | 104 const string16& database_name, |
| 104 const string16& database_details, | 105 const string16& database_details, |
| 105 int64 estimated_size, | 106 int64 estimated_size, |
| 106 int64* database_size); | 107 int64* database_size); |
| 107 void DatabaseModified(const string16& origin_identifier, | 108 void DatabaseModified(const string16& origin_identifier, |
| 108 const string16& database_name); | 109 const string16& database_name); |
| 109 void DatabaseClosed(const string16& origin_identifier, | 110 void DatabaseClosed(const string16& origin_identifier, |
| 110 const string16& database_name); | 111 const string16& database_name); |
| 111 void HandleSqliteError(const string16& origin_identifier, | 112 void HandleSqliteError(const string16& origin_identifier, |
| 112 const string16& database_name, | 113 const string16& database_name, |
| 113 int error); | 114 int error); |
| 114 | 115 |
| 115 void CloseDatabases(const DatabaseConnections& connections); | 116 void CloseDatabases(const DatabaseConnections& connections); |
| 116 | 117 |
| 117 void AddObserver(Observer* observer); | 118 void AddObserver(Observer* observer); |
| 118 void RemoveObserver(Observer* observer); | 119 void RemoveObserver(Observer* observer); |
| 119 | 120 |
| 120 void CloseTrackerDatabaseAndClearCaches(); | 121 void CloseTrackerDatabaseAndClearCaches(); |
| 121 | 122 |
| 122 const FilePath& DatabaseDirectory() const { return db_dir_; } | 123 const base::FilePath& DatabaseDirectory() const { return db_dir_; } |
| 123 FilePath GetFullDBFilePath(const string16& origin_identifier, | 124 base::FilePath GetFullDBFilePath(const string16& origin_identifier, |
| 124 const string16& database_name); | 125 const string16& database_name); |
| 125 | 126 |
| 126 // virtual for unit-testing only | 127 // virtual for unit-testing only |
| 127 virtual bool GetOriginInfo(const string16& origin_id, OriginInfo* info); | 128 virtual bool GetOriginInfo(const string16& origin_id, OriginInfo* info); |
| 128 virtual bool GetAllOriginIdentifiers(std::vector<string16>* origin_ids); | 129 virtual bool GetAllOriginIdentifiers(std::vector<string16>* origin_ids); |
| 129 virtual bool GetAllOriginsInfo(std::vector<OriginInfo>* origins_info); | 130 virtual bool GetAllOriginsInfo(std::vector<OriginInfo>* origins_info); |
| 130 | 131 |
| 131 // Safe to call on any thread. | 132 // Safe to call on any thread. |
| 132 quota::QuotaManagerProxy* quota_manager_proxy() const { | 133 quota::QuotaManagerProxy* quota_manager_proxy() const { |
| 133 return quota_manager_proxy_.get(); | 134 return quota_manager_proxy_.get(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 void ScheduleDatabasesForDeletion(const DatabaseSet& databases, | 258 void ScheduleDatabasesForDeletion(const DatabaseSet& databases, |
| 258 const net::CompletionCallback& callback); | 259 const net::CompletionCallback& callback); |
| 259 | 260 |
| 260 // Returns the directory where all DB files for the given origin are stored. | 261 // Returns the directory where all DB files for the given origin are stored. |
| 261 string16 GetOriginDirectory(const string16& origin_identifier); | 262 string16 GetOriginDirectory(const string16& origin_identifier); |
| 262 | 263 |
| 263 bool is_initialized_; | 264 bool is_initialized_; |
| 264 const bool is_incognito_; | 265 const bool is_incognito_; |
| 265 bool force_keep_session_state_; | 266 bool force_keep_session_state_; |
| 266 bool shutting_down_; | 267 bool shutting_down_; |
| 267 const FilePath profile_path_; | 268 const base::FilePath profile_path_; |
| 268 const FilePath db_dir_; | 269 const base::FilePath db_dir_; |
| 269 scoped_ptr<sql::Connection> db_; | 270 scoped_ptr<sql::Connection> db_; |
| 270 scoped_ptr<DatabasesTable> databases_table_; | 271 scoped_ptr<DatabasesTable> databases_table_; |
| 271 scoped_ptr<sql::MetaTable> meta_table_; | 272 scoped_ptr<sql::MetaTable> meta_table_; |
| 272 ObserverList<Observer, true> observers_; | 273 ObserverList<Observer, true> observers_; |
| 273 std::map<string16, CachedOriginInfo> origins_info_map_; | 274 std::map<string16, CachedOriginInfo> origins_info_map_; |
| 274 DatabaseConnections database_connections_; | 275 DatabaseConnections database_connections_; |
| 275 | 276 |
| 276 // The set of databases that should be deleted but are still opened | 277 // The set of databases that should be deleted but are still opened |
| 277 DatabaseSet dbs_to_be_deleted_; | 278 DatabaseSet dbs_to_be_deleted_; |
| 278 PendingDeletionCallbacks deletion_callbacks_; | 279 PendingDeletionCallbacks deletion_callbacks_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 298 // this map to assign directory names that do not reveal this information. | 299 // this map to assign directory names that do not reveal this information. |
| 299 OriginDirectoriesMap incognito_origin_directories_; | 300 OriginDirectoriesMap incognito_origin_directories_; |
| 300 int incognito_origin_directories_generator_; | 301 int incognito_origin_directories_generator_; |
| 301 | 302 |
| 302 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); | 303 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); |
| 303 }; | 304 }; |
| 304 | 305 |
| 305 } // namespace webkit_database | 306 } // namespace webkit_database |
| 306 | 307 |
| 307 #endif // WEBKIT_DATABASE_DATABASE_TRACKER_H_ | 308 #endif // WEBKIT_DATABASE_DATABASE_TRACKER_H_ |
| OLD | NEW |