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

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

Issue 7168019: Implement QM::GetOriginsModifiedSince for browser data deleter support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reflected comments 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);
44 45
45 bool SetOriginLastAccessTime(const GURL& origin, StorageType type, 46 bool SetOriginLastAccessTime(const GURL& origin,
47 StorageType type,
46 base::Time last_access_time); 48 base::Time last_access_time);
47 49
48 // Register |origins| to Database with |used_count| = 0 and 50 bool SetOriginLastModifiedTime(const GURL& origin,
49 // specified |last_access_time|. 51 StorageType type,
50 bool RegisterOrigins(const std::set<GURL>& origins, 52 base::Time last_modified_time);
51 StorageType type,
52 base::Time last_access_time);
53 53
54 bool DeleteHostQuota(const std::string& host, StorageType type); 54 // Register initial |origins| info |type| to the database.
55 bool DeleteOriginLastAccessTime(const GURL& origin, StorageType type); 55 // This method is assumed to be called only after the installation or
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);
56 61
57 bool GetGlobalQuota(StorageType type, int64* quota); 62 bool GetGlobalQuota(StorageType type, int64* quota);
58 bool SetGlobalQuota(StorageType type, int64 quota); 63 bool SetGlobalQuota(StorageType type, int64 quota);
59 64
60 // Sets |origin| to the least recently used origin of origins not included 65 // Sets |origin| to the least recently used origin of origins not included
61 // in |exceptions| and not granted the special unlimited storage right. 66 // in |exceptions| and not granted the special unlimited storage right.
62 // It returns false when it failed in accessing the database. 67 // It returns false when it failed in accessing the database.
63 // |origin| is set to empty when there is no matching origin. 68 // |origin| is set to empty when there is no matching origin.
64 bool GetLRUOrigin(StorageType type, 69 bool GetLRUOrigin(StorageType type,
65 const std::set<GURL>& exceptions, 70 const std::set<GURL>& exceptions,
66 SpecialStoragePolicy* special_storage_policy, 71 SpecialStoragePolicy* special_storage_policy,
67 GURL* origin); 72 GURL* origin);
68 73
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
69 // Returns false if SetOriginDatabaseBootstrapped has never 80 // Returns false if SetOriginDatabaseBootstrapped has never
70 // been called before, which means existing origins may not have been 81 // been called before, which means existing origins may not have been
71 // registered. 82 // registered.
72 bool IsOriginDatabaseBootstrapped(); 83 bool IsOriginDatabaseBootstrapped();
73 bool SetOriginDatabaseBootstrapped(bool bootstrap_flag); 84 bool SetOriginDatabaseBootstrapped(bool bootstrap_flag);
74 85
75 private: 86 private:
76 struct QuotaTableEntry { 87 struct QuotaTableEntry {
77 std::string host; 88 std::string host;
78 StorageType type; 89 StorageType type;
79 int64 quota; 90 int64 quota;
80 }; 91 };
81 friend bool operator <(const QuotaTableEntry& lhs, 92 friend bool operator <(const QuotaTableEntry& lhs,
82 const QuotaTableEntry& rhs); 93 const QuotaTableEntry& rhs);
83 94
84 struct LastAccessTimeTableEntry { 95 struct OriginInfoTableEntry {
85 GURL origin; 96 GURL origin;
86 StorageType type; 97 StorageType type;
87 int used_count; 98 int used_count;
88 base::Time last_access_time; 99 base::Time last_access_time;
100 base::Time last_modified_time;
89 }; 101 };
90 friend bool operator <(const LastAccessTimeTableEntry& lhs, 102 friend bool operator <(const OriginInfoTableEntry& lhs,
91 const LastAccessTimeTableEntry& rhs); 103 const OriginInfoTableEntry& 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 };
92 116
93 typedef base::Callback<bool (const QuotaTableEntry&)> QuotaTableCallback; 117 typedef base::Callback<bool (const QuotaTableEntry&)> QuotaTableCallback;
94 typedef base::Callback<bool (const LastAccessTimeTableEntry&)> 118 typedef base::Callback<bool (const OriginInfoTableEntry&)>
95 LastAccessTimeTableCallback; 119 OriginInfoTableCallback;
120
121 struct QuotaTableImporter;
96 122
97 // For long-running transactions support. We always keep a transaction open 123 // For long-running transactions support. We always keep a transaction open
98 // so that multiple transactions can be batched. They are flushed 124 // so that multiple transactions can be batched. They are flushed
99 // with a delay after a modification has been made. We support neither 125 // with a delay after a modification has been made. We support neither
100 // nested transactions nor rollback (as we don't need them for now). 126 // nested transactions nor rollback (as we don't need them for now).
101 void Commit(); 127 void Commit();
102 void ScheduleCommit(); 128 void ScheduleCommit();
103 129
104 bool FindOriginUsedCount(const GURL& origin, 130 bool FindOriginUsedCount(const GURL& origin,
105 StorageType type, 131 StorageType type,
106 int* used_count); 132 int* used_count);
107 133
108 bool LazyOpen(bool create_if_needed); 134 bool LazyOpen(bool create_if_needed);
109 bool EnsureDatabaseVersion(); 135 bool EnsureDatabaseVersion();
110 bool CreateSchema();
111 bool ResetSchema(); 136 bool ResetSchema();
137 bool UpgradeSchema(int current_version);
112 138
113 // |callback| may return false to stop reading data 139 static bool CreateSchema(
140 sql::Connection* database,
141 sql::MetaTable* meta_table,
142 int schema_version, int compatible_version,
143 const TableSchema* tables, size_t tables_size,
144 const IndexSchema* indexes, size_t indexes_size);
145
146 // |callback| may return false to stop reading data.
114 bool DumpQuotaTable(QuotaTableCallback* callback); 147 bool DumpQuotaTable(QuotaTableCallback* callback);
115 bool DumpLastAccessTimeTable(LastAccessTimeTableCallback* callback); 148 bool DumpOriginInfoTable(OriginInfoTableCallback* callback);
116
117 149
118 FilePath db_file_path_; 150 FilePath db_file_path_;
119 151
120 scoped_ptr<sql::Connection> db_; 152 scoped_ptr<sql::Connection> db_;
121 scoped_ptr<sql::MetaTable> meta_table_; 153 scoped_ptr<sql::MetaTable> meta_table_;
122 bool is_recreating_; 154 bool is_recreating_;
123 bool is_disabled_; 155 bool is_disabled_;
124 156
125 base::OneShotTimer<QuotaDatabase> timer_; 157 base::OneShotTimer<QuotaDatabase> timer_;
126 158
127 friend class QuotaDatabaseTest; 159 friend class QuotaDatabaseTest;
128 friend class QuotaManager; 160 friend class QuotaManager;
129 161
162 static const TableSchema kTables[];
163 static const IndexSchema kIndexes[];
164
130 DISALLOW_COPY_AND_ASSIGN(QuotaDatabase); 165 DISALLOW_COPY_AND_ASSIGN(QuotaDatabase);
131 }; 166 };
132 167
133 } // namespace quota 168 } // namespace quota
134 169
135 #endif // WEBKIT_QUOTA_QUOTA_DATABASE_H_ 170 #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