| OLD | NEW |
| 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 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // for more details. When |pid| cannot be determined, we are not able to | 219 // for more details. When |pid| cannot be determined, we are not able to |
| 220 // get process exit code, thus bail out early. | 220 // get process exit code, thus bail out early. |
| 221 if (pid < 0) { | 221 if (pid < 0) { |
| 222 RecordRecoveryComponentUMAEvent(RCE_ELEVATED_UNKNOWN_RESULT); | 222 RecordRecoveryComponentUMAEvent(RCE_ELEVATED_UNKNOWN_RESULT); |
| 223 return; | 223 return; |
| 224 } | 224 } |
| 225 base::Process process = base::Process::Open(pid); | 225 base::Process process = base::Process::Open(pid); |
| 226 #endif | 226 #endif |
| 227 // This task joins a process, hence .WithBaseSyncPrimitives(). | 227 // This task joins a process, hence .WithBaseSyncPrimitives(). |
| 228 base::PostTaskWithTraits( | 228 base::PostTaskWithTraits( |
| 229 FROM_HERE, base::TaskTraits() | 229 FROM_HERE, |
| 230 .WithShutdownBehavior( | 230 {base::WithBaseSyncPrimitives(), base::TaskPriority::BACKGROUND, |
| 231 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | 231 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, |
| 232 .WithPriority(base::TaskPriority::BACKGROUND) | |
| 233 .WithBaseSyncPrimitives(), | |
| 234 base::Bind(&WaitForElevatedInstallToComplete, base::Passed(&process))); | 232 base::Bind(&WaitForElevatedInstallToComplete, base::Passed(&process))); |
| 235 } | 233 } |
| 236 | 234 |
| 237 void ElevatedInstallRecoveryComponent(const base::FilePath& installer_path) { | 235 void ElevatedInstallRecoveryComponent(const base::FilePath& installer_path) { |
| 238 base::PostTaskWithTraits( | 236 base::PostTaskWithTraits( |
| 239 FROM_HERE, base::TaskTraits() | 237 FROM_HERE, |
| 240 .WithShutdownBehavior( | 238 {base::MayBlock(), base::TaskPriority::BACKGROUND, |
| 241 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | 239 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, |
| 242 .WithPriority(base::TaskPriority::BACKGROUND) | |
| 243 .MayBlock(), | |
| 244 base::Bind(&DoElevatedInstallRecoveryComponent, installer_path)); | 240 base::Bind(&DoElevatedInstallRecoveryComponent, installer_path)); |
| 245 } | 241 } |
| 246 | 242 |
| 247 } // namespace | 243 } // namespace |
| 248 | 244 |
| 249 // Component installer that is responsible to repair the chrome installation | 245 // Component installer that is responsible to repair the chrome installation |
| 250 // or repair the Google update installation. This is a last resort safety | 246 // or repair the Google update installation. This is a last resort safety |
| 251 // mechanism. | 247 // mechanism. |
| 252 // For user Chrome, recovery component just installs silently. For machine | 248 // For user Chrome, recovery component just installs silently. For machine |
| 253 // Chrome, elevation may be needed. If that happens, the installer will set | 249 // Chrome, elevation may be needed. If that happens, the installer will set |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 #if defined(OS_WIN) | 361 #if defined(OS_WIN) |
| 366 options.start_hidden = true; | 362 options.start_hidden = true; |
| 367 #endif | 363 #endif |
| 368 base::Process process = base::LaunchProcess(cmdline, options); | 364 base::Process process = base::LaunchProcess(cmdline, options); |
| 369 if (!process.IsValid()) | 365 if (!process.IsValid()) |
| 370 return false; | 366 return false; |
| 371 | 367 |
| 372 // Let worker pool thread wait for us so we don't block Chrome shutdown. | 368 // Let worker pool thread wait for us so we don't block Chrome shutdown. |
| 373 // This task joins a process, hence .WithBaseSyncPrimitives(). | 369 // This task joins a process, hence .WithBaseSyncPrimitives(). |
| 374 base::PostTaskWithTraits( | 370 base::PostTaskWithTraits( |
| 375 FROM_HERE, base::TaskTraits() | 371 FROM_HERE, |
| 376 .WithShutdownBehavior( | 372 {base::WithBaseSyncPrimitives(), base::TaskPriority::BACKGROUND, |
| 377 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | 373 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, |
| 378 .WithPriority(base::TaskPriority::BACKGROUND) | |
| 379 .WithBaseSyncPrimitives(), | |
| 380 base::Bind(&WaitForInstallToComplete, base::Passed(&process), | 374 base::Bind(&WaitForInstallToComplete, base::Passed(&process), |
| 381 installer_folder, prefs_)); | 375 installer_folder, prefs_)); |
| 382 | 376 |
| 383 // Returns true regardless of install result since from updater service | 377 // Returns true regardless of install result since from updater service |
| 384 // perspective the install is done, even we may need to do elevated | 378 // perspective the install is done, even we may need to do elevated |
| 385 // install later. | 379 // install later. |
| 386 return true; | 380 return true; |
| 387 } | 381 } |
| 388 | 382 |
| 389 #if defined(OS_POSIX) | 383 #if defined(OS_POSIX) |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 | 520 |
| 527 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); | 521 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); |
| 528 } | 522 } |
| 529 | 523 |
| 530 void DeclinedElevatedRecoveryInstall(PrefService* prefs) { | 524 void DeclinedElevatedRecoveryInstall(PrefService* prefs) { |
| 531 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 525 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 532 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); | 526 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); |
| 533 } | 527 } |
| 534 | 528 |
| 535 } // namespace component_updater | 529 } // namespace component_updater |
| OLD | NEW |