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

Unified Diff: chrome/browser/extensions/activity_log/counting_policy.cc

Issue 23983014: [Activity Log] when extension is uninstalled, delete data about it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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/counting_policy.cc
diff --git a/chrome/browser/extensions/activity_log/counting_policy.cc b/chrome/browser/extensions/activity_log/counting_policy.cc
index 3c5b737532b05742f7daac77df45c64977bfe696..e634fcb709e0404a5c6770dd6a9370a6009ce748 100644
--- a/chrome/browser/extensions/activity_log/counting_policy.cc
+++ b/chrome/browser/extensions/activity_log/counting_policy.cc
@@ -565,6 +565,37 @@ void CountingPolicy::DoRemoveURLs(const std::vector<GURL>& restrict_urls) {
CleanStringTables(db);
}
+void CountingPolicy::DoRemoveExtensionData(const std::string& extension_id) {
+ if (extension_id.empty())
+ return;
+
+ sql::Connection* db = GetDatabaseConnection();
+ if (!db) {
+ LOG(ERROR) << "Unable to connect to database";
+ return;
+ }
+
+ // Make sure any queued in memory are sent to the database before cleaning.
+ activity_database()->AdviseFlush(ActivityDatabase::kFlushImmediately);
+
+ std::string sql_str = base::StringPrintf(
+ "DELETE FROM %s WHERE extension_id_x=?", kTableName);
+ sql::Statement statement(
+ db->GetCachedStatement(sql::StatementID(SQL_FROM_HERE), sql_str.c_str()));
+ int64 id;
+ if (string_table_.StringToInt(db, extension_id, &id)) {
felt 2013/09/09 14:31:08 Michael, can you check this if-statement? Is the e
mvrable 2013/09/09 17:39:44 The else clause is not needed. All writes to the
felt 2013/09/09 21:19:44 Thanks, changed to a return.
+ statement.BindInt64(0, id);
+ } else {
+ statement.BindString(0, extension_id);
+ }
+ if (!statement.Run()) {
+ LOG(ERROR) << "Removing URLs for extension "
+ << extension_id << "from database failed: "
+ << statement.GetSQLStatement();
+ }
+ CleanStringTables(db);
+}
+
void CountingPolicy::DoDeleteDatabase() {
sql::Connection* db = GetDatabaseConnection();
if (!db) {
@@ -637,6 +668,10 @@ void CountingPolicy::RemoveURLs(const std::vector<GURL>& restrict_urls) {
ScheduleAndForget(this, &CountingPolicy::DoRemoveURLs, restrict_urls);
}
+void CountingPolicy::RemoveExtensionData(const std::string& extension_id) {
+ ScheduleAndForget(this, &CountingPolicy::DoRemoveExtensionData, extension_id);
+}
+
void CountingPolicy::DeleteDatabase() {
ScheduleAndForget(this, &CountingPolicy::DoDeleteDatabase);
}

Powered by Google App Engine
This is Rietveld 408576698