Commit 2ca0f9c9 authored by rvargas's avatar rvargas Committed by Commit bot

Remove implicit HANDLE conversions from cloud_print.

BUG=416722
R=gene@chromium.org

Review URL: https://codereview.chromium.org/606443003

Cr-Commit-Position: refs/heads/master@{#296582}
parent a9023056
...@@ -224,7 +224,7 @@ void ChromeLauncher::Run() { ...@@ -224,7 +224,7 @@ void ChromeLauncher::Run() {
DWORD thread_id = 0; DWORD thread_id = 0;
LaunchProcess(cmd, &chrome_handle, &thread_id); LaunchProcess(cmd, &chrome_handle, &thread_id);
HANDLE handles[] = {stop_event_.handle(), chrome_handle}; HANDLE handles[] = { stop_event_.handle(), chrome_handle.Get() };
DWORD wait_result = WAIT_TIMEOUT; DWORD wait_result = WAIT_TIMEOUT;
while (wait_result == WAIT_TIMEOUT) { while (wait_result == WAIT_TIMEOUT) {
cloud_print::SetGoogleUpdateUsage(kGoogleUpdateId); cloud_print::SetGoogleUpdateUsage(kGoogleUpdateId);
...@@ -232,7 +232,7 @@ void ChromeLauncher::Run() { ...@@ -232,7 +232,7 @@ void ChromeLauncher::Run() {
FALSE, kUsageUpdateTimeoutMs); FALSE, kUsageUpdateTimeoutMs);
} }
if (wait_result == WAIT_OBJECT_0) { if (wait_result == WAIT_OBJECT_0) {
ShutdownChrome(chrome_handle, thread_id); ShutdownChrome(chrome_handle.Get(), thread_id);
break; break;
} else if (wait_result == WAIT_OBJECT_0 + 1) { } else if (wait_result == WAIT_OBJECT_0 + 1) {
LOG(ERROR) << "Chrome process exited."; LOG(ERROR) << "Chrome process exited.";
...@@ -302,7 +302,7 @@ std::string ChromeLauncher::CreateServiceStateFile( ...@@ -302,7 +302,7 @@ std::string ChromeLauncher::CreateServiceStateFile(
} }
for (;;) { for (;;) {
DWORD wait_result = ::WaitForSingleObject(chrome_handle, 500); DWORD wait_result = ::WaitForSingleObject(chrome_handle.Get(), 500);
std::string json = ReadAndUpdateServiceState(temp_user_data.path(), std::string json = ReadAndUpdateServiceState(temp_user_data.path(),
proxy_id); proxy_id);
if (wait_result == WAIT_OBJECT_0) { if (wait_result == WAIT_OBJECT_0) {
...@@ -315,7 +315,7 @@ std::string ChromeLauncher::CreateServiceStateFile( ...@@ -315,7 +315,7 @@ std::string ChromeLauncher::CreateServiceStateFile(
} }
if (!json.empty()) { if (!json.empty()) {
// Close chrome because Service State is ready. // Close chrome because Service State is ready.
CloseChrome(chrome_handle, thread_id); CloseChrome(chrome_handle.Get(), thread_id);
return json; return json;
} }
} }
......
...@@ -71,7 +71,7 @@ HRESULT OpenService(const base::string16& name, DWORD access, ...@@ -71,7 +71,7 @@ HRESULT OpenService(const base::string16& name, DWORD access,
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
service->Set(::OpenService(scm, name.c_str(), access)); service->Set(::OpenService(scm.Get(), name.c_str(), access));
if (!service->IsValid()) if (!service->IsValid())
return cloud_print::GetLastHResult(); return cloud_print::GetLastHResult();
...@@ -95,10 +95,10 @@ HRESULT ServiceController::StartService() { ...@@ -95,10 +95,10 @@ HRESULT ServiceController::StartService() {
&service); &service);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
if (!::StartService(service, 0, NULL)) if (!::StartService(service.Get(), 0, NULL))
return cloud_print::GetLastHResult(); return cloud_print::GetLastHResult();
SERVICE_STATUS status = {0}; SERVICE_STATUS status = {0};
while (::QueryServiceStatus(service, &status) && while (::QueryServiceStatus(service.Get(), &status) &&
status.dwCurrentState == SERVICE_START_PENDING) { status.dwCurrentState == SERVICE_START_PENDING) {
Sleep(100); Sleep(100);
} }
...@@ -112,12 +112,12 @@ HRESULT ServiceController::StopService() { ...@@ -112,12 +112,12 @@ HRESULT ServiceController::StopService() {
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
SERVICE_STATUS status = {0}; SERVICE_STATUS status = {0};
if (!::ControlService(service, SERVICE_CONTROL_STOP, &status)) if (!::ControlService(service.Get(), SERVICE_CONTROL_STOP, &status))
return cloud_print::GetLastHResult(); return cloud_print::GetLastHResult();
while (::QueryServiceStatus(service, &status) && while (::QueryServiceStatus(service.Get(), &status) &&
status.dwCurrentState > SERVICE_STOPPED) { status.dwCurrentState > SERVICE_STOPPED) {
Sleep(500); Sleep(500);
::ControlService(service, SERVICE_CONTROL_STOP, &status); ::ControlService(service.Get(), SERVICE_CONTROL_STOP, &status);
} }
return S_OK; return S_OK;
} }
...@@ -197,7 +197,7 @@ HRESULT ServiceController::InstallService(const base::string16& user, ...@@ -197,7 +197,7 @@ HRESULT ServiceController::InstallService(const base::string16& user,
cloud_print::LoadLocalString(IDS_SERVICE_DISPLAY_NAME); cloud_print::LoadLocalString(IDS_SERVICE_DISPLAY_NAME);
ServiceHandle service( ServiceHandle service(
::CreateService( ::CreateService(
scm, name_.c_str(), display_name.c_str(), SERVICE_ALL_ACCESS, scm.Get(), name_.c_str(), display_name.c_str(), SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS, SERVICE_WIN32_OWN_PROCESS,
auto_start ? SERVICE_AUTO_START : SERVICE_DEMAND_START, auto_start ? SERVICE_AUTO_START : SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL, command_line.GetCommandLineString().c_str(), SERVICE_ERROR_NORMAL, command_line.GetCommandLineString().c_str(),
...@@ -213,7 +213,8 @@ HRESULT ServiceController::InstallService(const base::string16& user, ...@@ -213,7 +213,8 @@ HRESULT ServiceController::InstallService(const base::string16& user,
cloud_print::LoadLocalString(IDS_SERVICE_DESCRIPTION); cloud_print::LoadLocalString(IDS_SERVICE_DESCRIPTION);
SERVICE_DESCRIPTION description = {0}; SERVICE_DESCRIPTION description = {0};
description.lpDescription = const_cast<wchar_t*>(description_string.c_str()); description.lpDescription = const_cast<wchar_t*>(description_string.c_str());
::ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &description); ::ChangeServiceConfig2(service.Get(), SERVICE_CONFIG_DESCRIPTION,
&description);
return S_OK; return S_OK;
} }
...@@ -224,8 +225,8 @@ HRESULT ServiceController::UninstallService() { ...@@ -224,8 +225,8 @@ HRESULT ServiceController::UninstallService() {
ServiceHandle service; ServiceHandle service;
OpenService(name_, SERVICE_STOP | DELETE, &service); OpenService(name_, SERVICE_STOP | DELETE, &service);
HRESULT hr = S_FALSE; HRESULT hr = S_FALSE;
if (service) { if (service.IsValid()) {
if (!::DeleteService(service)) { if (!::DeleteService(service.Get())) {
LOG(ERROR) << "Failed to uninstall service"; LOG(ERROR) << "Failed to uninstall service";
hr = cloud_print::GetLastHResult(); hr = cloud_print::GetLastHResult();
} }
...@@ -250,8 +251,8 @@ HRESULT ServiceController::UpdateBinaryPath() { ...@@ -250,8 +251,8 @@ HRESULT ServiceController::UpdateBinaryPath() {
return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
command_line_.SetProgram(service_path); command_line_.SetProgram(service_path);
if (!::ChangeServiceConfig(service, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, if (!::ChangeServiceConfig(service.Get(), SERVICE_NO_CHANGE,
SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE,
command_line_.GetCommandLineString().c_str(), NULL, command_line_.GetCommandLineString().c_str(), NULL,
NULL, NULL, NULL, NULL, NULL)) { NULL, NULL, NULL, NULL, NULL)) {
return cloud_print::GetLastHResult(); return cloud_print::GetLastHResult();
...@@ -284,20 +285,21 @@ void ServiceController::UpdateState() { ...@@ -284,20 +285,21 @@ void ServiceController::UpdateState() {
state_ = STATE_STOPPED; state_ = STATE_STOPPED;
SERVICE_STATUS status = {0}; SERVICE_STATUS status = {0};
if (::QueryServiceStatus(service, &status) && if (::QueryServiceStatus(service.Get(), &status) &&
status.dwCurrentState == SERVICE_RUNNING) { status.dwCurrentState == SERVICE_RUNNING) {
state_ = STATE_RUNNING; state_ = STATE_RUNNING;
} }
DWORD config_size = 0; DWORD config_size = 0;
::QueryServiceConfig(service, NULL, 0, &config_size); ::QueryServiceConfig(service.Get(), NULL, 0, &config_size);
if (!config_size) if (!config_size)
return; return;
std::vector<uint8> buffer(config_size, 0); std::vector<uint8> buffer(config_size, 0);
QUERY_SERVICE_CONFIG* config = QUERY_SERVICE_CONFIG* config =
reinterpret_cast<QUERY_SERVICE_CONFIG*>(&buffer[0]); reinterpret_cast<QUERY_SERVICE_CONFIG*>(&buffer[0]);
if (!::QueryServiceConfig(service, config, buffer.size(), &config_size) || if (!::QueryServiceConfig(service.Get(), config, buffer.size(),
&config_size) ||
config_size != buffer.size()) { config_size != buffer.size()) {
return; return;
} }
......
...@@ -91,7 +91,7 @@ void ServiceListener::Connect() { ...@@ -91,7 +91,7 @@ void ServiceListener::Connect() {
SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION | SECURITY_SQOS_PRESENT | SECURITY_IDENTIFICATION |
FILE_FLAG_OVERLAPPED, NULL)); FILE_FLAG_OVERLAPPED, NULL));
if (handle.IsValid()) { if (handle.IsValid()) {
channel_ = IPC::Channel::CreateClient(IPC::ChannelHandle(handle), channel_ = IPC::Channel::CreateClient(IPC::ChannelHandle(handle.Get()),
this); this);
channel_->Connect(); channel_->Connect();
} else { } else {
......
...@@ -117,7 +117,7 @@ void SetupListener::Connect(const base::string16& user) { ...@@ -117,7 +117,7 @@ void SetupListener::Connect(const base::string16& user) {
IPC::Channel::kReadBufferSize, IPC::Channel::kReadBufferSize,
IPC::Channel::kReadBufferSize, 5000, &attribs)); IPC::Channel::kReadBufferSize, 5000, &attribs));
if (pipe.IsValid()) { if (pipe.IsValid()) {
channel_ = IPC::Channel::CreateServer(IPC::ChannelHandle(pipe), channel_ = IPC::Channel::CreateServer(IPC::ChannelHandle(pipe.Get()),
this); this);
channel_->Connect(); channel_->Connect();
} }
......
...@@ -147,7 +147,7 @@ HRESULT RegisterPortMonitor(bool install, const base::FilePath& install_path) { ...@@ -147,7 +147,7 @@ HRESULT RegisterPortMonitor(bool install, const base::FilePath& install_path) {
DWORD exit_code = S_OK; DWORD exit_code = S_OK;
if (install) { if (install) {
if (!GetExitCodeProcess(regsvr32_handle, &exit_code)) { if (!GetExitCodeProcess(regsvr32_handle.Get(), &exit_code)) {
LOG(ERROR) << "Unable to get regsvr32.exe exit code."; LOG(ERROR) << "Unable to get regsvr32.exe exit code.";
return GetLastHResult(); return GetLastHResult();
} }
......
...@@ -220,7 +220,7 @@ bool LaunchPrintDialog(const base::FilePath& xps_path, ...@@ -220,7 +220,7 @@ bool LaunchPrintDialog(const base::FilePath& xps_path,
command_line.AppendSwitchNative(switches::kCloudPrintFileType, kXpsMimeType); command_line.AppendSwitchNative(switches::kCloudPrintFileType, kXpsMimeType);
command_line.AppendSwitchNative(switches::kCloudPrintJobTitle, job_title); command_line.AppendSwitchNative(switches::kCloudPrintJobTitle, job_title);
base::LaunchOptions options; base::LaunchOptions options;
options.as_user = primary_token_scoped; options.as_user = primary_token_scoped.Get();
base::LaunchProcess(command_line, options, NULL); base::LaunchProcess(command_line, options, NULL);
return true; return true;
} }
...@@ -246,7 +246,7 @@ void LaunchChromeDownloadPage() { ...@@ -246,7 +246,7 @@ void LaunchChromeDownloadPage() {
command_line.AppendArg(kChromeInstallUrl); command_line.AppendArg(kChromeInstallUrl);
base::LaunchOptions options; base::LaunchOptions options;
options.as_user = token_scoped; options.as_user = token_scoped.Get();
base::LaunchProcess(command_line, options, NULL); base::LaunchProcess(command_line, options, NULL);
} }
...@@ -264,7 +264,7 @@ bool ValidateCurrentUser() { ...@@ -264,7 +264,7 @@ bool ValidateCurrentUser() {
if (base::win::GetVersion() >= base::win::VERSION_VISTA) { if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
DWORD session_id = 0; DWORD session_id = 0;
DWORD dummy; DWORD dummy;
if (!GetTokenInformation(token_scoped, if (!GetTokenInformation(token_scoped.Get(),
TokenSessionId, TokenSessionId,
reinterpret_cast<void *>(&session_id), reinterpret_cast<void *>(&session_id),
sizeof(DWORD), sizeof(DWORD),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment