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