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

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

Issue 120983002: Update some uses of UTF conversions in chrome/browser to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 FROM_HERE, 352 FROM_HERE,
353 base::Bind(&RLZTracker::PingNowImpl, base::Unretained(this)), 353 base::Bind(&RLZTracker::PingNowImpl, base::Unretained(this)),
354 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); 354 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
355 } 355 }
356 356
357 void RLZTracker::PingNowImpl() { 357 void RLZTracker::PingNowImpl() {
358 TRACE_EVENT0("RLZ", "RLZTracker::PingNowImpl"); 358 TRACE_EVENT0("RLZ", "RLZTracker::PingNowImpl");
359 base::string16 lang; 359 base::string16 lang;
360 GoogleUpdateSettings::GetLanguage(&lang); 360 GoogleUpdateSettings::GetLanguage(&lang);
361 if (lang.empty()) 361 if (lang.empty())
362 lang = ASCIIToUTF16("en"); 362 lang = base::ASCIIToUTF16("en");
363 base::string16 referral; 363 base::string16 referral;
364 GoogleUpdateSettings::GetReferral(&referral); 364 GoogleUpdateSettings::GetReferral(&referral);
365 365
366 if (!IsBrandOrganic(brand_) && SendFinancialPing(brand_, lang, referral)) { 366 if (!IsBrandOrganic(brand_) && SendFinancialPing(brand_, lang, referral)) {
367 GoogleUpdateSettings::ClearReferral(); 367 GoogleUpdateSettings::ClearReferral();
368 368
369 { 369 {
370 base::AutoLock lock(cache_lock_); 370 base::AutoLock lock(cache_lock_);
371 rlz_cache_.clear(); 371 rlz_cache_.clear();
372 } 372 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 } 487 }
488 488
489 // static 489 // static
490 std::string RLZTracker::GetAccessPointHttpHeader(rlz_lib::AccessPoint point) { 490 std::string RLZTracker::GetAccessPointHttpHeader(rlz_lib::AccessPoint point) {
491 TRACE_EVENT0("RLZ", "RLZTracker::GetAccessPointHttpHeader"); 491 TRACE_EVENT0("RLZ", "RLZTracker::GetAccessPointHttpHeader");
492 std::string extra_headers; 492 std::string extra_headers;
493 base::string16 rlz_string; 493 base::string16 rlz_string;
494 RLZTracker::GetAccessPointRlz(point, &rlz_string); 494 RLZTracker::GetAccessPointRlz(point, &rlz_string);
495 if (!rlz_string.empty()) { 495 if (!rlz_string.empty()) {
496 net::HttpUtil::AppendHeaderIfMissing("X-Rlz-String", 496 net::HttpUtil::AppendHeaderIfMissing("X-Rlz-String",
497 UTF16ToUTF8(rlz_string), 497 base::UTF16ToUTF8(rlz_string),
498 &extra_headers); 498 &extra_headers);
499 } 499 }
500 500
501 return extra_headers; 501 return extra_headers;
502 } 502 }
503 503
504 // GetAccessPointRlz() caches RLZ strings for all access points. If we had 504 // GetAccessPointRlz() caches RLZ strings for all access points. If we had
505 // a successful ping, then we update the cached value. 505 // a successful ping, then we update the cached value.
506 bool RLZTracker::GetAccessPointRlz(rlz_lib::AccessPoint point, 506 bool RLZTracker::GetAccessPointRlz(rlz_lib::AccessPoint point,
507 base::string16* rlz) { 507 base::string16* rlz) {
(...skipping 18 matching lines...) Expand all
526 526
527 // Make sure we don't access disk outside of the I/O thread. 527 // Make sure we don't access disk outside of the I/O thread.
528 // In such case we repost the task on the right thread and return error. 528 // In such case we repost the task on the right thread and return error.
529 if (ScheduleGetAccessPointRlz(point)) 529 if (ScheduleGetAccessPointRlz(point))
530 return false; 530 return false;
531 531
532 char str_rlz[rlz_lib::kMaxRlzLength + 1]; 532 char str_rlz[rlz_lib::kMaxRlzLength + 1];
533 if (!rlz_lib::GetAccessPointRlz(point, str_rlz, rlz_lib::kMaxRlzLength)) 533 if (!rlz_lib::GetAccessPointRlz(point, str_rlz, rlz_lib::kMaxRlzLength))
534 return false; 534 return false;
535 535
536 base::string16 rlz_local(ASCIIToUTF16(std::string(str_rlz))); 536 base::string16 rlz_local(base::ASCIIToUTF16(std::string(str_rlz)));
537 if (rlz) 537 if (rlz)
538 *rlz = rlz_local; 538 *rlz = rlz_local;
539 539
540 base::AutoLock lock(cache_lock_); 540 base::AutoLock lock(cache_lock_);
541 rlz_cache_[point] = rlz_local; 541 rlz_cache_[point] = rlz_local;
542 return true; 542 return true;
543 } 543 }
544 544
545 bool RLZTracker::ScheduleGetAccessPointRlz(rlz_lib::AccessPoint point) { 545 bool RLZTracker::ScheduleGetAccessPointRlz(rlz_lib::AccessPoint point) {
546 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) 546 if (!BrowserThread::CurrentlyOn(BrowserThread::UI))
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 void RLZTracker::CleanupRlz() { 586 void RLZTracker::CleanupRlz() {
587 GetInstance()->rlz_cache_.clear(); 587 GetInstance()->rlz_cache_.clear();
588 GetInstance()->registrar_.RemoveAll(); 588 GetInstance()->registrar_.RemoveAll();
589 rlz_lib::SetURLRequestContext(NULL); 589 rlz_lib::SetURLRequestContext(NULL);
590 } 590 }
591 591
592 // static 592 // static
593 void RLZTracker::EnableZeroDelayForTesting() { 593 void RLZTracker::EnableZeroDelayForTesting() {
594 GetInstance()->min_init_delay_ = base::TimeDelta(); 594 GetInstance()->min_init_delay_ = base::TimeDelta();
595 } 595 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/plugin_info_message_filter_unittest.cc ('k') | chrome/browser/rlz/rlz_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698