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

Side by Side Diff: chrome/browser/search_engines/ui_thread_search_terms_data.cc

Issue 2890943005: Cache the brand code to avoid hundreds of repeated reads. (Closed)
Patch Set: Removed the curly braces to be more consistent with Chromium code. 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 = []() {
80 auto* extracted = new std::string();
81 if (!google_brand::GetBrand(extracted))
82 extracted->clear();
83 return extracted;
84 }();
79 // For organic brandcodes do not use rlz at all. Empty brandcode usually 85 // For organic brandcodes do not use rlz at all. Empty brandcode usually
80 // means a chromium install. This is ok. 86 // means a chromium install. This is ok.
81 std::string brand; 87 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 88 // 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 89 // 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. 90 // search might not send the RLZ data but this is not really a problem.
87 rlz_lib::AccessPoint access_point = rlz::RLZTracker::ChromeOmnibox(); 91 rlz_lib::AccessPoint access_point = rlz::RLZTracker::ChromeOmnibox();
88 if (from_app_list) 92 if (from_app_list)
89 access_point = rlz::RLZTracker::ChromeAppList(); 93 access_point = rlz::RLZTracker::ChromeAppList();
90 rlz::RLZTracker::GetAccessPointRlz(access_point, &rlz_string); 94 rlz::RLZTracker::GetAccessPointRlz(access_point, &rlz_string);
91 } 95 }
92 #endif 96 #endif
93 return rlz_string; 97 return rlz_string;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (!modifier.empty()) 150 if (!modifier.empty())
147 version += " " + modifier; 151 version += " " + modifier;
148 return version; 152 return version;
149 } 153 }
150 154
151 // static 155 // static
152 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) { 156 void UIThreadSearchTermsData::SetGoogleBaseURL(const std::string& base_url) {
153 delete google_base_url_; 157 delete google_base_url_;
154 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url); 158 google_base_url_ = base_url.empty() ? NULL : new std::string(base_url);
155 } 159 }
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