Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4686)

Issue 5918044: Remove a static initializer from rlz. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 1 month ago by thakis
Modified:
12 years, 1 month ago
Reviewers:
Roger Tawa
CC:
rlz-codereviews_googlegroups.com
Base URL:
https://rlz.googlecode.com/svn/trunk
Visibility:
Public.

Description

Remove a static initializer from rlz. BUG=chromium:120335

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+11 lines, -7 lines) Patch
M lib/rlz_lib.h View 1 chunk +1 line, -3 lines 0 comments Download
M lib/rlz_lib.cc View 3 chunks +10 lines, -4 lines 0 comments Download

Messages

Total messages: 2
thakis
12 years, 1 month ago (2012-03-27 02:42:18 UTC) #1
Roger Tawa
12 years, 1 month ago (2012-03-27 13:56:28 UTC) #2
Lgtm
On Mar 26, 2012 10:42 PM, <thakis@chromium.org> wrote:

> Reviewers: rogerta1,
>
> Description:
> Remove a static initializer from rlz.
>
> BUG=chromium:120335
>
>
> Please review this at
https://codereview.appspot.**com/5918044/<https://codereview.appspot.com/5918...
>
> Affected files:
>  M lib/rlz_lib.cc
>  M lib/rlz_lib.h
>
>
> Index: lib/rlz_lib.cc
> diff --git a/lib/rlz_lib.cc b/lib/rlz_lib.cc
> index 233f52d291d16fa9a7a5a832a60e0c**d67397f001..**
> 67168e5f4fc2d5b6ae2a283098c86f**27756acef3 100644
> --- a/lib/rlz_lib.cc
> +++ b/lib/rlz_lib.cc
> @@ -7,6 +7,7 @@
>
>  #include "rlz/lib/rlz_lib.h"
>
> +#include "base/lazy_instance.h"
>  #include "base/string_util.h"
>  #include "base/stringprintf.h"
>  #include "rlz/lib/assert.h"
> @@ -682,12 +683,14 @@ bool GetPingParams(Product product, const
> AccessPoint* access_points,
>   return true;
>  }
>
> +static base::LazyInstance<std::**string>::Leaky g_supplemental_branding;
> +
>  SupplementaryBranding::**SupplementaryBranding(const char* brand)
>     : lock_(new ScopedRlzValueStoreLock) {
>   if (!lock_->GetStore())
>     return;
>
> -  if (!brand_.empty()) {
> +  if (!g_supplemental_branding.Get(**).empty()) {
>     ASSERT_STRING("**ProductBranding: existing brand is not empty");
>     return;
>   }
> @@ -697,15 +700,18 @@ SupplementaryBranding::**SupplementaryBranding(const
> char* brand)
>     return;
>   }
>
> -  brand_ = brand;
> +  g_supplemental_branding.Get() = brand;
>  }
>
>  SupplementaryBranding::~**SupplementaryBranding() {
>   if (lock_->GetStore())
> -    brand_.clear();
> +    g_supplemental_branding.Get().**clear();
>   delete lock_;
>  }
>
> -std::string SupplementaryBranding::brand_;
> +// static
> +const std::string& SupplementaryBranding::**GetBrand() {
> +  return g_supplemental_branding.Get();
> +}
>
>  }  // namespace rlz_lib
> Index: lib/rlz_lib.h
> diff --git a/lib/rlz_lib.h b/lib/rlz_lib.h
> index 0a8f5119dad380a0019c538ba711bb**af9bd1037e..**
> 129f35a6c972e7e1a4f0e47954f9c8**cba887b3b6 100644
> --- a/lib/rlz_lib.h
> +++ b/lib/rlz_lib.h
> @@ -324,12 +324,10 @@ class SupplementaryBranding {
>   SupplementaryBranding(const char* brand);
>   ~SupplementaryBranding();
>
> -  static const std::string& GetBrand() { return brand_; }
> +  static const std::string& GetBrand();
>
>  private:
>   ScopedRlzValueStoreLock* lock_;
> -
> -  static std::string brand_;
>  };
>
>  }  // namespace rlz_lib
>
>
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b