| 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 <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 18 #include "webkit/appcache/appcache_export.h" | 18 #include "webkit/appcache/appcache_export.h" |
| 19 | 19 |
| 20 namespace sql { | 20 namespace sql { |
| 21 class Connection; | 21 class Connection; |
| 22 class MetaTable; | 22 class MetaTable; |
| 23 class Statement; | 23 class Statement; |
| 24 class StatementID; | 24 class StatementID; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace appcache { | 27 namespace appcache { |
| 28 | 28 |
| 29 class AppCacheDatabase { | 29 class APPCACHE_EXPORT AppCacheDatabase { |
| 30 public: | 30 public: |
| 31 struct GroupRecord { | 31 struct APPCACHE_EXPORT GroupRecord { |
| 32 GroupRecord(); | 32 GroupRecord(); |
| 33 ~GroupRecord(); | 33 ~GroupRecord(); |
| 34 | 34 |
| 35 int64 group_id; | 35 int64 group_id; |
| 36 GURL origin; | 36 GURL origin; |
| 37 GURL manifest_url; | 37 GURL manifest_url; |
| 38 base::Time creation_time; | 38 base::Time creation_time; |
| 39 base::Time last_access_time; | 39 base::Time last_access_time; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 struct CacheRecord { | 42 struct APPCACHE_EXPORT CacheRecord { |
| 43 CacheRecord() | 43 CacheRecord() |
| 44 : cache_id(0), group_id(0), online_wildcard(false), cache_size(0) {} | 44 : cache_id(0), group_id(0), online_wildcard(false), cache_size(0) {} |
| 45 | 45 |
| 46 int64 cache_id; | 46 int64 cache_id; |
| 47 int64 group_id; | 47 int64 group_id; |
| 48 bool online_wildcard; | 48 bool online_wildcard; |
| 49 base::Time update_time; | 49 base::Time update_time; |
| 50 int64 cache_size; // the sum of all response sizes in this cache | 50 int64 cache_size; // the sum of all response sizes in this cache |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 struct EntryRecord { | 53 struct EntryRecord { |
| 54 EntryRecord() : cache_id(0), flags(0), response_id(0), response_size(0) {} | 54 EntryRecord() : cache_id(0), flags(0), response_id(0), response_size(0) {} |
| 55 | 55 |
| 56 int64 cache_id; | 56 int64 cache_id; |
| 57 GURL url; | 57 GURL url; |
| 58 int flags; | 58 int flags; |
| 59 int64 response_id; | 59 int64 response_id; |
| 60 int64 response_size; | 60 int64 response_size; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 struct FallbackNameSpaceRecord { | 63 struct APPCACHE_EXPORT FallbackNameSpaceRecord { |
| 64 FallbackNameSpaceRecord(); | 64 FallbackNameSpaceRecord(); |
| 65 ~FallbackNameSpaceRecord(); | 65 ~FallbackNameSpaceRecord(); |
| 66 | 66 |
| 67 int64 cache_id; | 67 int64 cache_id; |
| 68 GURL origin; // intentionally not normalized | 68 GURL origin; // intentionally not normalized |
| 69 GURL namespace_url; | 69 GURL namespace_url; |
| 70 GURL fallback_entry_url; | 70 GURL fallback_entry_url; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 struct OnlineWhiteListRecord { | 73 struct OnlineWhiteListRecord { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // Record retrieval helpers | 173 // Record retrieval helpers |
| 174 void ReadGroupRecord(const sql::Statement& statement, GroupRecord* record); | 174 void ReadGroupRecord(const sql::Statement& statement, GroupRecord* record); |
| 175 void ReadCacheRecord(const sql::Statement& statement, CacheRecord* record); | 175 void ReadCacheRecord(const sql::Statement& statement, CacheRecord* record); |
| 176 void ReadEntryRecord(const sql::Statement& statement, EntryRecord* record); | 176 void ReadEntryRecord(const sql::Statement& statement, EntryRecord* record); |
| 177 void ReadFallbackNameSpaceRecord( | 177 void ReadFallbackNameSpaceRecord( |
| 178 const sql::Statement& statement, FallbackNameSpaceRecord* record); | 178 const sql::Statement& statement, FallbackNameSpaceRecord* record); |
| 179 void ReadOnlineWhiteListRecord( | 179 void ReadOnlineWhiteListRecord( |
| 180 const sql::Statement& statement, OnlineWhiteListRecord* record); | 180 const sql::Statement& statement, OnlineWhiteListRecord* record); |
| 181 | 181 |
| 182 // Database creation | 182 // Database creation |
| 183 APPCACHE_EXPORT bool LazyOpen(bool create_if_needed); | 183 bool LazyOpen(bool create_if_needed); |
| 184 bool EnsureDatabaseVersion(); | 184 bool EnsureDatabaseVersion(); |
| 185 bool CreateSchema(); | 185 bool CreateSchema(); |
| 186 bool UpgradeSchema(); | 186 bool UpgradeSchema(); |
| 187 | 187 |
| 188 void ResetConnectionAndTables(); | 188 void ResetConnectionAndTables(); |
| 189 | 189 |
| 190 // Deletes the existing database file and the entire directory containing | 190 // Deletes the existing database file and the entire directory containing |
| 191 // the database file including the disk cache in which response headers | 191 // the database file including the disk cache in which response headers |
| 192 // and bodies are stored, and then creates a new database file. | 192 // and bodies are stored, and then creates a new database file. |
| 193 bool DeleteExistingAndCreateNewDatabase(); | 193 bool DeleteExistingAndCreateNewDatabase(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 207 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, ReCreate); | 207 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, ReCreate); |
| 208 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, DeletableResponseIds); | 208 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, DeletableResponseIds); |
| 209 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, OriginUsage); | 209 FRIEND_TEST_ALL_PREFIXES(AppCacheDatabaseTest, OriginUsage); |
| 210 | 210 |
| 211 DISALLOW_COPY_AND_ASSIGN(AppCacheDatabase); | 211 DISALLOW_COPY_AND_ASSIGN(AppCacheDatabase); |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 } // namespace appcache | 214 } // namespace appcache |
| 215 | 215 |
| 216 #endif // WEBKIT_APPCACHE_APPCACHE_DATABASE_H_ | 216 #endif // WEBKIT_APPCACHE_APPCACHE_DATABASE_H_ |
| OLD | NEW |