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

Unified Diff: third_party/libaddressinput/chromium/cpp/src/rule.cc

Issue 109323011: [rac] Download all rules for a country code in libaddressinput. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows build. Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/libaddressinput/chromium/cpp/src/rule.cc
diff --git a/third_party/libaddressinput/chromium/cpp/src/rule.cc b/third_party/libaddressinput/chromium/cpp/src/rule.cc
index 1566f646d15366e093d3a438551f172406edf109..5551ed44d19b127d74caa264f52016556703e703 100644
--- a/third_party/libaddressinput/chromium/cpp/src/rule.cc
+++ b/third_party/libaddressinput/chromium/cpp/src/rule.cc
@@ -24,6 +24,7 @@
#include "grit.h"
#include "messages.h"
+#include "region_data_constants.h"
#include "util/json.h"
#include "util/string_split.h"
@@ -32,6 +33,9 @@ namespace addressinput {
namespace {
+// Allocated once and leaked on shutdown.
+static Rule* default_rule = NULL;
+
bool ParseToken(char c, AddressField* field) {
assert(field != NULL);
switch (c) {
@@ -171,6 +175,16 @@ Rule::Rule()
Rule::~Rule() {}
+// static
+const Rule& Rule::GetDefault() {
+ if (default_rule == NULL) {
+ default_rule = new Rule;
+ default_rule->ParseSerializedRule(
+ RegionDataConstants::GetDefaultRegionData());
+ }
+ return *default_rule;
+}
+
void Rule::CopyFrom(const Rule& rule) {
format_ = rule.format_;
required_ = rule.required_;

Powered by Google App Engine
This is Rietveld 408576698