Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4720)

Unified Diff: chrome/browser/extensions/activity_database.h

Issue 11421192: Save extension activity log to a file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: something about lkgr Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/activity_actions.h ('k') | chrome/browser/extensions/activity_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,75 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use 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/api_actions.h"
+#include "chrome/browser/extensions/blocked_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();
+
+ // Sets up an optional error delegate.
+ // Should be the only thing done before Init.
+ void SetErrorDelegate(sql::ErrorDelegate* error_delegate);
+
+ // Opens the DB and creates tables as necessary.
+ void Init(const FilePath& db_name);
+ void LogInitFailure();
+
+ // Record a UrlAction in the database.
+ void RecordUrlAction(scoped_refptr<UrlAction> action);
+
+ // Record a APIAction in the database.
+ void RecordAPIAction(scoped_refptr<APIAction> action);
+
+ // Record a BlockedAction in the database.
+ void RecordBlockedAction(scoped_refptr<BlockedAction> action);
+
+ // Record an Action in the database.
+ void RecordAction(scoped_refptr<Action> 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>;
+
+ virtual ~ActivityDatabase();
+
+ sql::InitStatus InitializeTable(const char* table_name,
+ const char* table_structure);
+
+ sql::Connection db_;
+ bool initialized_;
+
+ DISALLOW_COPY_AND_ASSIGN(ActivityDatabase);
+};
+
+} // namespace extensions
+#endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_DATABASE_H_
+
« no previous file with comments | « chrome/browser/extensions/activity_actions.h ('k') | chrome/browser/extensions/activity_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698