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

Unified Diff: chrome/browser/extensions/activity_log/activity_actions.h

Issue 19234003: Extension activity log database refactoring (step 2) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 5 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
Index: chrome/browser/extensions/activity_log/activity_actions.h
diff --git a/chrome/browser/extensions/activity_log/activity_actions.h b/chrome/browser/extensions/activity_log/activity_actions.h
index 2a5d6366d4252f7bc1d31d7068f0484f921cb8c6..d4ca741051f91d2abea891c23f1cab118a7fe91e 100644
--- a/chrome/browser/extensions/activity_log/activity_actions.h
+++ b/chrome/browser/extensions/activity_log/activity_actions.h
@@ -13,6 +13,7 @@
#include "sql/connection.h"
#include "sql/statement.h"
#include "sql/transaction.h"
+#include "url/gurl.h"
namespace extensions {
@@ -20,10 +21,19 @@ namespace extensions {
// the activity log.
class Action : public base::RefCountedThreadSafe<Action> {
public:
- static const char* kTableBasicFields;
-
- // Initialize the table for a given action type.
- static bool InitializeTableInternal(sql::Connection* db);
+ // Types of log entries that can be stored. The numeric values are stored in
+ // the database, so keep them stable.
+ enum ActionType {
+ ACTION_WEB_REQUEST = 0,
+ ACTION_CONTENT_SCRIPT = 1,
+ ACTION_API_BLOCKED = 2,
+ ACTION_DOM_EVENT = 3,
+ ACTION_DOM_XHR = 4,
+ ACTION_DOM_OTHER = 5,
+ ACTION_API = 6,
+ ACTION_API_URL = 7,
+ ACTION_API_EVENT = 8,
+ };
// Record the action in the database.
virtual bool Record(sql::Connection* db) = 0;
@@ -46,17 +56,6 @@ class Action : public base::RefCountedThreadSafe<Action> {
api::activity_log_private::ExtensionActivity::ActivityType type);
virtual ~Action() {}
- // Initialize the table for a given action type.
- // The content_fields array should list the names of all of the columns in
- // the database. The field_types should specify the types of the corresponding
- // columns (e.g., INTEGER or LONGVARCHAR). There should be the same number of
- // field_types as content_fields, since the two arrays should correspond.
- static bool InitializeTableInternal(sql::Connection* db,
- const char* table_name,
- const char* content_fields[],
- const char* field_types[],
- const int num_content_fields);
-
private:
friend class base::RefCountedThreadSafe<Action>;
@@ -67,6 +66,35 @@ class Action : public base::RefCountedThreadSafe<Action> {
DISALLOW_COPY_AND_ASSIGN(Action);
};
+// This is a temporary class used to represent Actions which have been loaded
+// from the SQLite database. Soon the entire Action hierarchy will be
+// flattened out as the type-specific classes are eliminated, at which time
+// some of the logic here will be moved.
+class WatchdogAction : public Action {
felt 2013/07/16 06:44:03 Is this named WatchdogAction specifically b/c it s
mvrable 2013/07/16 18:12:35 Not any particularly good reason, I just needed an
+ public:
+ WatchdogAction(const std::string& extension_id,
+ const base::Time& time,
+ const ActionType action_type,
+ const std::string& api_name, // full method name
+ scoped_ptr<ListValue> args, // the argument list
+ const GURL& page_url, // page the action occurred on
+ const GURL& arg_url, // URL extracted from the argument list
+ scoped_ptr<DictionaryValue> other); // any extra logging info
+
+ virtual bool Record(sql::Connection* db) OVERRIDE;
+ virtual scoped_ptr<api::activity_log_private::ExtensionActivity>
+ ConvertToExtensionActivity() OVERRIDE;
+ virtual std::string PrintForDebug() OVERRIDE;
+
+ private:
+ ActionType action_type_;
+ std::string api_name_;
+ scoped_ptr<ListValue> args_;
+ GURL page_url_;
+ GURL arg_url_;
+ scoped_ptr<DictionaryValue> other_;
+};
+
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_ACTIVITY_LOG_ACTIVITY_ACTIONS_H_

Powered by Google App Engine
This is Rietveld 408576698