Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: webkit/quota/quota_database.h

Issue 7322005: Revert 91690 - Implement QM::GetOriginsModifiedSince for browser data deleter support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/quota/mock_storage_client.cc ('k') | webkit/quota/quota_database.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 23 matching lines...) Expand all
34 class QuotaDatabase { 34 class QuotaDatabase {
35 public: 35 public:
36 // If 'path' is empty, an in memory database will be used. 36 // If 'path' is empty, an in memory database will be used.
37 explicit QuotaDatabase(const FilePath& path); 37 explicit QuotaDatabase(const FilePath& path);
38 ~QuotaDatabase(); 38 ~QuotaDatabase();
39 39
40 void CloseConnection(); 40 void CloseConnection();
41 41
42 bool GetHostQuota(const std::string& host, StorageType type, int64* quota); 42 bool GetHostQuota(const std::string& host, StorageType type, int64* quota);
43 bool SetHostQuota(const std::string& host, StorageType type, int64 quota); 43 bool SetHostQuota(const std::string& host, StorageType type, int64 quota);
44 bool DeleteHostQuota(const std::string& host, StorageType type);
45 44
46 bool SetOriginLastAccessTime(const GURL& origin, 45 bool SetOriginLastAccessTime(const GURL& origin, StorageType type,
47 StorageType type,
48 base::Time last_access_time); 46 base::Time last_access_time);
49 47
50 bool SetOriginLastModifiedTime(const GURL& origin, 48 // Register |origins| to Database with |used_count| = 0 and
51 StorageType type, 49 // specified |last_access_time|.
52 base::Time last_modified_time); 50 bool RegisterOrigins(const std::set<GURL>& origins,
51 StorageType type,
52 base::Time last_access_time);
53 53
54 // Register initial |origins| info |type| to the database. 54 bool DeleteHostQuota(const std::string& host, StorageType type);
55 // This method is assumed to be called only after the installation or 55 bool DeleteOriginLastAccessTime(const GURL& origin, StorageType type);
56 // the database schema reset.
57 bool RegisterInitialOriginInfo(
58 const std::set<GURL>& origins, StorageType type);
59
60 bool DeleteOriginInfo(const GURL& origin, StorageType type);
61 56
62 bool GetGlobalQuota(StorageType type, int64* quota); 57 bool GetGlobalQuota(StorageType type, int64* quota);
63 bool SetGlobalQuota(StorageType type, int64 quota); 58 bool SetGlobalQuota(StorageType type, int64 quota);
64 59
65 // Sets |origin| to the least recently used origin of origins not included 60 // Sets |origin| to the least recently used origin of origins not included
66 // in |exceptions| and not granted the special unlimited storage right. 61 // in |exceptions| and not granted the special unlimited storage right.
67 // It returns false when it failed in accessing the database. 62 // It returns false when it failed in accessing the database.
68 // |origin| is set to empty when there is no matching origin. 63 // |origin| is set to empty when there is no matching origin.
69 bool GetLRUOrigin(StorageType type, 64 bool GetLRUOrigin(StorageType type,
70 const std::set<GURL>& exceptions, 65 const std::set<GURL>& exceptions,
71 SpecialStoragePolicy* special_storage_policy, 66 SpecialStoragePolicy* special_storage_policy,
72 GURL* origin); 67 GURL* origin);
73 68
74 // Populates |origins| with the ones that have been modified since
75 // the |modified_since|.
76 bool GetOriginsModifiedSince(StorageType type,
77 std::set<GURL>* origins,
78 base::Time modified_since);
79
80 // Returns false if SetOriginDatabaseBootstrapped has never 69 // Returns false if SetOriginDatabaseBootstrapped has never
81 // been called before, which means existing origins may not have been 70 // been called before, which means existing origins may not have been
82 // registered. 71 // registered.
83 bool IsOriginDatabaseBootstrapped(); 72 bool IsOriginDatabaseBootstrapped();
84 bool SetOriginDatabaseBootstrapped(bool bootstrap_flag); 73 bool SetOriginDatabaseBootstrapped(bool bootstrap_flag);
85 74
86 private: 75 private:
87 struct QuotaTableEntry { 76 struct QuotaTableEntry {
88 std::string host; 77 std::string host;
89 StorageType type; 78 StorageType type;
90 int64 quota; 79 int64 quota;
91 }; 80 };
92 friend bool operator <(const QuotaTableEntry& lhs, 81 friend bool operator <(const QuotaTableEntry& lhs,
93 const QuotaTableEntry& rhs); 82 const QuotaTableEntry& rhs);
94 83
95 struct OriginInfoTableEntry { 84 struct LastAccessTimeTableEntry {
96 GURL origin; 85 GURL origin;
97 StorageType type; 86 StorageType type;
98 int used_count; 87 int used_count;
99 base::Time last_access_time; 88 base::Time last_access_time;
100 base::Time last_modified_time;
101 }; 89 };
102 friend bool operator <(const OriginInfoTableEntry& lhs, 90 friend bool operator <(const LastAccessTimeTableEntry& lhs,
103 const OriginInfoTableEntry& rhs); 91 const LastAccessTimeTableEntry& rhs);
104
105 // Structures used for CreateSchema.
106 struct TableSchema {
107 const char* table_name;
108 const char* columns;
109 };
110 struct IndexSchema {
111 const char* index_name;
112 const char* table_name;
113 const char* columns;
114 bool unique;
115 };
116 92
117 typedef base::Callback<bool (const QuotaTableEntry&)> QuotaTableCallback; 93 typedef base::Callback<bool (const QuotaTableEntry&)> QuotaTableCallback;
118 typedef base::Callback<bool (const OriginInfoTableEntry&)> 94 typedef base::Callback<bool (const LastAccessTimeTableEntry&)>
119 OriginInfoTableCallback; 95 LastAccessTimeTableCallback;
120
121 struct QuotaTableImporter;
122 96
123 // For long-running transactions support. We always keep a transaction open 97 // For long-running transactions support. We always keep a transaction open
124 // so that multiple transactions can be batched. They are flushed 98 // so that multiple transactions can be batched. They are flushed
125 // with a delay after a modification has been made. We support neither 99 // with a delay after a modification has been made. We support neither
126 // nested transactions nor rollback (as we don't need them for now). 100 // nested transactions nor rollback (as we don't need them for now).
127 void Commit(); 101 void Commit();
128 void ScheduleCommit(); 102 void ScheduleCommit();
129 103
130 bool FindOriginUsedCount(const GURL& origin, 104 bool FindOriginUsedCount(const GURL& origin,
131 StorageType type, 105 StorageType type,
132 int* used_count); 106 int* used_count);
133 107
134 bool LazyOpen(bool create_if_needed); 108 bool LazyOpen(bool create_if_needed);
135 bool EnsureDatabaseVersion(); 109 bool EnsureDatabaseVersion();
110 bool CreateSchema();
136 bool ResetSchema(); 111 bool ResetSchema();
137 bool UpgradeSchema(int current_version);
138 112
139 static bool CreateSchema( 113 // |callback| may return false to stop reading data
140 sql::Connection* database, 114 bool DumpQuotaTable(QuotaTableCallback* callback);
141 sql::MetaTable* meta_table, 115 bool DumpLastAccessTimeTable(LastAccessTimeTableCallback* callback);
142 int schema_version, int compatible_version,
143 const TableSchema* tables, size_t tables_size,
144 const IndexSchema* indexes, size_t indexes_size);
145 116
146 // |callback| may return false to stop reading data.
147 bool DumpQuotaTable(QuotaTableCallback* callback);
148 bool DumpOriginInfoTable(OriginInfoTableCallback* callback);
149 117
150 FilePath db_file_path_; 118 FilePath db_file_path_;
151 119
152 scoped_ptr<sql::Connection> db_; 120 scoped_ptr<sql::Connection> db_;
153 scoped_ptr<sql::MetaTable> meta_table_; 121 scoped_ptr<sql::MetaTable> meta_table_;
154 bool is_recreating_; 122 bool is_recreating_;
155 bool is_disabled_; 123 bool is_disabled_;
156 124
157 base::OneShotTimer<QuotaDatabase> timer_; 125 base::OneShotTimer<QuotaDatabase> timer_;
158 126
159 friend class QuotaDatabaseTest; 127 friend class QuotaDatabaseTest;
160 friend class QuotaManager; 128 friend class QuotaManager;
161 129
162 static const TableSchema kTables[];
163 static const IndexSchema kIndexes[];
164
165 DISALLOW_COPY_AND_ASSIGN(QuotaDatabase); 130 DISALLOW_COPY_AND_ASSIGN(QuotaDatabase);
166 }; 131 };
167 132
168 } // namespace quota 133 } // namespace quota
169 134
170 #endif // WEBKIT_QUOTA_QUOTA_DATABASE_H_ 135 #endif // WEBKIT_QUOTA_QUOTA_DATABASE_H_
OLDNEW
« no previous file with comments | « webkit/quota/mock_storage_client.cc ('k') | webkit/quota/quota_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698