| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 STORAGE_BROWSER_QUOTA_QUOTA_DATABASE_H_ | 5 #ifndef STORAGE_BROWSER_QUOTA_QUOTA_DATABASE_H_ |
| 6 #define STORAGE_BROWSER_QUOTA_QUOTA_DATABASE_H_ | 6 #define STORAGE_BROWSER_QUOTA_QUOTA_DATABASE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 class GURL; | 30 class GURL; |
| 31 | 31 |
| 32 namespace storage { | 32 namespace storage { |
| 33 | 33 |
| 34 class SpecialStoragePolicy; | 34 class SpecialStoragePolicy; |
| 35 | 35 |
| 36 // All the methods of this class must run on the DB thread. | 36 // All the methods of this class must run on the DB thread. |
| 37 class STORAGE_EXPORT_PRIVATE QuotaDatabase { | 37 class STORAGE_EXPORT_PRIVATE QuotaDatabase { |
| 38 public: | 38 public: |
| 39 struct STORAGE_EXPORT_PRIVATE OriginInfoTableEntry { |
| 40 OriginInfoTableEntry(); |
| 41 OriginInfoTableEntry(const GURL& origin, |
| 42 StorageType type, |
| 43 int used_count, |
| 44 const base::Time& last_access_time, |
| 45 const base::Time& last_modified_time); |
| 46 GURL origin; |
| 47 StorageType type; |
| 48 int used_count; |
| 49 base::Time last_access_time; |
| 50 base::Time last_modified_time; |
| 51 }; |
| 52 |
| 39 // Constants for {Get,Set}QuotaConfigValue keys. | 53 // Constants for {Get,Set}QuotaConfigValue keys. |
| 40 static const char kDesiredAvailableSpaceKey[]; | 54 static const char kDesiredAvailableSpaceKey[]; |
| 41 static const char kTemporaryQuotaOverrideKey[]; | 55 static const char kTemporaryQuotaOverrideKey[]; |
| 42 | 56 |
| 43 // If 'path' is empty, an in memory database will be used. | 57 // If 'path' is empty, an in memory database will be used. |
| 44 explicit QuotaDatabase(const base::FilePath& path); | 58 explicit QuotaDatabase(const base::FilePath& path); |
| 45 ~QuotaDatabase(); | 59 ~QuotaDatabase(); |
| 46 | 60 |
| 47 void CloseConnection(); | 61 void CloseConnection(); |
| 48 | 62 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 64 bool SetOriginLastEvictionTime(const GURL& origin, | 78 bool SetOriginLastEvictionTime(const GURL& origin, |
| 65 StorageType type, | 79 StorageType type, |
| 66 base::Time last_eviction_time); | 80 base::Time last_eviction_time); |
| 67 bool DeleteOriginLastEvictionTime(const GURL& origin, StorageType type); | 81 bool DeleteOriginLastEvictionTime(const GURL& origin, StorageType type); |
| 68 | 82 |
| 69 // Register initial |origins| info |type| to the database. | 83 // Register initial |origins| info |type| to the database. |
| 70 // This method is assumed to be called only after the installation or | 84 // This method is assumed to be called only after the installation or |
| 71 // the database schema reset. | 85 // the database schema reset. |
| 72 bool RegisterInitialOriginInfo( | 86 bool RegisterInitialOriginInfo( |
| 73 const std::set<GURL>& origins, StorageType type); | 87 const std::set<GURL>& origins, StorageType type); |
| 88 bool GetOriginInfo(const GURL& origin, |
| 89 StorageType type, |
| 90 OriginInfoTableEntry* entry); |
| 74 | 91 |
| 75 bool DeleteOriginInfo(const GURL& origin, StorageType type); | 92 bool DeleteOriginInfo(const GURL& origin, StorageType type); |
| 76 | 93 |
| 77 bool GetQuotaConfigValue(const char* key, int64* value); | 94 bool GetQuotaConfigValue(const char* key, int64* value); |
| 78 bool SetQuotaConfigValue(const char* key, int64 value); | 95 bool SetQuotaConfigValue(const char* key, int64 value); |
| 79 | 96 |
| 80 // Sets |origin| to the least recently used origin of origins not included | 97 // Sets |origin| to the least recently used origin of origins not included |
| 81 // in |exceptions| and not granted the special unlimited storage right. | 98 // in |exceptions| and not granted the special unlimited storage right. |
| 82 // It returns false when it failed in accessing the database. | 99 // It returns false when it failed in accessing the database. |
| 83 // |origin| is set to empty when there is no matching origin. | 100 // |origin| is set to empty when there is no matching origin. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 104 QuotaTableEntry( | 121 QuotaTableEntry( |
| 105 const std::string& host, | 122 const std::string& host, |
| 106 StorageType type, | 123 StorageType type, |
| 107 int64 quota); | 124 int64 quota); |
| 108 std::string host; | 125 std::string host; |
| 109 StorageType type; | 126 StorageType type; |
| 110 int64 quota; | 127 int64 quota; |
| 111 }; | 128 }; |
| 112 friend STORAGE_EXPORT_PRIVATE bool operator <( | 129 friend STORAGE_EXPORT_PRIVATE bool operator <( |
| 113 const QuotaTableEntry& lhs, const QuotaTableEntry& rhs); | 130 const QuotaTableEntry& lhs, const QuotaTableEntry& rhs); |
| 114 | |
| 115 struct STORAGE_EXPORT_PRIVATE OriginInfoTableEntry { | |
| 116 OriginInfoTableEntry(); | |
| 117 OriginInfoTableEntry( | |
| 118 const GURL& origin, | |
| 119 StorageType type, | |
| 120 int used_count, | |
| 121 const base::Time& last_access_time, | |
| 122 const base::Time& last_modified_time); | |
| 123 GURL origin; | |
| 124 StorageType type; | |
| 125 int used_count; | |
| 126 base::Time last_access_time; | |
| 127 base::Time last_modified_time; | |
| 128 }; | |
| 129 friend STORAGE_EXPORT_PRIVATE bool operator <( | 131 friend STORAGE_EXPORT_PRIVATE bool operator <( |
| 130 const OriginInfoTableEntry& lhs, const OriginInfoTableEntry& rhs); | 132 const OriginInfoTableEntry& lhs, const OriginInfoTableEntry& rhs); |
| 131 | 133 |
| 132 // Structures used for CreateSchema. | 134 // Structures used for CreateSchema. |
| 133 struct TableSchema { | 135 struct TableSchema { |
| 134 const char* table_name; | 136 const char* table_name; |
| 135 const char* columns; | 137 const char* columns; |
| 136 }; | 138 }; |
| 137 struct IndexSchema { | 139 struct IndexSchema { |
| 138 const char* index_name; | 140 const char* index_name; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 190 |
| 189 static const TableSchema kTables[]; | 191 static const TableSchema kTables[]; |
| 190 static const IndexSchema kIndexes[]; | 192 static const IndexSchema kIndexes[]; |
| 191 | 193 |
| 192 DISALLOW_COPY_AND_ASSIGN(QuotaDatabase); | 194 DISALLOW_COPY_AND_ASSIGN(QuotaDatabase); |
| 193 }; | 195 }; |
| 194 | 196 |
| 195 } // namespace storage | 197 } // namespace storage |
| 196 | 198 |
| 197 #endif // STORAGE_BROWSER_QUOTA_QUOTA_DATABASE_H_ | 199 #endif // STORAGE_BROWSER_QUOTA_QUOTA_DATABASE_H_ |
| OLD | NEW |