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

Unified Diff: chrome/browser/search_engines/ui_thread_search_terms_data.cc

Issue 2891453004: Avoid unnecessary registry/plist reads (hundreds of them) by caching the brand code. (Closed)
Patch Set: Minor change. Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/search_engines/ui_thread_search_terms_data.cc
diff --git a/chrome/browser/search_engines/ui_thread_search_terms_data.cc b/chrome/browser/search_engines/ui_thread_search_terms_data.cc
index 9a31685b52640c5fe56e2d0085624b76c859eb37..cdbb70f5945ded5551db2d4b2f25922c42ce2875 100644
--- a/chrome/browser/search_engines/ui_thread_search_terms_data.cc
+++ b/chrome/browser/search_engines/ui_thread_search_terms_data.cc
@@ -76,11 +76,14 @@ base::string16 UIThreadSearchTermsData::GetRlzParameterValue(
BrowserThread::CurrentlyOn(BrowserThread::UI));
base::string16 rlz_string;
#if BUILDFLAG(ENABLE_RLZ)
+ static std::string* brand = NULL;
grt (UTC plus 2) 2017/05/17 08:45:43 the idiomatic way i've seen to do this sort of one
Boris Vidolov 2017/05/17 18:37:10 Sure. I've seen both and I just used the old-fashi
+ if (!brand) {
+ brand = new std::string();
+ google_brand::GetBrand(brand);
+ }
// For organic brandcodes do not use rlz at all. Empty brandcode usually
// means a chromium install. This is ok.
- std::string brand;
- if (google_brand::GetBrand(&brand) && !brand.empty() &&
- !google_brand::IsOrganic(brand)) {
+ if (!brand->empty() && !google_brand::IsOrganic(*brand)) {
// This call will return false the first time(s) it is called until the
// value has been cached. This normally would mean that at most one omnibox
// search might not send the RLZ data but this is not really a problem.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698