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 CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 186 |
187 // Deletes everything in the database. | 187 // Deletes everything in the database. |
188 virtual void DeleteDatabase() = 0; | 188 virtual void DeleteDatabase() = 0; |
189 | 189 |
190 protected: | 190 protected: |
191 // The Schedule methods dispatch the calls to the database on a | 191 // The Schedule methods dispatch the calls to the database on a |
192 // separate thread. | 192 // separate thread. |
193 template<typename DatabaseType, typename DatabaseFunc> | 193 template<typename DatabaseType, typename DatabaseFunc> |
194 void ScheduleAndForget(DatabaseType db, DatabaseFunc func) { | 194 void ScheduleAndForget(DatabaseType db, DatabaseFunc func) { |
195 content::BrowserThread::PostTask( | 195 content::BrowserThread::PostTask( |
196 content::BrowserThread::DB, | 196 content::BrowserThread::DB, FROM_HERE, |
197 FROM_HERE, | 197 base::BindOnce(func, base::Unretained(db))); |
198 base::Bind(func, base::Unretained(db))); | |
199 } | 198 } |
200 | 199 |
201 template<typename DatabaseType, typename DatabaseFunc, typename ArgA> | 200 template<typename DatabaseType, typename DatabaseFunc, typename ArgA> |
202 void ScheduleAndForget(DatabaseType db, DatabaseFunc func, ArgA a) { | 201 void ScheduleAndForget(DatabaseType db, DatabaseFunc func, ArgA a) { |
203 content::BrowserThread::PostTask( | 202 content::BrowserThread::PostTask( |
204 content::BrowserThread::DB, | 203 content::BrowserThread::DB, FROM_HERE, |
205 FROM_HERE, | 204 base::BindOnce(func, base::Unretained(db), a)); |
206 base::Bind(func, base::Unretained(db), a)); | |
207 } | 205 } |
208 | 206 |
209 template<typename DatabaseType, typename DatabaseFunc, | 207 template<typename DatabaseType, typename DatabaseFunc, |
210 typename ArgA, typename ArgB> | 208 typename ArgA, typename ArgB> |
211 void ScheduleAndForget(DatabaseType db, DatabaseFunc func, ArgA a, ArgB b) { | 209 void ScheduleAndForget(DatabaseType db, DatabaseFunc func, ArgA a, ArgB b) { |
212 content::BrowserThread::PostTask( | 210 content::BrowserThread::PostTask( |
213 content::BrowserThread::DB, | 211 content::BrowserThread::DB, FROM_HERE, |
214 FROM_HERE, | 212 base::BindOnce(func, base::Unretained(db), a, b)); |
215 base::Bind(func, base::Unretained(db), a, b)); | |
216 } | 213 } |
217 | 214 |
218 // Access to the underlying ActivityDatabase. | 215 // Access to the underlying ActivityDatabase. |
219 ActivityDatabase* activity_database() const { return db_; } | 216 ActivityDatabase* activity_database() const { return db_; } |
220 | 217 |
221 // Access to the SQL connection in the ActivityDatabase. This should only be | 218 // Access to the SQL connection in the ActivityDatabase. This should only be |
222 // called from the database thread. May return NULL if the database is not | 219 // called from the database thread. May return NULL if the database is not |
223 // valid. | 220 // valid. |
224 sql::Connection* GetDatabaseConnection() const; | 221 sql::Connection* GetDatabaseConnection() const; |
225 | 222 |
226 private: | 223 private: |
227 // See the comments for the ActivityDatabase class for a discussion of how | 224 // See the comments for the ActivityDatabase class for a discussion of how |
228 // database cleanup runs. | 225 // database cleanup runs. |
229 ActivityDatabase* db_; | 226 ActivityDatabase* db_; |
230 base::FilePath database_path_; | 227 base::FilePath database_path_; |
231 }; | 228 }; |
232 | 229 |
233 } // namespace extensions | 230 } // namespace extensions |
234 | 231 |
235 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ | 232 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ |
OLD | NEW |