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 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 GURL namespace_url; | 80 GURL namespace_url; |
80 }; | 81 }; |
81 | 82 |
82 explicit AppCacheDatabase(const FilePath& path); | 83 explicit AppCacheDatabase(const FilePath& path); |
83 ~AppCacheDatabase(); | 84 ~AppCacheDatabase(); |
84 | 85 |
85 void CloseConnection(); | 86 void CloseConnection(); |
86 void Disable(); | 87 void Disable(); |
87 bool is_disabled() const { return is_disabled_; } | 88 bool is_disabled() const { return is_disabled_; } |
88 | 89 |
89 int64 GetDefaultOriginQuota() { return 5 * 1024 * 1024; } | |
90 int64 GetOriginUsage(const GURL& origin); | 90 int64 GetOriginUsage(const GURL& origin); |
91 int64 GetOriginQuota(const GURL& origin); | 91 bool GetAllOriginUsage(std::map<GURL, int64>* usage_map); |
92 | 92 |
93 bool FindOriginsWithGroups(std::set<GURL>* origins); | 93 bool FindOriginsWithGroups(std::set<GURL>* origins); |
94 bool FindLastStorageIds( | 94 bool FindLastStorageIds( |
95 int64* last_group_id, int64* last_cache_id, int64* last_response_id, | 95 int64* last_group_id, int64* last_cache_id, int64* last_response_id, |
96 int64* last_deletable_response_rowid); | 96 int64* last_deletable_response_rowid); |
97 | 97 |
98 bool FindGroup(int64 group_id, GroupRecord* record); | 98 bool FindGroup(int64 group_id, GroupRecord* record); |
99 bool FindGroupForManifestUrl(const GURL& manifest_url, GroupRecord* record); | 99 bool FindGroupForManifestUrl(const GURL& manifest_url, GroupRecord* record); |
100 bool FindGroupsForOrigin( | 100 bool FindGroupsForOrigin( |
101 const GURL& origin, std::vector<GroupRecord>* records); | 101 const GURL& origin, std::vector<GroupRecord>* records); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 void ResetConnectionAndTables(); | 191 void ResetConnectionAndTables(); |
192 | 192 |
193 // Deletes the existing database file and the entire directory containing | 193 // Deletes the existing database file and the entire directory containing |
194 // the database file including the disk cache in which response headers | 194 // the database file including the disk cache in which response headers |
195 // and bodies are stored, and then creates a new database file. | 195 // and bodies are stored, and then creates a new database file. |
196 bool DeleteExistingAndCreateNewDatabase(); | 196 bool DeleteExistingAndCreateNewDatabase(); |
197 | 197 |
198 FilePath db_file_path_; | 198 FilePath db_file_path_; |
199 scoped_ptr<sql::Connection> db_; | 199 scoped_ptr<sql::Connection> db_; |
200 scoped_ptr<sql::MetaTable> meta_table_; | 200 scoped_ptr<sql::MetaTable> meta_table_; |
201 scoped_ptr<webkit_database::QuotaTable> quota_table_; | |
202 bool is_disabled_; | 201 bool is_disabled_; |
203 bool is_recreating_; | 202 bool is_recreating_; |
204 | 203 |
205 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, CacheRecords); | 204 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, CacheRecords); |
206 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, EntryRecords); | 205 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, EntryRecords); |
207 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, FallbackNameSpaceRecords); | 206 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, FallbackNameSpaceRecords); |
208 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, GroupRecords); | 207 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, GroupRecords); |
209 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, LazyOpen); | 208 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, LazyOpen); |
210 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, OnlineWhiteListRecords); | 209 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, OnlineWhiteListRecords); |
211 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, ReCreate); | 210 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, ReCreate); |
212 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, DeletableResponseIds); | 211 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, DeletableResponseIds); |
213 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, Quotas); | 212 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, OriginUsage); |
214 | 213 |
215 DISALLOW_COPY_AND_ASSIGN(AppCacheDatabase); | 214 DISALLOW_COPY_AND_ASSIGN(AppCacheDatabase); |
216 }; | 215 }; |
217 | 216 |
218 } // namespace appcache | 217 } // namespace appcache |
219 | 218 |
220 #endif // WEBKIT_APPCACHE_APPCACHE_DATABASE_H_ | 219 #endif // WEBKIT_APPCACHE_APPCACHE_DATABASE_H_ |
OLD | NEW |