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> |
11 #include <memory> | 11 #include <memory> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
17 #include "base/bind_helpers.h" | 17 #include "base/bind_helpers.h" |
18 #include "base/callback.h" | 18 #include "base/callback.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/values.h" | 20 #include "base/values.h" |
21 #include "chrome/browser/extensions/activity_log/activity_actions.h" | 21 #include "chrome/browser/extensions/activity_log/activity_actions.h" |
22 #include "chrome/browser/extensions/activity_log/activity_database.h" | 22 #include "chrome/browser/extensions/activity_log/activity_database.h" |
| 23 #include "chrome/browser/extensions/activity_log/activity_log_task_runner.h" |
23 #include "chrome/common/extensions/api/activity_log_private.h" | 24 #include "chrome/common/extensions/api/activity_log_private.h" |
24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
25 #include "url/gurl.h" | 26 #include "url/gurl.h" |
26 | 27 |
27 class Profile; | 28 class Profile; |
28 class GURL; | 29 class GURL; |
29 | 30 |
30 namespace base { | 31 namespace base { |
31 class Clock; | 32 class Clock; |
32 class FilePath; | 33 class FilePath; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 virtual void RemoveExtensionData(const std::string& extension_id) = 0; | 186 virtual void RemoveExtensionData(const std::string& extension_id) = 0; |
186 | 187 |
187 // Deletes everything in the database. | 188 // Deletes everything in the database. |
188 virtual void DeleteDatabase() = 0; | 189 virtual void DeleteDatabase() = 0; |
189 | 190 |
190 protected: | 191 protected: |
191 // The Schedule methods dispatch the calls to the database on a | 192 // The Schedule methods dispatch the calls to the database on a |
192 // separate thread. | 193 // separate thread. |
193 template<typename DatabaseType, typename DatabaseFunc> | 194 template<typename DatabaseType, typename DatabaseFunc> |
194 void ScheduleAndForget(DatabaseType db, DatabaseFunc func) { | 195 void ScheduleAndForget(DatabaseType db, DatabaseFunc func) { |
195 content::BrowserThread::PostTask( | 196 GetActivityLogTaskRunner()->PostTask( |
196 content::BrowserThread::DB, FROM_HERE, | 197 FROM_HERE, base::BindOnce(func, base::Unretained(db))); |
197 base::BindOnce(func, base::Unretained(db))); | |
198 } | 198 } |
199 | 199 |
200 template<typename DatabaseType, typename DatabaseFunc, typename ArgA> | 200 template<typename DatabaseType, typename DatabaseFunc, typename ArgA> |
201 void ScheduleAndForget(DatabaseType db, DatabaseFunc func, ArgA a) { | 201 void ScheduleAndForget(DatabaseType db, DatabaseFunc func, ArgA a) { |
202 content::BrowserThread::PostTask( | 202 GetActivityLogTaskRunner()->PostTask( |
203 content::BrowserThread::DB, FROM_HERE, | 203 FROM_HERE, base::BindOnce(func, base::Unretained(db), a)); |
204 base::BindOnce(func, base::Unretained(db), a)); | |
205 } | 204 } |
206 | 205 |
207 template<typename DatabaseType, typename DatabaseFunc, | 206 template<typename DatabaseType, typename DatabaseFunc, |
208 typename ArgA, typename ArgB> | 207 typename ArgA, typename ArgB> |
209 void ScheduleAndForget(DatabaseType db, DatabaseFunc func, ArgA a, ArgB b) { | 208 void ScheduleAndForget(DatabaseType db, DatabaseFunc func, ArgA a, ArgB b) { |
210 content::BrowserThread::PostTask( | 209 GetActivityLogTaskRunner()->PostTask( |
211 content::BrowserThread::DB, FROM_HERE, | 210 FROM_HERE, base::BindOnce(func, base::Unretained(db), a, b)); |
212 base::BindOnce(func, base::Unretained(db), a, b)); | |
213 } | 211 } |
214 | 212 |
215 // Access to the underlying ActivityDatabase. | 213 // Access to the underlying ActivityDatabase. |
216 ActivityDatabase* activity_database() const { return db_; } | 214 ActivityDatabase* activity_database() const { return db_; } |
217 | 215 |
218 // Access to the SQL connection in the ActivityDatabase. This should only be | 216 // Access to the SQL connection in the ActivityDatabase. This should only be |
219 // called from the database thread. May return NULL if the database is not | 217 // called from the database thread. May return NULL if the database is not |
220 // valid. | 218 // valid. |
221 sql::Connection* GetDatabaseConnection() const; | 219 sql::Connection* GetDatabaseConnection() const; |
222 | 220 |
223 private: | 221 private: |
224 // See the comments for the ActivityDatabase class for a discussion of how | 222 // See the comments for the ActivityDatabase class for a discussion of how |
225 // database cleanup runs. | 223 // database cleanup runs. |
226 ActivityDatabase* db_; | 224 ActivityDatabase* db_; |
227 base::FilePath database_path_; | 225 base::FilePath database_path_; |
228 }; | 226 }; |
229 | 227 |
230 } // namespace extensions | 228 } // namespace extensions |
231 | 229 |
232 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ | 230 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_LOG_POLICY_H_ |
OLD | NEW |