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

Side by Side Diff: chrome/browser/webdata/web_data_service.cc

Issue 9585020: Cull autofill entries older than 60 days. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comments Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/webdata/web_data_service.h" 5 #include "chrome/browser/webdata/web_data_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 GetNextRequestHandle(), 508 GetNextRequestHandle(),
509 NULL, 509 NULL,
510 delete_begin, 510 delete_begin,
511 delete_end); 511 delete_end);
512 RegisterRequest(request); 512 RegisterRequest(request);
513 ScheduleTask(FROM_HERE, 513 ScheduleTask(FROM_HERE,
514 Bind(&WebDataService::RemoveFormElementsAddedBetweenImpl, 514 Bind(&WebDataService::RemoveFormElementsAddedBetweenImpl,
515 this, request)); 515 this, request));
516 } 516 }
517 517
518 void WebDataService::RemoveExpiredFormElements() {
519 GenericRequest<Time>* request =
520 new GenericRequest<Time>(this, GetNextRequestHandle(), NULL,
521 AutofillEntry::ExpirationTime());
522 RegisterRequest(request);
523 ScheduleTask(FROM_HERE,
524 Bind(&WebDataService::RemoveExpiredFormElementsImpl,
525 this, request));
526 }
527
518 void WebDataService::RemoveFormValueForElementName( 528 void WebDataService::RemoveFormValueForElementName(
519 const string16& name, const string16& value) { 529 const string16& name, const string16& value) {
520 GenericRequest2<string16, string16>* request = 530 GenericRequest2<string16, string16>* request =
521 new GenericRequest2<string16, string16>(this, 531 new GenericRequest2<string16, string16>(this,
522 GetNextRequestHandle(), 532 GetNextRequestHandle(),
523 NULL, 533 NULL,
524 name, value); 534 name, value);
525 RegisterRequest(request); 535 RegisterRequest(request);
526 ScheduleTask(FROM_HERE, 536 ScheduleTask(FROM_HERE,
527 Bind(&WebDataService::RemoveFormValueForElementNameImpl, 537 Bind(&WebDataService::RemoveFormValueForElementNameImpl,
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1261 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1252 content::Source<WebDataService>(this), 1262 content::Source<WebDataService>(this),
1253 content::Details<AutofillChangeList>(&changes)); 1263 content::Details<AutofillChangeList>(&changes));
1254 } 1264 }
1255 ScheduleCommit(); 1265 ScheduleCommit();
1256 } 1266 }
1257 } 1267 }
1258 request->RequestComplete(); 1268 request->RequestComplete();
1259 } 1269 }
1260 1270
1271 void WebDataService::RemoveExpiredFormElementsImpl(
1272 GenericRequest<Time>* request) {
1273 InitializeDatabaseIfNecessary();
1274 if (db_ && !request->IsCancelled(NULL)) {
1275 AutofillChangeList changes;
1276 if (db_->GetAutofillTable()->RemoveExpiredFormElements(
1277 request->arg(), &changes)) {
1278 if (!changes.empty()) {
1279 request->SetResult(
1280 new WDResult<AutofillChangeList>(AUTOFILL_CHANGES, changes));
1281
1282 // Post the notifications including the list of affected keys.
1283 // This is sent here so that work resulting from this notification
1284 // will be done on the DB thread, and not the UI thread.
1285 content::NotificationService::current()->Notify(
1286 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1287 content::Source<WebDataService>(this),
1288 content::Details<AutofillChangeList>(&changes));
1289 }
1290 ScheduleCommit();
1291 }
1292 }
1293 request->RequestComplete();
1294 }
1295
1261 void WebDataService::RemoveFormValueForElementNameImpl( 1296 void WebDataService::RemoveFormValueForElementNameImpl(
1262 GenericRequest2<string16, string16>* request) { 1297 GenericRequest2<string16, string16>* request) {
1263 InitializeDatabaseIfNecessary(); 1298 InitializeDatabaseIfNecessary();
1264 if (db_ && !request->IsCancelled(NULL)) { 1299 if (db_ && !request->IsCancelled(NULL)) {
1265 const string16& name = request->arg1(); 1300 const string16& name = request->arg1();
1266 const string16& value = request->arg2(); 1301 const string16& value = request->arg2();
1267 1302
1268 if (db_->GetAutofillTable()->RemoveFormElement(name, value)) { 1303 if (db_->GetAutofillTable()->RemoveFormElement(name, value)) {
1269 AutofillChangeList changes; 1304 AutofillChangeList changes;
1270 changes.push_back(AutofillChange(AutofillChange::REMOVE, 1305 changes.push_back(AutofillChange(AutofillChange::REMOVE,
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 } 1655 }
1621 1656
1622 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { 1657 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const {
1623 return result_; 1658 return result_;
1624 } 1659 }
1625 1660
1626 void WebDataService::WebDataRequest::RequestComplete() { 1661 void WebDataService::WebDataRequest::RequestComplete() {
1627 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, 1662 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted,
1628 service_.get(), handle_)); 1663 service_.get(), handle_));
1629 } 1664 }
OLDNEW
« chrome/browser/webdata/autofill_table.cc ('K') | « chrome/browser/webdata/web_data_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698