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

Unified Diff: chrome/browser/extensions/api_actions.cc

Issue 11946028: Record event activity to the extension activity log. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased 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/api_actions.h ('k') | chrome/browser/extensions/event_router.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api_actions.cc
diff --git a/chrome/browser/extensions/api_actions.cc b/chrome/browser/extensions/api_actions.cc
index b628afa8384be40c752c9ed2723574b9ba10c4c1..bd94fd259926bb6345097a0e8471bed30b2da0ff 100644
--- a/chrome/browser/extensions/api_actions.cc
+++ b/chrome/browser/extensions/api_actions.cc
@@ -15,6 +15,7 @@ const char* APIAction::kTableName = "activitylog_apis";
const char* APIAction::kTableStructure = "("
"extension_id LONGVARCHAR NOT NULL, "
"time INTEGER NOT NULL, "
+ "api_category LONGVARCHAR NOT NULL, "
felt 2013/01/22 23:02:11 I think that the schema change is good.
"api_action_type LONGVARCHAR NOT NULL, "
"target_type LONGVARCHAR NOT NULL, "
"api_call LONGVARCHAR NOT NULL, "
@@ -22,12 +23,14 @@ const char* APIAction::kTableStructure = "("
APIAction::APIAction(const std::string& extension_id,
const base::Time& time,
+ const APICategory category,
const APIActionType verb,
const APITargetType target,
const std::string& api_call,
const std::string& extra)
: extension_id_(extension_id),
time_(time),
+ category_(category),
verb_(verb),
target_(target),
api_call_(api_call),
@@ -38,16 +41,17 @@ APIAction::~APIAction() {
void APIAction::Record(sql::Connection* db) {
std::string sql_str = "INSERT INTO " + std::string(kTableName)
- + " (extension_id, time, api_action_type, target_type, api_call, extra)"
- " VALUES (?,?,?,?,?,?)";
+ + " (extension_id, time, api_category, api_action_type, target_type,"
+ " api_call, extra) VALUES (?,?,?,?,?,?,?)";
felt 2013/01/22 23:02:11 What happens if you had the table created with the
mvrable 2013/01/23 16:54:07 I've added some code to update the database schema
sql::Statement statement(db->GetCachedStatement(
sql::StatementID(SQL_FROM_HERE), sql_str.c_str()));
statement.BindString(0, extension_id_);
statement.BindInt64(1, time_.ToInternalValue());
- statement.BindString(2, VerbAsString());
- statement.BindString(3, TargetAsString());
- statement.BindString(4, api_call_);
- statement.BindString(5, extra_);
+ statement.BindString(2, CategoryAsString());
+ statement.BindString(3, VerbAsString());
+ statement.BindString(4, TargetAsString());
+ statement.BindString(5, api_call_);
+ statement.BindString(6, extra_);
if (!statement.Run())
LOG(ERROR) << "Activity log database I/O failed: " << sql_str;
@@ -60,8 +64,20 @@ std::string APIAction::PrettyPrintFori18n() {
std::string APIAction::PrettyPrintForDebug() {
// TODO(felt): implement this for real when the UI is redesigned.
- return "ID: " + extension_id_ + ", VERB: " + VerbAsString() +
- ", TARGET: " + TargetAsString() + ", API: " + api_call_;
+ return "ID: " + extension_id_ + + ", CATEGORY: " + CategoryAsString() +
+ ", VERB: " + VerbAsString() + ", TARGET: " + TargetAsString() +
+ ", API: " + api_call_;
+}
+
+std::string APIAction::CategoryAsString() const {
+ switch (category_) {
+ case CALL:
+ return "CALL";
+ case EVENT_CALLBACK:
+ return "EVENT_CALLBACK";
+ default:
+ return "UNKNOWN_CATEGORY";
+ }
}
std::string APIAction::VerbAsString() const {
@@ -106,6 +122,17 @@ std::string APIAction::TargetAsString() const {
}
}
+APIAction::APICategory APIAction::StringAsCategory(
+ const std::string& str) {
+ if (str == "CALL") {
+ return CALL;
+ } else if (str == "EVENT_CALLBACK") {
+ return EVENT_CALLBACK;
+ } else {
+ return UNKNOWN_CATEGORY;
+ }
+}
+
APIAction::APIActionType APIAction::StringAsActionType(
const std::string& str) {
if (str == "READ") {
« no previous file with comments | « chrome/browser/extensions/api_actions.h ('k') | chrome/browser/extensions/event_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698