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

Side by Side Diff: chrome/browser/rlz/rlz.cc

Issue 7980013: After a successful ping of the RLZ server, make sure to update the cached (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/rlz/rlz_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This code glues the RLZ library DLL with Chrome. It allows Chrome to work 5 // This code glues the RLZ library DLL with Chrome. It allows Chrome to work
6 // with or without the DLL being present. If the DLL is not present the 6 // with or without the DLL being present. If the DLL is not present the
7 // functions do nothing and just return false. 7 // functions do nothing and just return false.
8 8
9 #include "chrome/browser/rlz/rlz.h" 9 #include "chrome/browser/rlz/rlz.h"
10 10
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 _beginthread(PingNow, 0, this); 239 _beginthread(PingNow, 0, this);
240 } 240 }
241 241
242 // static 242 // static
243 void _cdecl RLZTracker::PingNow(void* arg) { 243 void _cdecl RLZTracker::PingNow(void* arg) {
244 RLZTracker* tracker = reinterpret_cast<RLZTracker*>(arg); 244 RLZTracker* tracker = reinterpret_cast<RLZTracker*>(arg);
245 tracker->PingNowImpl(); 245 tracker->PingNowImpl();
246 } 246 }
247 247
248 void RLZTracker::PingNowImpl() { 248 void RLZTracker::PingNowImpl() {
249 // Needs to be evaluated. See http://crbug.com/62328. 249 // This is the entry point of a background thread, so I/O is allowed.
250 base::ThreadRestrictions::ScopedAllowIO allow_io; 250 base::ThreadRestrictions::ScopedAllowIO allow_io;
251 251
252 std::wstring lang; 252 std::wstring lang;
253 GoogleUpdateSettings::GetLanguage(&lang); 253 GoogleUpdateSettings::GetLanguage(&lang);
254 if (lang.empty()) 254 if (lang.empty())
255 lang = L"en"; 255 lang = L"en";
256 std::wstring brand; 256 std::wstring brand;
257 GoogleUpdateSettings::GetBrand(&brand); 257 GoogleUpdateSettings::GetBrand(&brand);
258 std::wstring referral; 258 std::wstring referral;
259 GoogleUpdateSettings::GetReferral(&referral); 259 GoogleUpdateSettings::GetReferral(&referral);
260 if (SendFinancialPing(brand, lang, referral, is_organic(brand))) { 260 if (SendFinancialPing(brand, lang, referral, is_organic(brand))) {
261 GoogleUpdateSettings::ClearReferral(); 261 GoogleUpdateSettings::ClearReferral();
262 base::AutoLock lock(cache_lock_); 262
263 rlz_cache_.clear(); 263 {
264 base::AutoLock lock(cache_lock_);
265 rlz_cache_.clear();
266 }
267
268 // Prime the RLZ cache for the access points we are interested in.
269 GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, NULL);
270 GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, NULL);
264 } 271 }
265 } 272 }
266 273
267 bool RLZTracker::SendFinancialPing(const std::wstring& brand, 274 bool RLZTracker::SendFinancialPing(const std::wstring& brand,
268 const std::wstring& lang, 275 const std::wstring& lang,
269 const std::wstring& referral, 276 const std::wstring& referral,
270 bool exclude_id) { 277 bool exclude_id) {
271 return ::SendFinancialPing(brand, lang, referral, exclude_id); 278 return ::SendFinancialPing(brand, lang, referral, exclude_id);
272 } 279 }
273 280
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 std::wstring rlz_local(ASCIIToWide(std::string(str_rlz))); 378 std::wstring rlz_local(ASCIIToWide(std::string(str_rlz)));
372 if (rlz) 379 if (rlz)
373 *rlz = rlz_local; 380 *rlz = rlz_local;
374 381
375 base::AutoLock lock(cache_lock_); 382 base::AutoLock lock(cache_lock_);
376 rlz_cache_[point] = rlz_local; 383 rlz_cache_[point] = rlz_local;
377 return true; 384 return true;
378 } 385 }
379 386
380 bool RLZTracker::ScheduleGetAccessPointRlz(rlz_lib::AccessPoint point) { 387 bool RLZTracker::ScheduleGetAccessPointRlz(rlz_lib::AccessPoint point) {
381 if (BrowserThread::CurrentlyOn(BrowserThread::FILE)) 388 if (!BrowserThread::CurrentlyOn(BrowserThread::UI))
382 return false; 389 return false;
383 390
384 std::wstring* not_used = NULL; 391 std::wstring* not_used = NULL;
385 BrowserThread::PostTask( 392 BrowserThread::PostTask(
386 BrowserThread::FILE, FROM_HERE, 393 BrowserThread::FILE, FROM_HERE,
387 NewRunnableFunction(&RLZTracker::GetAccessPointRlz, point, not_used)); 394 NewRunnableFunction(&RLZTracker::GetAccessPointRlz, point, not_used));
388 return true; 395 return true;
389 } 396 }
390 397
391 // static 398 // static
392 void RLZTracker::CleanupRlz() { 399 void RLZTracker::CleanupRlz() {
393 GetInstance()->rlz_cache_.clear(); 400 GetInstance()->rlz_cache_.clear();
394 GetInstance()->registrar_.RemoveAll(); 401 GetInstance()->registrar_.RemoveAll();
395 } 402 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/rlz/rlz_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698