Index: chrome/browser/extensions/activity_database.h |
=================================================================== |
--- chrome/browser/extensions/activity_database.h (revision 0) |
+++ chrome/browser/extensions/activity_database.h (revision 0) |
@@ -0,0 +1,68 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// User of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_ |
+#define CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_ |
+ |
+#include "base/basictypes.h" |
+#include "base/file_path.h" |
+#include "base/memory/ref_counted_memory.h" |
+#include "chrome/browser/extensions/blocked_actions.h" |
+#include "chrome/browser/extensions/manager_actions.h" |
+#include "chrome/browser/extensions/url_actions.h" |
+#include "sql/connection.h" |
+#include "sql/init_status.h" |
+ |
+class FilePath; |
+ |
+namespace extensions { |
+ |
+// Encapsulates the SQL connection for the activity log database. |
+// This class holds the database connection and has methods for writing. |
+class ActivityDatabase : public base::RefCountedThreadSafe<ActivityDatabase> { |
+ public: |
+ // Need to call Init to actually use the ActivityDatabase. |
+ ActivityDatabase(); |
+ |
+ // Opens the DB and creates tables as necessary. |
+ sql::InitStatus Init(const FilePath& db_name, |
+ sql::ErrorDelegate* error_delegate); |
+ |
+ // Record a UrlAction in the database. |
+ void RecordUrlAction(scoped_refptr<UrlAction> action); |
+ |
+ // Record a ManagerAction in the database. |
+ void RecordManagerAction(scoped_refptr<ManagerAction> action); |
+ |
+ // Record a BlockedAction in the database. |
+ void RecordBlockedAction(scoped_refptr<BlockedAction> action); |
+ |
+ void KillDatabase(); |
+ |
+ bool initialized() const { return initialized_; } |
+ |
+ // Standard db operation wrappers. |
+ void BeginTransaction(); |
+ void CommitTransaction(); |
+ void RollbackTransaction(); |
+ bool Raze(); |
+ void Close(); |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe<ActivityDatabase>; |
+ |
+ sql::Connection db_; |
+ bool initialized_; |
+ |
+ ~ActivityDatabase(); |
+ |
+ // Report a failure in INIT. |
+ sql::InitStatus MarkInitFailure(); |
Eric Dingle
2012/12/13 20:37:34
From the style guide, order of declarations:
Type
felt
2012/12/15 02:51:52
Done.
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(ActivityDatabase); |
+}; |
+ |
+} // namespace |
+#endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_ |
+ |