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

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

Issue 2548643002: Use TaskScheduler instead of WorkerPool in recovery_component_installer.cc. (Closed)
Patch Set: Created 4 years 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 (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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/base_paths.h" 13 #include "base/base_paths.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
18 #include "base/files/file_util.h" 18 #include "base/files/file_util.h"
19 #include "base/json/json_file_value_serializer.h" 19 #include "base/json/json_file_value_serializer.h"
20 #include "base/logging.h" 20 #include "base/logging.h"
21 #include "base/task_scheduler/post_task.h"
21 #if defined(OS_MACOSX) 22 #if defined(OS_MACOSX)
22 #include "base/mac/authorization_util.h" 23 #include "base/mac/authorization_util.h"
23 #include "base/mac/scoped_authorizationref.h" 24 #include "base/mac/scoped_authorizationref.h"
24 #endif 25 #endif
25 #include "base/metrics/histogram_macros.h" 26 #include "base/metrics/histogram_macros.h"
26 #include "base/path_service.h" 27 #include "base/path_service.h"
27 #include "base/process/kill.h" 28 #include "base/process/kill.h"
28 #include "base/process/launch.h" 29 #include "base/process/launch.h"
29 #include "base/process/process.h" 30 #include "base/process/process.h"
30 #include "base/threading/worker_pool.h"
31 #include "build/build_config.h" 31 #include "build/build_config.h"
32 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
34 #include "components/component_updater/component_updater_paths.h" 34 #include "components/component_updater/component_updater_paths.h"
35 #include "components/component_updater/component_updater_service.h" 35 #include "components/component_updater/component_updater_service.h"
36 #include "components/component_updater/pref_names.h" 36 #include "components/component_updater/pref_names.h"
37 #include "components/prefs/pref_registry_simple.h" 37 #include "components/prefs/pref_registry_simple.h"
38 #include "components/prefs/pref_service.h" 38 #include "components/prefs/pref_service.h"
39 #include "components/update_client/update_client.h" 39 #include "components/update_client/update_client.h"
40 #include "components/update_client/utils.h" 40 #include "components/update_client/utils.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // The child process must print its PID in the first line of its STDOUT. See 217 // The child process must print its PID in the first line of its STDOUT. See
218 // https://cs.chromium.org/chromium/src/base/mac/authorization_util.h?l=8 218 // https://cs.chromium.org/chromium/src/base/mac/authorization_util.h?l=8
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 base::WorkerPool::PostTask( 227 base::PostTaskWithTraits(
228 FROM_HERE, 228 FROM_HERE, base::TaskTraits()
229 base::Bind(&WaitForElevatedInstallToComplete, base::Passed(&process)), 229 .WithShutdownBehavior(
230 true); 230 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
231 .WithPriority(base::TaskPriority::BACKGROUND)
232 .WithWait(),
233 base::Bind(&WaitForElevatedInstallToComplete, base::Passed(&process)));
231 } 234 }
232 235
233 void ElevatedInstallRecoveryComponent(const base::FilePath& installer_path) { 236 void ElevatedInstallRecoveryComponent(const base::FilePath& installer_path) {
234 base::WorkerPool::PostTask( 237 base::PostTaskWithTraits(
235 FROM_HERE, 238 FROM_HERE, base::TaskTraits()
236 base::Bind(&DoElevatedInstallRecoveryComponent, installer_path), 239 .WithShutdownBehavior(
237 true); 240 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
241 .WithPriority(base::TaskPriority::BACKGROUND)
242 .WithFileIO(),
243 base::Bind(&DoElevatedInstallRecoveryComponent, installer_path));
238 } 244 }
239 #endif // defined(OS_WIN) 245 #endif // defined(OS_WIN)
240 246
241 } // namespace 247 } // namespace
242 248
243 // Component installer that is responsible to repair the chrome installation 249 // Component installer that is responsible to repair the chrome installation
244 // or repair the Google update installation. This is a last resort safety 250 // or repair the Google update installation. This is a last resort safety
245 // mechanism. 251 // mechanism.
246 // For user Chrome, recovery component just installs silently. For machine 252 // For user Chrome, recovery component just installs silently. For machine
247 // Chrome, elevation may be needed. If that happens, the installer will set 253 // Chrome, elevation may be needed. If that happens, the installer will set
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 364
359 base::LaunchOptions options; 365 base::LaunchOptions options;
360 #if defined(OS_WIN) 366 #if defined(OS_WIN)
361 options.start_hidden = true; 367 options.start_hidden = true;
362 #endif 368 #endif
363 base::Process process = base::LaunchProcess(cmdline, options); 369 base::Process process = base::LaunchProcess(cmdline, options);
364 if (!process.IsValid()) 370 if (!process.IsValid())
365 return false; 371 return false;
366 372
367 // Let worker pool thread wait for us so we don't block Chrome shutdown. 373 // Let worker pool thread wait for us so we don't block Chrome shutdown.
368 base::WorkerPool::PostTask( 374 base::PostTaskWithTraits(
369 FROM_HERE, 375 FROM_HERE, base::TaskTraits()
370 base::Bind(&WaitForInstallToComplete, 376 .WithShutdownBehavior(
371 base::Passed(&process), installer_folder, prefs_), 377 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
372 true); 378 .WithPriority(base::TaskPriority::BACKGROUND)
379 .WithWait(),
380 base::Bind(&WaitForInstallToComplete, base::Passed(&process),
381 installer_folder, prefs_));
373 382
374 // Returns true regardless of install result since from updater service 383 // Returns true regardless of install result since from updater service
375 // perspective the install is done, even we may need to do elevated 384 // perspective the install is done, even we may need to do elevated
376 // install later. 385 // install later.
377 return true; 386 return true;
378 } 387 }
379 #else 388 #else
380 bool RecoveryComponentInstaller::RunInstallCommand( 389 bool RecoveryComponentInstaller::RunInstallCommand(
381 const base::CommandLine& cmdline, 390 const base::CommandLine& cmdline,
382 const base::FilePath&) const { 391 const base::FilePath&) const {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 #endif // OS_WIN 525 #endif // OS_WIN
517 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); 526 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false);
518 } 527 }
519 528
520 void DeclinedElevatedRecoveryInstall(PrefService* prefs) { 529 void DeclinedElevatedRecoveryInstall(PrefService* prefs) {
521 DCHECK_CURRENTLY_ON(BrowserThread::UI); 530 DCHECK_CURRENTLY_ON(BrowserThread::UI);
522 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); 531 prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false);
523 } 532 }
524 533
525 } // namespace component_updater 534 } // namespace component_updater
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