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

Side by Side Diff: chrome/browser/component_updater/recovery_component_installer.cc

Issue 1107963003: [chrome/browser/component_updater] favor DCHECK_CURRENTLY_ON for better logs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased the patch Created 5 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
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 #include "chrome/browser/component_updater/recovery_component_installer.h" 5 #include "chrome/browser/component_updater/recovery_component_installer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 Version current_version_; 197 Version current_version_;
198 PrefService* prefs_; 198 PrefService* prefs_;
199 }; 199 };
200 200
201 void SimulateElevatedRecoveryHelper(PrefService* prefs) { 201 void SimulateElevatedRecoveryHelper(PrefService* prefs) {
202 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, true); 202 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, true);
203 } 203 }
204 204
205 void RecoveryRegisterHelper(ComponentUpdateService* cus, PrefService* prefs) { 205 void RecoveryRegisterHelper(ComponentUpdateService* cus, PrefService* prefs) {
206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 206 DCHECK_CURRENTLY_ON(BrowserThread::UI);
207 Version version(prefs->GetString(prefs::kRecoveryComponentVersion)); 207 Version version(prefs->GetString(prefs::kRecoveryComponentVersion));
208 if (!version.IsValid()) { 208 if (!version.IsValid()) {
209 NOTREACHED(); 209 NOTREACHED();
210 return; 210 return;
211 } 211 }
212 212
213 update_client::CrxComponent recovery; 213 update_client::CrxComponent recovery;
214 recovery.name = "recovery"; 214 recovery.name = "recovery";
215 recovery.installer = new RecoveryComponentInstaller(version, prefs); 215 recovery.installer = new RecoveryComponentInstaller(version, prefs);
216 recovery.version = version; 216 recovery.version = version;
217 recovery.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); 217 recovery.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]);
218 if (cus->RegisterComponent(recovery) != ComponentUpdateService::Status::kOk) { 218 if (cus->RegisterComponent(recovery) != ComponentUpdateService::Status::kOk) {
219 NOTREACHED() << "Recovery component registration failed."; 219 NOTREACHED() << "Recovery component registration failed.";
220 } 220 }
221 } 221 }
222 222
223 void RecoveryUpdateVersionHelper(const Version& version, PrefService* prefs) { 223 void RecoveryUpdateVersionHelper(const Version& version, PrefService* prefs) {
224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 224 DCHECK_CURRENTLY_ON(BrowserThread::UI);
225 prefs->SetString(prefs::kRecoveryComponentVersion, version.GetString()); 225 prefs->SetString(prefs::kRecoveryComponentVersion, version.GetString());
226 } 226 }
227 227
228 void SetPrefsForElevatedRecoveryInstall(const base::FilePath& unpack_path, 228 void SetPrefsForElevatedRecoveryInstall(const base::FilePath& unpack_path,
229 PrefService* prefs) { 229 PrefService* prefs) {
230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 230 DCHECK_CURRENTLY_ON(BrowserThread::UI);
231 prefs->SetFilePath(prefs::kRecoveryComponentUnpackPath, unpack_path); 231 prefs->SetFilePath(prefs::kRecoveryComponentUnpackPath, unpack_path);
232 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, true); 232 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, true);
233 } 233 }
234 234
235 RecoveryComponentInstaller::RecoveryComponentInstaller(const Version& version, 235 RecoveryComponentInstaller::RecoveryComponentInstaller(const Version& version,
236 PrefService* prefs) 236 PrefService* prefs)
237 : current_version_(version), prefs_(prefs) { 237 : current_version_(version), prefs_(prefs) {
238 DCHECK(version.IsValid()); 238 DCHECK(version.IsValid());
239 } 239 }
240 240
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 387 }
388 388
389 void RegisterPrefsForRecoveryComponent(PrefRegistrySimple* registry) { 389 void RegisterPrefsForRecoveryComponent(PrefRegistrySimple* registry) {
390 registry->RegisterStringPref(prefs::kRecoveryComponentVersion, "0.0.0.0"); 390 registry->RegisterStringPref(prefs::kRecoveryComponentVersion, "0.0.0.0");
391 registry->RegisterFilePathPref(prefs::kRecoveryComponentUnpackPath, 391 registry->RegisterFilePathPref(prefs::kRecoveryComponentUnpackPath,
392 base::FilePath()); 392 base::FilePath());
393 registry->RegisterBooleanPref(prefs::kRecoveryComponentNeedsElevation, false); 393 registry->RegisterBooleanPref(prefs::kRecoveryComponentNeedsElevation, false);
394 } 394 }
395 395
396 void AcceptedElevatedRecoveryInstall(PrefService* prefs) { 396 void AcceptedElevatedRecoveryInstall(PrefService* prefs) {
397 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 397 DCHECK_CURRENTLY_ON(BrowserThread::UI);
398 398
399 #if defined(OS_WIN) 399 #if defined(OS_WIN)
400 ElevatedInstallRecoveryComponent( 400 ElevatedInstallRecoveryComponent(
401 prefs->GetFilePath(prefs::kRecoveryComponentUnpackPath)); 401 prefs->GetFilePath(prefs::kRecoveryComponentUnpackPath));
402 #endif // OS_WIN 402 #endif // OS_WIN
403 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); 403 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false);
404 } 404 }
405 405
406 void DeclinedElevatedRecoveryInstall(PrefService* prefs) { 406 void DeclinedElevatedRecoveryInstall(PrefService* prefs) {
407 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 407 DCHECK_CURRENTLY_ON(BrowserThread::UI);
408 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); 408 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false);
409 } 409 }
410 410
411 } // namespace component_updater 411 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698