| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use 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/api_actions.h" | |
| 12 #include "chrome/browser/extensions/blocked_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 void Init(const FilePath& db_name, sql::ErrorDelegate* error_delegate); | |
| 30 void LogInitFailure(); | |
| 31 | |
| 32 // Record a UrlAction in the database. | |
| 33 void RecordUrlAction(scoped_refptr<UrlAction> action); | |
| 34 | |
| 35 // Record a APIAction in the database. | |
| 36 void RecordAPIAction(scoped_refptr<APIAction> action); | |
| 37 | |
| 38 // Record a BlockedAction in the database. | |
| 39 void RecordBlockedAction(scoped_refptr<BlockedAction> action); | |
| 40 | |
| 41 // Record an Action in the database. | |
| 42 void RecordAction(scoped_refptr<Action> action); | |
| 43 | |
| 44 void KillDatabase(); | |
| 45 | |
| 46 bool initialized() const { return initialized_; } | |
| 47 | |
| 48 // Standard db operation wrappers. | |
| 49 void BeginTransaction(); | |
| 50 void CommitTransaction(); | |
| 51 void RollbackTransaction(); | |
| 52 bool Raze(); | |
| 53 void Close(); | |
| 54 | |
| 55 private: | |
| 56 friend class base::RefCountedThreadSafe<ActivityDatabase>; | |
| 57 | |
| 58 virtual ~ActivityDatabase(); | |
| 59 | |
| 60 sql::InitStatus InitializeTable(const char* table_name, | |
| 61 const char* table_structure); | |
| 62 | |
| 63 sql::Connection db_; | |
| 64 bool initialized_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(ActivityDatabase); | |
| 67 }; | |
| 68 | |
| 69 } // namespace extensions | |
| 70 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_ | |
| 71 | |
| OLD | NEW |