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_QUOTA_QUOTA_DATABASE_H_ | 5 #ifndef WEBKIT_QUOTA_QUOTA_DATABASE_H_ |
6 #define WEBKIT_QUOTA_QUOTA_DATABASE_H_ | 6 #define WEBKIT_QUOTA_QUOTA_DATABASE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | 12 #include "base/callback.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 "base/timer.h" | 17 #include "base/timer.h" |
18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
19 #include "webkit/quota/quota_types.h" | 19 #include "webkit/quota/quota_types.h" |
| 20 #include "webkit/storage/webkit_storage_export.h" |
20 | 21 |
21 namespace sql { | 22 namespace sql { |
22 class Connection; | 23 class Connection; |
23 class MetaTable; | 24 class MetaTable; |
24 } | 25 } |
25 | 26 |
26 class GURL; | 27 class GURL; |
27 | 28 |
28 namespace quota { | 29 namespace quota { |
29 | 30 |
30 class SpecialStoragePolicy; | 31 class SpecialStoragePolicy; |
31 | 32 |
32 // All the methods of this class must run on the DB thread. | 33 // All the methods of this class must run on the DB thread. |
33 class QuotaDatabase { | 34 class WEBKIT_STORAGE_EXPORT_PRIVATE QuotaDatabase { |
34 public: | 35 public: |
35 // Constants for {Get,Set}QuotaConfigValue keys. | 36 // Constants for {Get,Set}QuotaConfigValue keys. |
36 static const char kDesiredAvailableSpaceKey[]; | 37 static const char kDesiredAvailableSpaceKey[]; |
37 static const char kTemporaryQuotaOverrideKey[]; | 38 static const char kTemporaryQuotaOverrideKey[]; |
38 | 39 |
39 // If 'path' is empty, an in memory database will be used. | 40 // If 'path' is empty, an in memory database will be used. |
40 explicit QuotaDatabase(const FilePath& path); | 41 explicit QuotaDatabase(const FilePath& path); |
41 ~QuotaDatabase(); | 42 ~QuotaDatabase(); |
42 | 43 |
43 void CloseConnection(); | 44 void CloseConnection(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 std::set<GURL>* origins, | 81 std::set<GURL>* origins, |
81 base::Time modified_since); | 82 base::Time modified_since); |
82 | 83 |
83 // Returns false if SetOriginDatabaseBootstrapped has never | 84 // Returns false if SetOriginDatabaseBootstrapped has never |
84 // been called before, which means existing origins may not have been | 85 // been called before, which means existing origins may not have been |
85 // registered. | 86 // registered. |
86 bool IsOriginDatabaseBootstrapped(); | 87 bool IsOriginDatabaseBootstrapped(); |
87 bool SetOriginDatabaseBootstrapped(bool bootstrap_flag); | 88 bool SetOriginDatabaseBootstrapped(bool bootstrap_flag); |
88 | 89 |
89 private: | 90 private: |
90 struct QuotaTableEntry { | 91 struct WEBKIT_STORAGE_EXPORT_PRIVATE QuotaTableEntry { |
91 QuotaTableEntry(); | 92 QuotaTableEntry(); |
92 QuotaTableEntry( | 93 QuotaTableEntry( |
93 const std::string& host, | 94 const std::string& host, |
94 StorageType type, | 95 StorageType type, |
95 int64 quota); | 96 int64 quota); |
96 std::string host; | 97 std::string host; |
97 StorageType type; | 98 StorageType type; |
98 int64 quota; | 99 int64 quota; |
99 }; | 100 }; |
100 friend bool operator <(const QuotaTableEntry& lhs, | 101 friend WEBKIT_STORAGE_EXPORT_PRIVATE bool operator <( |
101 const QuotaTableEntry& rhs); | 102 const QuotaTableEntry& lhs, const QuotaTableEntry& rhs); |
102 | 103 |
103 struct OriginInfoTableEntry { | 104 struct WEBKIT_STORAGE_EXPORT_PRIVATE OriginInfoTableEntry { |
104 OriginInfoTableEntry(); | 105 OriginInfoTableEntry(); |
105 OriginInfoTableEntry( | 106 OriginInfoTableEntry( |
106 const GURL& origin, | 107 const GURL& origin, |
107 StorageType type, | 108 StorageType type, |
108 int used_count, | 109 int used_count, |
109 const base::Time& last_access_time, | 110 const base::Time& last_access_time, |
110 const base::Time& last_modified_time); | 111 const base::Time& last_modified_time); |
111 GURL origin; | 112 GURL origin; |
112 StorageType type; | 113 StorageType type; |
113 int used_count; | 114 int used_count; |
114 base::Time last_access_time; | 115 base::Time last_access_time; |
115 base::Time last_modified_time; | 116 base::Time last_modified_time; |
116 }; | 117 }; |
117 friend bool operator <(const OriginInfoTableEntry& lhs, | 118 friend WEBKIT_STORAGE_EXPORT_PRIVATE bool operator <( |
118 const OriginInfoTableEntry& rhs); | 119 const OriginInfoTableEntry& lhs, const OriginInfoTableEntry& rhs); |
119 | 120 |
120 // Structures used for CreateSchema. | 121 // Structures used for CreateSchema. |
121 struct TableSchema { | 122 struct TableSchema { |
122 const char* table_name; | 123 const char* table_name; |
123 const char* columns; | 124 const char* columns; |
124 }; | 125 }; |
125 struct IndexSchema { | 126 struct IndexSchema { |
126 const char* index_name; | 127 const char* index_name; |
127 const char* table_name; | 128 const char* table_name; |
128 const char* columns; | 129 const char* columns; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 177 |
177 static const TableSchema kTables[]; | 178 static const TableSchema kTables[]; |
178 static const IndexSchema kIndexes[]; | 179 static const IndexSchema kIndexes[]; |
179 | 180 |
180 DISALLOW_COPY_AND_ASSIGN(QuotaDatabase); | 181 DISALLOW_COPY_AND_ASSIGN(QuotaDatabase); |
181 }; | 182 }; |
182 | 183 |
183 } // namespace quota | 184 } // namespace quota |
184 | 185 |
185 #endif // WEBKIT_QUOTA_QUOTA_DATABASE_H_ | 186 #endif // WEBKIT_QUOTA_QUOTA_DATABASE_H_ |
OLD | NEW |