| 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_APPCACHE_APPCACHE_DATABASE_H_ | 5 #ifndef WEBKIT_APPCACHE_APPCACHE_DATABASE_H_ |
| 6 #define WEBKIT_APPCACHE_APPCACHE_DATABASE_H_ | 6 #define WEBKIT_APPCACHE_APPCACHE_DATABASE_H_ |
| 7 | 7 |
| 8 #include <map> |
| 8 #include <set> | 9 #include <set> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 12 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 13 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/time.h" | 16 #include "base/time.h" |
| 16 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 17 | 18 |
| 18 namespace sql { | 19 namespace sql { |
| 19 class Connection; | 20 class Connection; |
| 20 class MetaTable; | 21 class MetaTable; |
| 21 class Statement; | 22 class Statement; |
| 22 class StatementID; | 23 class StatementID; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace webkit_database { | |
| 26 class QuotaTable; | |
| 27 } | |
| 28 | |
| 29 namespace appcache { | 26 namespace appcache { |
| 30 | 27 |
| 31 class AppCacheDatabase { | 28 class AppCacheDatabase { |
| 32 public: | 29 public: |
| 33 struct GroupRecord { | 30 struct GroupRecord { |
| 34 GroupRecord(); | 31 GroupRecord(); |
| 35 ~GroupRecord(); | 32 ~GroupRecord(); |
| 36 | 33 |
| 37 int64 group_id; | 34 int64 group_id; |
| 38 GURL origin; | 35 GURL origin; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 GURL namespace_url; | 76 GURL namespace_url; |
| 80 }; | 77 }; |
| 81 | 78 |
| 82 explicit AppCacheDatabase(const FilePath& path); | 79 explicit AppCacheDatabase(const FilePath& path); |
| 83 ~AppCacheDatabase(); | 80 ~AppCacheDatabase(); |
| 84 | 81 |
| 85 void CloseConnection(); | 82 void CloseConnection(); |
| 86 void Disable(); | 83 void Disable(); |
| 87 bool is_disabled() const { return is_disabled_; } | 84 bool is_disabled() const { return is_disabled_; } |
| 88 | 85 |
| 89 int64 GetDefaultOriginQuota() { return 5 * 1024 * 1024; } | |
| 90 int64 GetOriginUsage(const GURL& origin); | 86 int64 GetOriginUsage(const GURL& origin); |
| 91 int64 GetOriginQuota(const GURL& origin); | 87 bool GetAllOriginUsage(std::map<GURL, int64>* usage_map); |
| 92 | 88 |
| 93 bool FindOriginsWithGroups(std::set<GURL>* origins); | 89 bool FindOriginsWithGroups(std::set<GURL>* origins); |
| 94 bool FindLastStorageIds( | 90 bool FindLastStorageIds( |
| 95 int64* last_group_id, int64* last_cache_id, int64* last_response_id, | 91 int64* last_group_id, int64* last_cache_id, int64* last_response_id, |
| 96 int64* last_deletable_response_rowid); | 92 int64* last_deletable_response_rowid); |
| 97 | 93 |
| 98 bool FindGroup(int64 group_id, GroupRecord* record); | 94 bool FindGroup(int64 group_id, GroupRecord* record); |
| 99 bool FindGroupForManifestUrl(const GURL& manifest_url, GroupRecord* record); | 95 bool FindGroupForManifestUrl(const GURL& manifest_url, GroupRecord* record); |
| 100 bool FindGroupsForOrigin( | 96 bool FindGroupsForOrigin( |
| 101 const GURL& origin, std::vector<GroupRecord>* records); | 97 const GURL& origin, std::vector<GroupRecord>* records); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 void ResetConnectionAndTables(); | 187 void ResetConnectionAndTables(); |
| 192 | 188 |
| 193 // Deletes the existing database file and the entire directory containing | 189 // Deletes the existing database file and the entire directory containing |
| 194 // the database file including the disk cache in which response headers | 190 // the database file including the disk cache in which response headers |
| 195 // and bodies are stored, and then creates a new database file. | 191 // and bodies are stored, and then creates a new database file. |
| 196 bool DeleteExistingAndCreateNewDatabase(); | 192 bool DeleteExistingAndCreateNewDatabase(); |
| 197 | 193 |
| 198 FilePath db_file_path_; | 194 FilePath db_file_path_; |
| 199 scoped_ptr<sql::Connection> db_; | 195 scoped_ptr<sql::Connection> db_; |
| 200 scoped_ptr<sql::MetaTable> meta_table_; | 196 scoped_ptr<sql::MetaTable> meta_table_; |
| 201 scoped_ptr<webkit_database::QuotaTable> quota_table_; | |
| 202 bool is_disabled_; | 197 bool is_disabled_; |
| 203 bool is_recreating_; | 198 bool is_recreating_; |
| 204 | 199 |
| 205 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, CacheRecords); | 200 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, CacheRecords); |
| 206 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, EntryRecords); | 201 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, EntryRecords); |
| 207 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, FallbackNameSpaceRecords); | 202 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, FallbackNameSpaceRecords); |
| 208 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, GroupRecords); | 203 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, GroupRecords); |
| 209 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, LazyOpen); | 204 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, LazyOpen); |
| 210 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, OnlineWhiteListRecords); | 205 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, OnlineWhiteListRecords); |
| 211 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, ReCreate); | 206 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, ReCreate); |
| 212 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, DeletableResponseIds); | 207 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, DeletableResponseIds); |
| 213 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, Quotas); | 208 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, OriginUsage); |
| 214 | 209 |
| 215 DISALLOW_COPY_AND_ASSIGN(AppCacheDatabase); | 210 DISALLOW_COPY_AND_ASSIGN(AppCacheDatabase); |
| 216 }; | 211 }; |
| 217 | 212 |
| 218 } // namespace appcache | 213 } // namespace appcache |
| 219 | 214 |
| 220 #endif // WEBKIT_APPCACHE_APPCACHE_DATABASE_H_ | 215 #endif // WEBKIT_APPCACHE_APPCACHE_DATABASE_H_ |
| OLD | NEW |