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

Side by Side Diff: webkit/database/database_tracker.h

Issue 7037018: DB quota (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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 | « content/worker/worker_webkitclient_impl.cc ('k') | webkit/glue/webkitclient_impl.h » ('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_DATABASE_DATABASE_TRACKER_H_ 5 #ifndef WEBKIT_DATABASE_DATABASE_TRACKER_H_
6 #define WEBKIT_DATABASE_DATABASE_TRACKER_H_ 6 #define WEBKIT_DATABASE_DATABASE_TRACKER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 string16 origin_; 64 string16 origin_;
65 int64 total_size_; 65 int64 total_size_;
66 int64 quota_; 66 int64 quota_;
67 DatabaseInfoMap database_info_; 67 DatabaseInfoMap database_info_;
68 }; 68 };
69 69
70 // This class manages the main database, and keeps track of per origin quotas. 70 // This class manages the main database, and keeps track of per origin quotas.
71 // 71 //
72 // The data in this class is not thread-safe, so all methods of this class 72 // The data in this class is not thread-safe, so all methods of this class
73 // should be called on the same thread. The only exception is 73 // should be called on the same thread. The only exceptions are the ctor(),
74 // database_directory() which returns a constant that is initialized when 74 // the dtor() and the database_directory() and quota_manager_proxy() getters.
75 // the DatabaseTracker instance is created.
76 // 75 //
77 // Furthermore, some methods of this class have to read/write data from/to 76 // Furthermore, some methods of this class have to read/write data from/to
78 // the disk. Therefore, in a multi-threaded application, all methods of this 77 // the disk. Therefore, in a multi-threaded application, all methods of this
79 // class should be called on the thread dedicated to file operations (file 78 // class should be called on the thread dedicated to file operations (file
80 // thread in the browser process, for example), if such a thread exists. 79 // thread in the browser process, for example), if such a thread exists.
81 class DatabaseTracker 80 class DatabaseTracker
82 : public base::RefCountedThreadSafe<DatabaseTracker> { 81 : public base::RefCountedThreadSafe<DatabaseTracker> {
83 public: 82 public:
84 class Observer { 83 class Observer {
85 public: 84 public:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 116
118 const FilePath& DatabaseDirectory() const { return db_dir_; } 117 const FilePath& DatabaseDirectory() const { return db_dir_; }
119 FilePath GetFullDBFilePath(const string16& origin_identifier, 118 FilePath GetFullDBFilePath(const string16& origin_identifier,
120 const string16& database_name); 119 const string16& database_name);
121 120
122 // virtual for unittesting only 121 // virtual for unittesting only
123 virtual bool GetOriginInfo(const string16& origin_id, OriginInfo* info); 122 virtual bool GetOriginInfo(const string16& origin_id, OriginInfo* info);
124 virtual bool GetAllOriginIdentifiers(std::vector<string16>* origin_ids); 123 virtual bool GetAllOriginIdentifiers(std::vector<string16>* origin_ids);
125 virtual bool GetAllOriginsInfo(std::vector<OriginInfo>* origins_info); 124 virtual bool GetAllOriginsInfo(std::vector<OriginInfo>* origins_info);
126 125
126 // TODO(michaeln): remove quota related stuff when quota manager
127 // integration is complete
127 void SetOriginQuota(const string16& origin_identifier, int64 new_quota); 128 void SetOriginQuota(const string16& origin_identifier, int64 new_quota);
128 int64 GetDefaultQuota() { return default_quota_; } 129 int64 GetDefaultQuota() { return default_quota_; }
129 // Sets the default quota for all origins. Should be used in tests only. 130 void SetDefaultQuota(int64 quota); // for testing
130 void SetDefaultQuota(int64 quota); 131
132 // Safe to call on any thread.
133 quota::QuotaManagerProxy* quota_manager_proxy() const {
134 return quota_manager_proxy_.get();
135 }
131 136
132 bool IsDatabaseScheduledForDeletion(const string16& origin_identifier, 137 bool IsDatabaseScheduledForDeletion(const string16& origin_identifier,
133 const string16& database_name); 138 const string16& database_name);
134 139
135 // Deletes a single database. Returns net::OK on success, net::FAILED on 140 // Deletes a single database. Returns net::OK on success, net::FAILED on
136 // failure, or net::ERR_IO_PENDING and |callback| is invoked upon completion, 141 // failure, or net::ERR_IO_PENDING and |callback| is invoked upon completion,
137 // if non-NULL. 142 // if non-NULL.
138 int DeleteDatabase(const string16& origin_identifier, 143 int DeleteDatabase(const string16& origin_identifier,
139 const string16& database_name, 144 const string16& database_name,
140 net::CompletionCallback* callback); 145 net::CompletionCallback* callback);
141 146
142 // Delete any databases that have been touched since the cutoff date that's 147 // Delete any databases that have been touched since the cutoff date that's
143 // supplied, omitting any that match IDs within |protected_origins|. 148 // supplied, omitting any that match IDs within |protected_origins|.
144 // Returns net::OK on success, net::FAILED if not all databases could be 149 // Returns net::OK on success, net::FAILED if not all databases could be
145 // deleted, and net::ERR_IO_PENDING and |callback| is invoked upon completion, 150 // deleted, and net::ERR_IO_PENDING and |callback| is invoked upon completion,
146 // if non-NULL. Protected origins, according the the SpecialStoragePolicy, 151 // if non-NULL. Protected origins, according the the SpecialStoragePolicy,
147 // are not deleted by this method. 152 // are not deleted by this method.
148 int DeleteDataModifiedSince(const base::Time& cutoff, 153 int DeleteDataModifiedSince(const base::Time& cutoff,
149 net::CompletionCallback* callback); 154 net::CompletionCallback* callback);
150 155
151 // Delete all databases that belong to the given origin. Returns net::OK on 156 // Delete all databases that belong to the given origin. Returns net::OK on
152 // success, net::FAILED if not all databases could be deleted, and 157 // success, net::FAILED if not all databases could be deleted, and
153 // net::ERR_IO_PENDING and |callback| is invoked upon completion, if non-NULL. 158 // net::ERR_IO_PENDING and |callback| is invoked upon completion, if non-NULL.
154 int DeleteDataForOrigin(const string16& origin_identifier, 159 // virtual for unit testing only
155 net::CompletionCallback* callback); 160 virtual int DeleteDataForOrigin(const string16& origin_identifier,
161 net::CompletionCallback* callback);
156 162
157 bool IsIncognitoProfile() const { return is_incognito_; } 163 bool IsIncognitoProfile() const { return is_incognito_; }
158 164
159 void GetIncognitoFileHandle(const string16& vfs_file_path, 165 void GetIncognitoFileHandle(const string16& vfs_file_path,
160 base::PlatformFile* file_handle) const; 166 base::PlatformFile* file_handle) const;
161 void SaveIncognitoFileHandle(const string16& vfs_file_path, 167 void SaveIncognitoFileHandle(const string16& vfs_file_path,
162 const base::PlatformFile& file_handle); 168 const base::PlatformFile& file_handle);
163 bool CloseIncognitoFileHandle(const string16& vfs_file_path); 169 bool CloseIncognitoFileHandle(const string16& vfs_file_path);
164 bool HasSavedIncognitoFileHandle(const string16& vfs_file_path) const; 170 bool HasSavedIncognitoFileHandle(const string16& vfs_file_path) const;
165 171
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // this map to assign directory names that do not reveal this information. 276 // this map to assign directory names that do not reveal this information.
271 OriginDirectoriesMap incognito_origin_directories_; 277 OriginDirectoriesMap incognito_origin_directories_;
272 int incognito_origin_directories_generator_; 278 int incognito_origin_directories_generator_;
273 279
274 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper); 280 FRIEND_TEST_ALL_PREFIXES(DatabaseTracker, TestHelper);
275 }; 281 };
276 282
277 } // namespace webkit_database 283 } // namespace webkit_database
278 284
279 #endif // WEBKIT_DATABASE_DATABASE_TRACKER_H_ 285 #endif // WEBKIT_DATABASE_DATABASE_TRACKER_H_
OLDNEW
« no previous file with comments | « content/worker/worker_webkitclient_impl.cc ('k') | webkit/glue/webkitclient_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698