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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" 5 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 // Android implementations are in ui_thread_search_terms_data_android.cc. 71 // Android implementations are in ui_thread_search_terms_data_android.cc.
72 #if !defined(OS_ANDROID) 72 #if !defined(OS_ANDROID)
73 base::string16 UIThreadSearchTermsData::GetRlzParameterValue( 73 base::string16 UIThreadSearchTermsData::GetRlzParameterValue(
74 bool from_app_list) const { 74 bool from_app_list) const {
75 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || 75 DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) ||
76 BrowserThread::CurrentlyOn(BrowserThread::UI)); 76 BrowserThread::CurrentlyOn(BrowserThread::UI));
77 base::string16 rlz_string; 77 base::string16 rlz_string;
78 #if BUILDFLAG(ENABLE_RLZ) 78 #if BUILDFLAG(ENABLE_RLZ)
79 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
80 if (!brand) {
81 brand = new std::string();
82 google_brand::GetBrand(brand);
83 }
79 // For organic brandcodes do not use rlz at all. Empty brandcode usually 84 // For organic brandcodes do not use rlz at all. Empty brandcode usually
80 // means a chromium install. This is ok. 85 // means a chromium install. This is ok.
81 std::string brand; 86 if (!brand->empty() && !google_brand::IsOrganic(*brand)) {
82 if (google_brand::GetBrand(&brand) && !brand.empty() &&
83 !google_brand::IsOrganic(brand)) {
84 // This call will return false the first time(s) it is called until the 87 // This call will return false the first time(s) it is called until the
85 // value has been cached. This normally would mean that at most one omnibox 88 // value has been cached. This normally would mean that at most one omnibox
86 // search might not send the RLZ data but this is not really a problem. 89 // search might not send the RLZ data but this is not really a problem.
87 rlz_lib::AccessPoint access_point = rlz::RLZTracker::ChromeOmnibox(); 90 rlz_lib::AccessPoint access_point = rlz::RLZTracker::ChromeOmnibox();
88 if (from_app_list) 91 if (from_app_list)
89 access_point = rlz::RLZTracker::ChromeAppList(); 92 access_point = rlz::RLZTracker::ChromeAppList();
90 rlz::RLZTracker::GetAccessPointRlz(access_point, &rlz_string); 93 rlz::RLZTracker::GetAccessPointRlz(access_point, &rlz_string);
91 } 94 }
92 #endif 95 #endif
93 return rlz_string; 96 return rlz_string;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (!modifier.empty()) 149 if (!modifier.empty())
147 version += " " + modifier; 150 version += " " + modifier;
148 return version; 151 return version;
149 } 152 }
150 153
151 // static 154 // static
152 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { 155 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) {
153 delete google_base_url_; 156 delete google_base_url_;
154 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); 157 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url);
155 } 158 }
OLDNEW
« 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