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

Side by Side Diff: chrome/installer/util/user_experiment.cc

Issue 606473002: Remove implicit HANDLE conversions from chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/installer/util/user_experiment.h" 5 #include "chrome/installer/util/user_experiment.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <sddl.h> 8 #include <sddl.h>
9 #include <wtsapi32.h> 9 #include <wtsapi32.h>
10 #include <vector> 10 #include <vector>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Returns -1 if there was an error retrieving the directory time. 77 // Returns -1 if there was an error retrieving the directory time.
78 int GetDirectoryWriteTimeInHours(const wchar_t* path) { 78 int GetDirectoryWriteTimeInHours(const wchar_t* path) {
79 // To open a directory you need to pass FILE_FLAG_BACKUP_SEMANTICS. 79 // To open a directory you need to pass FILE_FLAG_BACKUP_SEMANTICS.
80 DWORD share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; 80 DWORD share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
81 base::win::ScopedHandle file(::CreateFileW(path, 0, share, NULL, 81 base::win::ScopedHandle file(::CreateFileW(path, 0, share, NULL,
82 OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL)); 82 OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL));
83 if (!file.IsValid()) 83 if (!file.IsValid())
84 return -1; 84 return -1;
85 85
86 FILETIME time; 86 FILETIME time;
87 return ::GetFileTime(file, NULL, NULL, &time) ? FileTimeToHours(time) : -1; 87 return ::GetFileTime(file.Get(), NULL, NULL, &time) ?
88 FileTimeToHours(time) : -1;
Lei Zhang 2014/09/24 23:10:10 nit: indent 4 spaces from "return" ?
rvargas (doing something else) 2014/09/24 23:58:46 yeah, I've always hated indenting under a return a
88 } 89 }
89 90
90 // Returns the time in hours since the last write to the user data directory. 91 // Returns the time in hours since the last write to the user data directory.
91 // A return value of 14 means that the directory was last written 14 hours ago. 92 // A return value of 14 means that the directory was last written 14 hours ago.
92 // Returns -1 if there was an error retrieving the directory. 93 // Returns -1 if there was an error retrieving the directory.
93 int GetUserDataDirectoryWriteAgeInHours() { 94 int GetUserDataDirectoryWriteAgeInHours() {
94 base::FilePath user_data_dir; 95 base::FilePath user_data_dir;
95 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) 96 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir))
96 return -1; 97 return -1;
97 int dir_time = GetDirectoryWriteTimeInHours(user_data_dir.value().c_str()); 98 int dir_time = GetDirectoryWriteTimeInHours(user_data_dir.value().c_str());
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 outcome = kToastExpTriesOkGroup; 507 outcome = kToastExpTriesOkGroup;
507 break; 508 break;
508 case chrome::RESULT_CODE_NORMAL_EXIT_CANCEL: 509 case chrome::RESULT_CODE_NORMAL_EXIT_CANCEL:
509 outcome = kToastExpCancelGroup; 510 outcome = kToastExpCancelGroup;
510 break; 511 break;
511 case chrome::RESULT_CODE_NORMAL_EXIT_EXP2: 512 case chrome::RESULT_CODE_NORMAL_EXIT_EXP2:
512 outcome = kToastExpUninstallGroup; 513 outcome = kToastExpUninstallGroup;
513 break; 514 break;
514 default: 515 default:
515 outcome = kToastExpTriesErrorGroup; 516 outcome = kToastExpTriesErrorGroup;
516 }; 517 }
517 // Write to the |client| key for the last time. 518 // Write to the |client| key for the last time.
518 SetClient(experiment_group + outcome, true); 519 SetClient(experiment_group + outcome, true);
519 520
520 if (outcome != kToastExpUninstallGroup) 521 if (outcome != kToastExpUninstallGroup)
521 return; 522 return;
522 // The user wants to uninstall. This is a best effort operation. Note that 523 // The user wants to uninstall. This is a best effort operation. Note that
523 // we waited for chrome to exit so the uninstall would not detect chrome 524 // we waited for chrome to exit so the uninstall would not detect chrome
524 // running. 525 // running.
525 bool system_level_toast = CommandLine::ForCurrentProcess()->HasSwitch( 526 bool system_level_toast = CommandLine::ForCurrentProcess()->HasSwitch(
526 switches::kSystemLevelToast); 527 switches::kSystemLevelToast);
527 528
528 CommandLine cmd(InstallUtil::GetChromeUninstallCmd( 529 CommandLine cmd(InstallUtil::GetChromeUninstallCmd(
529 system_level_toast, product.distribution()->GetType())); 530 system_level_toast, product.distribution()->GetType()));
530 base::LaunchProcess(cmd, base::LaunchOptions(), NULL); 531 base::LaunchProcess(cmd, base::LaunchOptions(), NULL);
531 } 532 }
532 533
533 } // namespace installer 534 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698