| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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_DATABASE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| 11 #include "chrome/browser/extensions/api_actions.h" | 11 #include "chrome/browser/extensions/api_actions.h" |
| 12 #include "chrome/browser/extensions/blocked_actions.h" | 12 #include "chrome/browser/extensions/blocked_actions.h" |
| 13 #include "chrome/browser/extensions/url_actions.h" | 13 #include "chrome/browser/extensions/url_actions.h" |
| 14 #include "sql/connection.h" | 14 #include "sql/connection.h" |
| 15 #include "sql/init_status.h" | 15 #include "sql/init_status.h" |
| 16 | 16 |
| 17 namespace base { |
| 17 class FilePath; | 18 class FilePath; |
| 19 } |
| 18 | 20 |
| 19 namespace extensions { | 21 namespace extensions { |
| 20 | 22 |
| 21 // Encapsulates the SQL connection for the activity log database. | 23 // Encapsulates the SQL connection for the activity log database. |
| 22 // This class holds the database connection and has methods for writing. | 24 // This class holds the database connection and has methods for writing. |
| 23 class ActivityDatabase : public base::RefCountedThreadSafe<ActivityDatabase> { | 25 class ActivityDatabase : public base::RefCountedThreadSafe<ActivityDatabase> { |
| 24 public: | 26 public: |
| 25 // Need to call Init to actually use the ActivityDatabase. | 27 // Need to call Init to actually use the ActivityDatabase. |
| 26 ActivityDatabase(); | 28 ActivityDatabase(); |
| 27 | 29 |
| 28 // Sets up an optional error delegate. | 30 // Sets up an optional error delegate. |
| 29 // Should be the only thing done before Init. | 31 // Should be the only thing done before Init. |
| 30 void SetErrorDelegate(sql::ErrorDelegate* error_delegate); | 32 void SetErrorDelegate(sql::ErrorDelegate* error_delegate); |
| 31 | 33 |
| 32 // Opens the DB and creates tables as necessary. | 34 // Opens the DB and creates tables as necessary. |
| 33 void Init(const FilePath& db_name); | 35 void Init(const base::FilePath& db_name); |
| 34 void LogInitFailure(); | 36 void LogInitFailure(); |
| 35 | 37 |
| 36 // Record a UrlAction in the database. | 38 // Record a UrlAction in the database. |
| 37 void RecordUrlAction(scoped_refptr<UrlAction> action); | 39 void RecordUrlAction(scoped_refptr<UrlAction> action); |
| 38 | 40 |
| 39 // Record a APIAction in the database. | 41 // Record a APIAction in the database. |
| 40 void RecordAPIAction(scoped_refptr<APIAction> action); | 42 void RecordAPIAction(scoped_refptr<APIAction> action); |
| 41 | 43 |
| 42 // Record a BlockedAction in the database. | 44 // Record a BlockedAction in the database. |
| 43 void RecordBlockedAction(scoped_refptr<BlockedAction> action); | 45 void RecordBlockedAction(scoped_refptr<BlockedAction> action); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 65 const char* table_structure); | 67 const char* table_structure); |
| 66 | 68 |
| 67 sql::Connection db_; | 69 sql::Connection db_; |
| 68 bool initialized_; | 70 bool initialized_; |
| 69 | 71 |
| 70 DISALLOW_COPY_AND_ASSIGN(ActivityDatabase); | 72 DISALLOW_COPY_AND_ASSIGN(ActivityDatabase); |
| 71 }; | 73 }; |
| 72 | 74 |
| 73 } // namespace extensions | 75 } // namespace extensions |
| 74 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_ | 76 #endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_ |
| OLD | NEW |