Index: chrome/browser/extensions/activity_log/counting_policy.cc |
diff --git a/chrome/browser/extensions/activity_log/counting_policy.cc b/chrome/browser/extensions/activity_log/counting_policy.cc |
index 8c3fbf8158766e467ddde0c5e3f61fead2ada641..1ed675ef2963fcf2bb9f8c64afbcf13286b63afb 100644 |
--- a/chrome/browser/extensions/activity_log/counting_policy.cc |
+++ b/chrome/browser/extensions/activity_log/counting_policy.cc |
@@ -518,6 +518,43 @@ scoped_ptr<Action::ActionVector> CountingPolicy::DoReadFilteredData( |
return actions.Pass(); |
} |
+void CountingPolicy::DoRemoveActions(const std::vector<int64>& action_ids) { |
+ if (action_ids.empty()) |
+ return; |
+ |
+ sql::Connection* db = GetDatabaseConnection(); |
+ if (!db) { |
+ LOG(ERROR) << "Unable to connect to database"; |
+ return; |
+ } |
+ |
+ // Flush data first so the activity removal affects queued-up data as well. |
+ activity_database()->AdviseFlush(ActivityDatabase::kFlushImmediately); |
+ |
+ sql::Transaction transaction(db); |
+ if (!transaction.Begin()) |
+ return; |
+ |
+ for (size_t i = 0; i < action_ids.size(); i++) { |
+ std::string query_str = |
mvrable
2014/02/12 18:38:55
query_str can be moved outside the loop since it d
pmarch
2014/02/12 19:03:23
Done.
|
+ base::StringPrintf("DELETE FROM %s WHERE rowid = ?", kTableName); |
+ sql::Statement query(db->GetCachedStatement(sql::StatementID(SQL_FROM_HERE), |
+ query_str.c_str())); |
+ query.BindInt64(0, action_ids[i]); |
+ if (!query.Run()) { |
+ LOG(ERROR) << "Removing activities from database failed: " |
+ << query.GetSQLStatement(); |
+ break; |
+ } |
+ } |
+ |
+ CleanStringTables(db); |
+ |
+ if (!transaction.Commit()) { |
+ LOG(ERROR) << "Removing activities from database failed"; |
+ } |
+} |
+ |
void CountingPolicy::DoRemoveURLs(const std::vector<GURL>& restrict_urls) { |
sql::Connection* db = GetDatabaseConnection(); |
if (!db) { |
@@ -694,6 +731,10 @@ void CountingPolicy::ReadFilteredData( |
callback); |
} |
+void CountingPolicy::RemoveActions(const std::vector<int64>& action_ids) { |
+ ScheduleAndForget(this, &CountingPolicy::DoRemoveActions, action_ids); |
+} |
+ |
void CountingPolicy::RemoveURLs(const std::vector<GURL>& restrict_urls) { |
ScheduleAndForget(this, &CountingPolicy::DoRemoveURLs, restrict_urls); |
} |