| 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_BROWSER_DATABASE_DATABASE_TRACKER_H_ | 5 #ifndef WEBKIT_BROWSER_DATABASE_DATABASE_TRACKER_H_ |
| 6 #define WEBKIT_BROWSER_DATABASE_DATABASE_TRACKER_H_ | 6 #define WEBKIT_BROWSER_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 18 matching lines...) Expand all Loading... |
| 29 namespace content { | 29 namespace content { |
| 30 class DatabaseTracker_TestHelper_Test; | 30 class DatabaseTracker_TestHelper_Test; |
| 31 class MockDatabaseTracker; | 31 class MockDatabaseTracker; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace sql { | 34 namespace sql { |
| 35 class Connection; | 35 class Connection; |
| 36 class MetaTable; | 36 class MetaTable; |
| 37 } | 37 } |
| 38 | 38 |
| 39 namespace quota { | 39 namespace storage { |
| 40 class QuotaManagerProxy; | 40 class QuotaManagerProxy; |
| 41 class SpecialStoragePolicy; | 41 class SpecialStoragePolicy; |
| 42 } | 42 } |
| 43 | 43 |
| 44 namespace webkit_database { | 44 namespace storage { |
| 45 | 45 |
| 46 WEBKIT_STORAGE_BROWSER_EXPORT extern const base::FilePath::CharType | 46 WEBKIT_STORAGE_BROWSER_EXPORT extern const base::FilePath::CharType |
| 47 kDatabaseDirectoryName[]; | 47 kDatabaseDirectoryName[]; |
| 48 WEBKIT_STORAGE_BROWSER_EXPORT extern const base::FilePath::CharType | 48 WEBKIT_STORAGE_BROWSER_EXPORT extern const base::FilePath::CharType |
| 49 kTrackerDatabaseFileName[]; | 49 kTrackerDatabaseFileName[]; |
| 50 | 50 |
| 51 class DatabasesTable; | 51 class DatabasesTable; |
| 52 | 52 |
| 53 // This class is used to store information about all databases in an origin. | 53 // This class is used to store information about all databases in an origin. |
| 54 class WEBKIT_STORAGE_BROWSER_EXPORT OriginInfo { | 54 class WEBKIT_STORAGE_BROWSER_EXPORT OriginInfo { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 virtual void OnDatabaseScheduledForDeletion( | 96 virtual void OnDatabaseScheduledForDeletion( |
| 97 const std::string& origin_identifier, | 97 const std::string& origin_identifier, |
| 98 const base::string16& database_name) = 0; | 98 const base::string16& database_name) = 0; |
| 99 | 99 |
| 100 protected: | 100 protected: |
| 101 virtual ~Observer() {} | 101 virtual ~Observer() {} |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 DatabaseTracker(const base::FilePath& profile_path, | 104 DatabaseTracker(const base::FilePath& profile_path, |
| 105 bool is_incognito, | 105 bool is_incognito, |
| 106 quota::SpecialStoragePolicy* special_storage_policy, | 106 storage::SpecialStoragePolicy* special_storage_policy, |
| 107 quota::QuotaManagerProxy* quota_manager_proxy, | 107 storage::QuotaManagerProxy* quota_manager_proxy, |
| 108 base::MessageLoopProxy* db_tracker_thread); | 108 base::MessageLoopProxy* db_tracker_thread); |
| 109 | 109 |
| 110 void DatabaseOpened(const std::string& origin_identifier, | 110 void DatabaseOpened(const std::string& origin_identifier, |
| 111 const base::string16& database_name, | 111 const base::string16& database_name, |
| 112 const base::string16& database_details, | 112 const base::string16& database_details, |
| 113 int64 estimated_size, | 113 int64 estimated_size, |
| 114 int64* database_size); | 114 int64* database_size); |
| 115 void DatabaseModified(const std::string& origin_identifier, | 115 void DatabaseModified(const std::string& origin_identifier, |
| 116 const base::string16& database_name); | 116 const base::string16& database_name); |
| 117 void DatabaseClosed(const std::string& origin_identifier, | 117 void DatabaseClosed(const std::string& origin_identifier, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 130 const base::FilePath& DatabaseDirectory() const { return db_dir_; } | 130 const base::FilePath& DatabaseDirectory() const { return db_dir_; } |
| 131 base::FilePath GetFullDBFilePath(const std::string& origin_identifier, | 131 base::FilePath GetFullDBFilePath(const std::string& origin_identifier, |
| 132 const base::string16& database_name); | 132 const base::string16& database_name); |
| 133 | 133 |
| 134 // virtual for unit-testing only | 134 // virtual for unit-testing only |
| 135 virtual bool GetOriginInfo(const std::string& origin_id, OriginInfo* info); | 135 virtual bool GetOriginInfo(const std::string& origin_id, OriginInfo* info); |
| 136 virtual bool GetAllOriginIdentifiers(std::vector<std::string>* origin_ids); | 136 virtual bool GetAllOriginIdentifiers(std::vector<std::string>* origin_ids); |
| 137 virtual bool GetAllOriginsInfo(std::vector<OriginInfo>* origins_info); | 137 virtual bool GetAllOriginsInfo(std::vector<OriginInfo>* origins_info); |
| 138 | 138 |
| 139 // Safe to call on any thread. | 139 // Safe to call on any thread. |
| 140 quota::QuotaManagerProxy* quota_manager_proxy() const { | 140 storage::QuotaManagerProxy* quota_manager_proxy() const { |
| 141 return quota_manager_proxy_.get(); | 141 return quota_manager_proxy_.get(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool IsDatabaseScheduledForDeletion(const std::string& origin_identifier, | 144 bool IsDatabaseScheduledForDeletion(const std::string& origin_identifier, |
| 145 const base::string16& database_name); | 145 const base::string16& database_name); |
| 146 | 146 |
| 147 // Deletes a single database. Returns net::OK on success, net::FAILED on | 147 // Deletes a single database. Returns net::OK on success, net::FAILED on |
| 148 // failure, or net::ERR_IO_PENDING and |callback| is invoked upon completion, | 148 // failure, or net::ERR_IO_PENDING and |callback| is invoked upon completion, |
| 149 // if non-NULL. | 149 // if non-NULL. |
| 150 int DeleteDatabase(const std::string& origin_identifier, | 150 int DeleteDatabase(const std::string& origin_identifier, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 scoped_ptr<sql::MetaTable> meta_table_; | 283 scoped_ptr<sql::MetaTable> meta_table_; |
| 284 ObserverList<Observer, true> observers_; | 284 ObserverList<Observer, true> observers_; |
| 285 std::map<std::string, CachedOriginInfo> origins_info_map_; | 285 std::map<std::string, CachedOriginInfo> origins_info_map_; |
| 286 DatabaseConnections database_connections_; | 286 DatabaseConnections database_connections_; |
| 287 | 287 |
| 288 // The set of databases that should be deleted but are still opened | 288 // The set of databases that should be deleted but are still opened |
| 289 DatabaseSet dbs_to_be_deleted_; | 289 DatabaseSet dbs_to_be_deleted_; |
| 290 PendingDeletionCallbacks deletion_callbacks_; | 290 PendingDeletionCallbacks deletion_callbacks_; |
| 291 | 291 |
| 292 // Apps and Extensions can have special rights. | 292 // Apps and Extensions can have special rights. |
| 293 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 293 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_; |
| 294 | 294 |
| 295 scoped_refptr<quota::QuotaManagerProxy> quota_manager_proxy_; | 295 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy_; |
| 296 | 296 |
| 297 // The database tracker thread we're supposed to run file IO on. | 297 // The database tracker thread we're supposed to run file IO on. |
| 298 scoped_refptr<base::MessageLoopProxy> db_tracker_thread_; | 298 scoped_refptr<base::MessageLoopProxy> db_tracker_thread_; |
| 299 | 299 |
| 300 // When in incognito mode, store a DELETE_ON_CLOSE handle to each | 300 // When in incognito mode, store a DELETE_ON_CLOSE handle to each |
| 301 // main DB and journal file that was accessed. When the incognito profile | 301 // main DB and journal file that was accessed. When the incognito profile |
| 302 // goes away (or when the browser crashes), all these handles will be | 302 // goes away (or when the browser crashes), all these handles will be |
| 303 // closed, and the files will be deleted. | 303 // closed, and the files will be deleted. |
| 304 FileHandlesMap incognito_file_handles_; | 304 FileHandlesMap incognito_file_handles_; |
| 305 | 305 |
| 306 // In a non-incognito profile, all DBs in an origin are stored in a directory | 306 // In a non-incognito profile, all DBs in an origin are stored in a directory |
| 307 // named after the origin. In an incognito profile though, we do not want the | 307 // named after the origin. In an incognito profile though, we do not want the |
| 308 // directory structure to reveal the origins visited by the user (in case the | 308 // directory structure to reveal the origins visited by the user (in case the |
| 309 // browser process crashes and those directories are not deleted). So we use | 309 // browser process crashes and those directories are not deleted). So we use |
| 310 // this map to assign directory names that do not reveal this information. | 310 // this map to assign directory names that do not reveal this information. |
| 311 OriginDirectoriesMap incognito_origin_directories_; | 311 OriginDirectoriesMap incognito_origin_directories_; |
| 312 int incognito_origin_directories_generator_; | 312 int incognito_origin_directories_generator_; |
| 313 | 313 |
| 314 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); | 314 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); |
| 315 }; | 315 }; |
| 316 | 316 |
| 317 } // namespace webkit_database | 317 } // namespace storage |
| 318 | 318 |
| 319 #endif // WEBKIT_BROWSER_DATABASE_DATABASE_TRACKER_H_ | 319 #endif // WEBKIT_BROWSER_DATABASE_DATABASE_TRACKER_H_ |
| OLD | NEW |