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

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

Issue 5610002: Don't re-save autofill profiles to the web database if they haven't changed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile. Created 10 years 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
« no previous file with comments | « chrome/browser/webdata/web_database.h ('k') | chrome/browser/webdata/web_database_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_database.h" 5 #include "chrome/browser/webdata/web_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 } 1686 }
1687 1687
1688 while (s.Step()) 1688 while (s.Step())
1689 profiles->push_back(AutoFillProfileFromStatement(s)); 1689 profiles->push_back(AutoFillProfileFromStatement(s));
1690 1690
1691 return s.Succeeded(); 1691 return s.Succeeded();
1692 } 1692 }
1693 1693
1694 bool WebDatabase::UpdateAutoFillProfile(const AutoFillProfile& profile) { 1694 bool WebDatabase::UpdateAutoFillProfile(const AutoFillProfile& profile) {
1695 DCHECK(guid::IsValidGUID(profile.guid())); 1695 DCHECK(guid::IsValidGUID(profile.guid()));
1696
1697 // Preserve appropriate modification dates by not updating unchanged profiles.
1698 AutoFillProfile* tmp_profile;
dhollowa 2010/12/03 16:02:21 Please initialize this to NULL. If the DCHECK fai
Ilya Sherman 2010/12/04 01:47:12 Done.
1699 DCHECK(GetAutoFillProfileForGUID(profile.guid(), &tmp_profile));
1700 scoped_ptr<AutoFillProfile> old_profile(tmp_profile);
1701 if ((*old_profile) == profile)
dhollowa 2010/12/03 16:02:21 Are the extra parens necessary?
Ilya Sherman 2010/12/04 01:47:12 Nah. It's never been clear to me what the style e
1702 return true;
1703
1696 sql::Statement s(db_.GetUniqueStatement( 1704 sql::Statement s(db_.GetUniqueStatement(
1697 "UPDATE autofill_profiles " 1705 "UPDATE autofill_profiles "
1698 "SET guid=?, label=?, first_name=?, middle_name=?, last_name=?, " 1706 "SET guid=?, label=?, first_name=?, middle_name=?, last_name=?, "
1699 " email=?, company_name=?, address_line_1=?, address_line_2=?, " 1707 " email=?, company_name=?, address_line_1=?, address_line_2=?, "
1700 " city=?, state=?, zipcode=?, country=?, phone=?, fax=?, " 1708 " city=?, state=?, zipcode=?, country=?, phone=?, fax=?, "
1701 " date_modified=? " 1709 " date_modified=? "
1702 "WHERE guid=?")); 1710 "WHERE guid=?"));
1703 if (!s) { 1711 if (!s) {
1704 NOTREACHED() << "Statement prepare failed"; 1712 NOTREACHED() << "Statement prepare failed";
1705 return false; 1713 return false;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 } 1814 }
1807 1815
1808 while (s.Step()) 1816 while (s.Step())
1809 credit_cards->push_back(CreditCardFromStatement(s)); 1817 credit_cards->push_back(CreditCardFromStatement(s));
1810 1818
1811 return s.Succeeded(); 1819 return s.Succeeded();
1812 } 1820 }
1813 1821
1814 bool WebDatabase::UpdateCreditCard(const CreditCard& credit_card) { 1822 bool WebDatabase::UpdateCreditCard(const CreditCard& credit_card) {
1815 DCHECK(guid::IsValidGUID(credit_card.guid())); 1823 DCHECK(guid::IsValidGUID(credit_card.guid()));
1824
1825 // Preserve appropriate modification dates by not updating unchanged cards.
1826 CreditCard* tmp_credit_card;
1827 DCHECK(GetCreditCardForGUID(credit_card.guid(), &tmp_credit_card));
1828 scoped_ptr<CreditCard> old_credit_card(tmp_credit_card);
1829 if ((*old_credit_card) == credit_card)
1830 return true;
1831
1816 sql::Statement s(db_.GetUniqueStatement( 1832 sql::Statement s(db_.GetUniqueStatement(
1817 "UPDATE credit_cards " 1833 "UPDATE credit_cards "
1818 "SET guid=?, label=?, name_on_card=?, expiration_month=?, " 1834 "SET guid=?, label=?, name_on_card=?, expiration_month=?, "
1819 " expiration_year=?, card_number_encrypted=?, date_modified=? " 1835 " expiration_year=?, card_number_encrypted=?, date_modified=? "
1820 "WHERE guid=?")); 1836 "WHERE guid=?"));
1821 if (!s) { 1837 if (!s) {
1822 NOTREACHED() << "Statement prepare failed"; 1838 NOTREACHED() << "Statement prepare failed";
1823 return false; 1839 return false;
1824 } 1840 }
1825 1841
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
2557 2573
2558 // Add successive versions here. Each should set the version number and 2574 // Add successive versions here. Each should set the version number and
2559 // compatible version number as appropriate, then fall through to the next 2575 // compatible version number as appropriate, then fall through to the next
2560 // case. 2576 // case.
2561 2577
2562 case kCurrentVersionNumber: 2578 case kCurrentVersionNumber:
2563 // No migration needed. 2579 // No migration needed.
2564 return sql::INIT_OK; 2580 return sql::INIT_OK;
2565 } 2581 }
2566 } 2582 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_database.h ('k') | chrome/browser/webdata/web_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698