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

Side by Side Diff: chrome/installer/setup/setup_util.cc

Issue 16023027: Lower the I/O priority of the installer when resonable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 file declares util functions for setup project. 5 // This file declares util functions for setup project.
6 6
7 #include "chrome/installer/setup/setup_util.h" 7 #include "chrome/installer/setup/setup_util.h"
8 8
9 #include <windows.h> 9 #include <windows.h>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/process_util.h" 15 #include "base/process_util.h"
16 #include "base/string_util.h" 16 #include "base/string_util.h"
17 #include "base/version.h" 17 #include "base/version.h"
18 #include "base/win/windows_version.h"
18 #include "chrome/installer/util/copy_tree_work_item.h" 19 #include "chrome/installer/util/copy_tree_work_item.h"
19 #include "chrome/installer/util/installation_state.h" 20 #include "chrome/installer/util/installation_state.h"
20 #include "chrome/installer/util/installer_state.h" 21 #include "chrome/installer/util/installer_state.h"
21 #include "chrome/installer/util/master_preferences.h" 22 #include "chrome/installer/util/master_preferences.h"
22 #include "chrome/installer/util/util_constants.h" 23 #include "chrome/installer/util/util_constants.h"
23 #include "chrome/installer/util/work_item.h" 24 #include "chrome/installer/util/work_item.h"
24 #include "courgette/courgette.h" 25 #include "courgette/courgette.h"
25 #include "third_party/bspatch/mbspatch.h" 26 #include "third_party/bspatch/mbspatch.h"
26 27
27 namespace installer { 28 namespace installer {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 is_affected = is_uninstall || !product->HasOption(kOptionReadyMode); 307 is_affected = is_uninstall || !product->HasOption(kOptionReadyMode);
307 } else { 308 } else {
308 is_affected = true; 309 is_affected = true;
309 } 310 }
310 } 311 }
311 312
312 // Decide among {(1),(2),(3),(4)}. 313 // Decide among {(1),(2),(3),(4)}.
313 return is_affected ? !is_uninstall : is_present; 314 return is_affected ? !is_uninstall : is_present;
314 } 315 }
315 316
317 bool AdjustProcessPriority() {
318 if (base::win::GetVersion() > base::win::VERSION_SERVER_2003) {
cpu_(ooo_6.6-7.5) 2013/06/03 19:43:02 can we use VERSION_VISTA ? in general we try our b
grt (UTC plus 2) 2013/06/03 20:13:18 Done.
319 HANDLE current_process = ::GetCurrentProcess();
320 DWORD priority_class = ::GetPriorityClass(current_process);
321 if (priority_class == 0) {
322 PLOG(WARNING) << "Failed to get the process's priority class.";
323 } else if (priority_class == BELOW_NORMAL_PRIORITY_CLASS ||
324 priority_class == IDLE_PRIORITY_CLASS) {
325 BOOL result = ::SetPriorityClass(current_process,
326 PROCESS_MODE_BACKGROUND_BEGIN);
327 PLOG_IF(WARNING, !result) << "Failed to enter background mode.";
328 return !!result;
cpu_(ooo_6.6-7.5) 2013/06/03 19:43:02 note that GetCurrentProcess just returns -1 so it
grt (UTC plus 2) 2013/06/03 20:13:18 Done.
329 }
330 }
331 return false;
332 }
333
316 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) 334 ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name)
317 : is_enabled_(false) { 335 : is_enabled_(false) {
318 if (!::OpenProcessToken(::GetCurrentProcess(), 336 if (!::OpenProcessToken(::GetCurrentProcess(),
319 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, 337 TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
320 token_.Receive())) { 338 token_.Receive())) {
321 return; 339 return;
322 } 340 }
323 341
324 LUID privilege_luid; 342 LUID privilege_luid;
325 if (!::LookupPrivilegeValue(NULL, privilege_name, &privilege_luid)) { 343 if (!::LookupPrivilegeValue(NULL, privilege_name, &privilege_luid)) {
(...skipping 19 matching lines...) Expand all
345 } 363 }
346 364
347 ScopedTokenPrivilege::~ScopedTokenPrivilege() { 365 ScopedTokenPrivilege::~ScopedTokenPrivilege() {
348 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { 366 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) {
349 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, 367 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_,
350 sizeof(TOKEN_PRIVILEGES), NULL, NULL); 368 sizeof(TOKEN_PRIVILEGES), NULL, NULL);
351 } 369 }
352 } 370 }
353 371
354 } // namespace installer 372 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698