summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-01 01:55:55 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-01 01:55:55 +0000
commita153d452308b3ce34183908c36a899d3aa45a7b9 (patch)
tree8ddb519f09e4c43eb830d2213838940203260cf5
parente830ab8f5a757935ad0256c1798474008f18a922 (diff)
downloadchromium_src-a153d452308b3ce34183908c36a899d3aa45a7b9.zip
chromium_src-a153d452308b3ce34183908c36a899d3aa45a7b9.tar.gz
chromium_src-a153d452308b3ce34183908c36a899d3aa45a7b9.tar.bz2
fix jstemplate_builder::UseVersion2
realized the old implementation was over-complicated and could fail if two objects had interleaved, rather than nested, scope. BUG=none TEST=manual Review URL: http://codereview.chromium.org/10269008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134663 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/jstemplate_builder.cc10
-rw-r--r--chrome/common/jstemplate_builder.h2
2 files changed, 5 insertions, 7 deletions
diff --git a/chrome/common/jstemplate_builder.cc b/chrome/common/jstemplate_builder.cc
index eb95674..9d0d46b 100644
--- a/chrome/common/jstemplate_builder.cc
+++ b/chrome/common/jstemplate_builder.cc
@@ -16,19 +16,19 @@
namespace {
-// True when building version 2 templates. See UseVersion2 class.
-bool g_version2 = false;
+// Non-zero when building version 2 templates. See UseVersion2 class.
+int g_version2 = 0;
} // namespace
namespace jstemplate_builder {
-UseVersion2::UseVersion2() : previous_value_(g_version2) {
- g_version2 = true;
+UseVersion2::UseVersion2() {
+ g_version2++;
}
UseVersion2::~UseVersion2() {
- g_version2 = previous_value_;
+ g_version2--;
}
std::string GetTemplateHtml(const base::StringPiece& html_template,
diff --git a/chrome/common/jstemplate_builder.h b/chrome/common/jstemplate_builder.h
index e925349..19afbc0 100644
--- a/chrome/common/jstemplate_builder.h
+++ b/chrome/common/jstemplate_builder.h
@@ -33,8 +33,6 @@ class UseVersion2 {
~UseVersion2();
private:
- bool previous_value_;
-
DISALLOW_COPY_AND_ASSIGN(UseVersion2);
};