| Index: chrome/browser/extensions/activity_log/fullstream_ui_policy.cc
|
| diff --git a/chrome/browser/extensions/activity_log/fullstream_ui_policy.cc b/chrome/browser/extensions/activity_log/fullstream_ui_policy.cc
|
| index b2a6737a2bb9d72ac120413209bc5e6d2d30a3ef..d44f62646039908c90f79a0f12c9ad680ab9f5d0 100644
|
| --- a/chrome/browser/extensions/activity_log/fullstream_ui_policy.cc
|
| +++ b/chrome/browser/extensions/activity_log/fullstream_ui_policy.cc
|
| @@ -220,6 +220,63 @@ scoped_ptr<Action::ActionVector> FullStreamUIPolicy::DoReadFilteredData(
|
| return actions.Pass();
|
| }
|
|
|
| +void FullStreamUIPolicy::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);
|
| +
|
| + int batch_size = 50;
|
| + int iter = action_ids.size() / batch_size;
|
| + for (int i = 0; i < iter; i++) {
|
| + int start = i * batch_size;
|
| + int end = start + batch_size;
|
| + std::string rowid_set;
|
| + for (int j = start; j < end; j++) {
|
| + rowid_set += "?,";
|
| + }
|
| + // Delete the last comma from the set.
|
| + rowid_set = rowid_set.substr(0, rowid_set.length() - 1);
|
| + std::string query_str = base::StringPrintf(
|
| + "DELETE FROM %s WHERE rowid in (%s)", kTableName, rowid_set.c_str());
|
| + sql::Statement query(db->GetUniqueStatement(query_str.c_str()));
|
| + for (int j = start; j < end; j++) {
|
| + query.BindInt64(j - start, action_ids[j]);
|
| + }
|
| + if (!query.Run()) {
|
| + LOG(ERROR) << "Removing activities from database failed: "
|
| + << query.GetSQLStatement();
|
| + return;
|
| + }
|
| + }
|
| + int start = iter * batch_size;
|
| + int end = action_ids.size();
|
| + std::string rowid_set;
|
| + for (int i = start; i < end; i++) {
|
| + rowid_set += "?,";
|
| + }
|
| + // Delete the last comma from the set.
|
| + rowid_set = rowid_set.substr(0, rowid_set.length() - 1);
|
| + std::string query_str = base::StringPrintf(
|
| + "DELETE FROM %s WHERE rowid in (%s)", kTableName, rowid_set.c_str());
|
| + sql::Statement query(db->GetUniqueStatement(query_str.c_str()));
|
| + for (int i = start; i < end; i++) {
|
| + query.BindInt64(i - start, action_ids[i]);
|
| + }
|
| + if (!query.Run()) {
|
| + LOG(ERROR) << "Removing activities from database failed: "
|
| + << query.GetSQLStatement();
|
| + return;
|
| + }
|
| +}
|
| +
|
| void FullStreamUIPolicy::DoRemoveURLs(const std::vector<GURL>& restrict_urls) {
|
| sql::Connection* db = GetDatabaseConnection();
|
| if (!db) {
|
| @@ -374,6 +431,10 @@ void FullStreamUIPolicy::ReadFilteredData(
|
| callback);
|
| }
|
|
|
| +void FullStreamUIPolicy::RemoveActions(const std::vector<int64>& action_ids) {
|
| + ScheduleAndForget(this, &FullStreamUIPolicy::DoRemoveActions, action_ids);
|
| +}
|
| +
|
| void FullStreamUIPolicy::RemoveURLs(const std::vector<GURL>& restrict_urls) {
|
| ScheduleAndForget(this, &FullStreamUIPolicy::DoRemoveURLs, restrict_urls);
|
| }
|
|
|