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

Side by Side Diff: chrome/browser/google/google_brand_chromeos.cc

Issue 703623005: cros: Fix unit_tests crashes in GetBrand() on official builders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 52 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
53 g_brand_empty = true; 53 g_brand_empty = true;
54 } 54 }
55 55
56 std::string GetBrand() { 56 std::string GetBrand() {
57 DCHECK(!content::BrowserThread::IsThreadInitialized( 57 DCHECK(!content::BrowserThread::IsThreadInitialized(
58 content::BrowserThread::UI) || 58 content::BrowserThread::UI) ||
59 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 59 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
60 if (g_brand_empty) 60 if (g_brand_empty)
61 return std::string(); 61 return std::string();
62 DCHECK(g_browser_process->local_state()); 62 // Unit tests do not have prefs.
63 if (!g_browser_process->local_state())
64 return std::string();
63 return g_browser_process->local_state()->GetString(prefs::kRLZBrand); 65 return g_browser_process->local_state()->GetString(prefs::kRLZBrand);
64 } 66 }
65 67
66 void InitBrand(const base::Closure& callback) { 68 void InitBrand(const base::Closure& callback) {
67 ::chromeos::system::StatisticsProvider* provider = 69 ::chromeos::system::StatisticsProvider* provider =
68 ::chromeos::system::StatisticsProvider::GetInstance(); 70 ::chromeos::system::StatisticsProvider::GetInstance();
69 std::string brand; 71 std::string brand;
70 const bool found = provider->GetMachineStatistic( 72 const bool found = provider->GetMachineStatistic(
71 ::chromeos::system::kRlzBrandCodeKey, &brand); 73 ::chromeos::system::kRlzBrandCodeKey, &brand);
72 if (found && !brand.empty()) { 74 if (found && !brand.empty()) {
73 SetBrand(callback, brand); 75 SetBrand(callback, brand);
74 return; 76 return;
75 } 77 }
76 78
77 base::PostTaskAndReplyWithResult( 79 base::PostTaskAndReplyWithResult(
78 base::WorkerPool::GetTaskRunner(false /* task_is_slow */).get(), 80 base::WorkerPool::GetTaskRunner(false /* task_is_slow */).get(),
79 FROM_HERE, 81 FROM_HERE,
80 base::Bind(&ReadBrandFromFile), 82 base::Bind(&ReadBrandFromFile),
81 base::Bind(&SetBrand, callback)); 83 base::Bind(&SetBrand, callback));
82 } 84 }
83 85
84 } // namespace chromeos 86 } // namespace chromeos
85 } // namespace google_brand 87 } // namespace google_brand
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