summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/phone_number_i18n.h
diff options
context:
space:
mode:
authorgeorgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-24 21:06:25 +0000
committergeorgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-24 21:06:25 +0000
commit35734e958a211a628446c9f89fa379b8c96d52a6 (patch)
tree683abf962cab684b79669da33e75936eb75c1d95 /chrome/browser/autofill/phone_number_i18n.h
parentcc87500b3429b8a31b2c60729be4248c3b562f85 (diff)
downloadchromium_src-35734e958a211a628446c9f89fa379b8c96d52a6.zip
chromium_src-35734e958a211a628446c9f89fa379b8c96d52a6.tar.gz
chromium_src-35734e958a211a628446c9f89fa379b8c96d52a6.tar.bz2
Another performance improvement for phone library - at least +25% to previous cl (982ms for 100 items DB test comared to 1251ms)
But feels like much more as the penalty shifted to DB thread. TEST=The caching object is tested by multiple AutofillManager, PersonalDataManager, etc. unittests + new unit-test to test performance. BUG=85152 Review URL: http://codereview.chromium.org/7044102 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/phone_number_i18n.h')
-rw-r--r--chrome/browser/autofill/phone_number_i18n.h38
1 files changed, 37 insertions, 1 deletions
diff --git a/chrome/browser/autofill/phone_number_i18n.h b/chrome/browser/autofill/phone_number_i18n.h
index 9d75cab..a8ecef7 100644
--- a/chrome/browser/autofill/phone_number_i18n.h
+++ b/chrome/browser/autofill/phone_number_i18n.h
@@ -10,10 +10,16 @@
#include <vector>
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
-// Utilities to process, normalize and compare international phone numbers.
+namespace i18n {
+namespace phonenumbers {
+class PhoneNumber;
+}
+}
+// Utilities to process, normalize and compare international phone numbers.
namespace autofill_i18n {
// Most of the following functions require |locale| to operate. The |locale| is
@@ -88,6 +94,36 @@ bool PhoneNumbersMatch(const string16& number_a,
const string16& number_b,
const std::string& country_code);
+// The cached phone number, does parsing only once, improves performance.
+class PhoneObject {
+ public:
+ PhoneObject(const string16& number, const std::string& locale);
+ PhoneObject(const PhoneObject&);
+ PhoneObject();
+ ~PhoneObject();
+
+ string16 GetCountryCode() const { return country_code_; }
+ string16 GetCityCode() const { return city_code_; }
+ string16 GetNumber() const { return number_; }
+ std::string GetLocale() const { return locale_; }
+
+ string16 GetWholeNumber() const;
+
+ PhoneMatch ComparePhones(const string16& phone) const;
+
+ PhoneObject& operator=(const PhoneObject& other);
+
+ bool IsValidNumber() const { return i18n_number_ != NULL; }
+
+ private:
+ string16 city_code_;
+ string16 country_code_;
+ string16 number_;
+ mutable string16 whole_number_; // Set on first request.
+ std::string locale_;
+ scoped_ptr<i18n::phonenumbers::PhoneNumber> i18n_number_;
+};
+
} // namespace autofill_i18n
#endif // CHROME_BROWSER_AUTOFILL_PHONE_NUMBER_I18N_H_