Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // User of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/file_path.h" | |
| 10 #include "base/memory/ref_counted_memory.h" | |
| 11 #include "chrome/browser/extensions/blocked_actions.h" | |
| 12 #include "chrome/browser/extensions/manager_actions.h" | |
| 13 #include "chrome/browser/extensions/url_actions.h" | |
| 14 #include "sql/connection.h" | |
| 15 #include "sql/init_status.h" | |
| 16 | |
| 17 class FilePath; | |
| 18 | |
| 19 namespace extensions { | |
| 20 | |
| 21 // Encapsulates the SQL connection for the activity log database. | |
| 22 // This class holds the database connection and has methods for writing. | |
| 23 class ActivityDatabase : public base::RefCountedThreadSafe<ActivityDatabase> { | |
| 24 public: | |
| 25 // Need to call Init to actually use the ActivityDatabase. | |
| 26 ActivityDatabase(); | |
| 27 | |
| 28 // Opens the DB and creates tables as necessary. | |
| 29 sql::InitStatus Init(const FilePath& db_name, | |
| 30 sql::ErrorDelegate* error_delegate); | |
| 31 | |
| 32 // Record a UrlAction in the database. | |
| 33 void RecordUrlAction(scoped_refptr<UrlAction> action); | |
| 34 | |
| 35 // Record a ManagerAction in the database. | |
| 36 void RecordManagerAction(scoped_refptr<ManagerAction> action); | |
| 37 | |
| 38 // Record a BlockedAction in the database. | |
| 39 void RecordBlockedAction(scoped_refptr<BlockedAction> action); | |
| 40 | |
| 41 void KillDatabase(); | |
| 42 | |
| 43 bool initialized() const { return initialized_; } | |
| 44 | |
| 45 // Standard db operation wrappers. | |
| 46 void BeginTransaction(); | |
| 47 void CommitTransaction(); | |
| 48 void RollbackTransaction(); | |
| 49 bool Raze(); | |
| 50 void Close(); | |
| 51 | |
| 52 private: | |
| 53 friend class base::RefCountedThreadSafe<ActivityDatabase>; | |
| 54 | |
| 55 ~ActivityDatabase(); | |
|
Eric Dingle
2012/12/18 21:55:35
virtual?
felt
2012/12/19 17:56:27
Done.
| |
| 56 | |
| 57 sql::InitStatus InitializeTable(const char* table_name, | |
| 58 const char* table_structure); | |
| 59 | |
| 60 sql::Connection db_; | |
| 61 bool initialized_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(ActivityDatabase); | |
| 64 }; | |
| 65 | |
| 66 } // namespace extensions | |
| 67 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_ | |
| 68 | |
| OLD | NEW |