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

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: Fixed clang 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::RemoveFormElementsAccessedBefore(const Time& delete_end) {
519 GenericRequest<Time>* request =
520 new GenericRequest<Time>(this, GetNextRequestHandle(), NULL, delete_end);
521 RegisterRequest(request);
522 ScheduleTask(FROM_HERE,
523 Bind(&WebDataService::RemoveFormElementsAccessedBeforeImpl,
524 this, request));
525 }
Ilya Sherman 2012/03/15 21:00:41 I like exposing this API to clients of the WDS --
GeorgeY 2012/03/17 00:36:16 There are different functions: one removes all tim
Ilya Sherman 2012/03/19 21:12:51 Ok, that makes sense. Please add a TODO to refact
526
518 void WebDataService::RemoveFormValueForElementName( 527 void WebDataService::RemoveFormValueForElementName(
519 const string16& name, const string16& value) { 528 const string16& name, const string16& value) {
520 GenericRequest2<string16, string16>* request = 529 GenericRequest2<string16, string16>* request =
521 new GenericRequest2<string16, string16>(this, 530 new GenericRequest2<string16, string16>(this,
522 GetNextRequestHandle(), 531 GetNextRequestHandle(),
523 NULL, 532 NULL,
524 name, value); 533 name, value);
525 RegisterRequest(request); 534 RegisterRequest(request);
526 ScheduleTask(FROM_HERE, 535 ScheduleTask(FROM_HERE,
527 Bind(&WebDataService::RemoveFormValueForElementNameImpl, 536 Bind(&WebDataService::RemoveFormValueForElementNameImpl,
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED, 1260 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1252 content::Source<WebDataService>(this), 1261 content::Source<WebDataService>(this),
1253 content::Details<AutofillChangeList>(&changes)); 1262 content::Details<AutofillChangeList>(&changes));
1254 } 1263 }
1255 ScheduleCommit(); 1264 ScheduleCommit();
1256 } 1265 }
1257 } 1266 }
1258 request->RequestComplete(); 1267 request->RequestComplete();
1259 } 1268 }
1260 1269
1270 void WebDataService::RemoveFormElementsAccessedBeforeImpl(
1271 GenericRequest<Time>* request) {
1272 InitializeDatabaseIfNecessary();
1273 if (db_ && !request->IsCancelled(NULL)) {
1274 AutofillChangeList changes;
1275 if (db_->GetAutofillTable()->RemoveFormElementsAccessedBefore(
1276 request->arg(), &changes)) {
1277 if (!changes.empty()) {
1278 request->SetResult(
1279 new WDResult<AutofillChangeList>(AUTOFILL_CHANGES, changes));
1280
1281 // Post the notifications including the list of affected keys.
1282 // This is sent here so that work resulting from this notification
1283 // will be done on the DB thread, and not the UI thread.
1284 content::NotificationService::current()->Notify(
1285 chrome::NOTIFICATION_AUTOFILL_ENTRIES_CHANGED,
1286 content::Source<WebDataService>(this),
1287 content::Details<AutofillChangeList>(&changes));
1288 }
1289 ScheduleCommit();
1290 }
1291 }
1292 request->RequestComplete();
1293 }
1294
1261 void WebDataService::RemoveFormValueForElementNameImpl( 1295 void WebDataService::RemoveFormValueForElementNameImpl(
1262 GenericRequest2<string16, string16>* request) { 1296 GenericRequest2<string16, string16>* request) {
1263 InitializeDatabaseIfNecessary(); 1297 InitializeDatabaseIfNecessary();
1264 if (db_ && !request->IsCancelled(NULL)) { 1298 if (db_ && !request->IsCancelled(NULL)) {
1265 const string16& name = request->arg1(); 1299 const string16& name = request->arg1();
1266 const string16& value = request->arg2(); 1300 const string16& value = request->arg2();
1267 1301
1268 if (db_->GetAutofillTable()->RemoveFormElement(name, value)) { 1302 if (db_->GetAutofillTable()->RemoveFormElement(name, value)) {
1269 AutofillChangeList changes; 1303 AutofillChangeList changes;
1270 changes.push_back(AutofillChange(AutofillChange::REMOVE, 1304 changes.push_back(AutofillChange(AutofillChange::REMOVE,
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 } 1654 }
1621 1655
1622 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const { 1656 const WDTypedResult* WebDataService::WebDataRequest::GetResult() const {
1623 return result_; 1657 return result_;
1624 } 1658 }
1625 1659
1626 void WebDataService::WebDataRequest::RequestComplete() { 1660 void WebDataService::WebDataRequest::RequestComplete() {
1627 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted, 1661 message_loop_->PostTask(FROM_HERE, Bind(&WebDataService::RequestCompleted,
1628 service_.get(), handle_)); 1662 service_.get(), handle_));
1629 } 1663 }
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