Commit d7743bab authored by rvargas's avatar rvargas Committed by Commit bot

Remove implicit HANDLE conversions from chrome.

BUG=416722
R=thestig@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#296613}
parent ae685fa4
...@@ -227,7 +227,7 @@ bool ImagePreReader::PartialPreReadImageOnDisk(const wchar_t* file_path, ...@@ -227,7 +227,7 @@ bool ImagePreReader::PartialPreReadImageOnDisk(const wchar_t* file_path,
headers.reserve(kMinHeaderBufferSize); headers.reserve(kMinHeaderBufferSize);
// Read, hopefully, all of the headers. // Read, hopefully, all of the headers.
if (!ReadMissingBytes(file, &headers, kMinHeaderBufferSize)) if (!ReadMissingBytes(file.Get(), &headers, kMinHeaderBufferSize))
return false; return false;
// The DOS header starts at offset 0 and allows us to get the offset of the // The DOS header starts at offset 0 and allows us to get the offset of the
...@@ -235,7 +235,7 @@ bool ImagePreReader::PartialPreReadImageOnDisk(const wchar_t* file_path, ...@@ -235,7 +235,7 @@ bool ImagePreReader::PartialPreReadImageOnDisk(const wchar_t* file_path,
size_t nt_headers_start = size_t nt_headers_start =
reinterpret_cast<IMAGE_DOS_HEADER*>(&headers[0])->e_lfanew; reinterpret_cast<IMAGE_DOS_HEADER*>(&headers[0])->e_lfanew;
size_t nt_headers_end = nt_headers_start + sizeof(IMAGE_NT_HEADERS); size_t nt_headers_end = nt_headers_start + sizeof(IMAGE_NT_HEADERS);
if (!ReadMissingBytes(file, &headers, nt_headers_end)) if (!ReadMissingBytes(file.Get(), &headers, nt_headers_end))
return false; return false;
// Now that we've got the NT headers we can get the total header size, // Now that we've got the NT headers we can get the total header size,
...@@ -243,7 +243,7 @@ bool ImagePreReader::PartialPreReadImageOnDisk(const wchar_t* file_path, ...@@ -243,7 +243,7 @@ bool ImagePreReader::PartialPreReadImageOnDisk(const wchar_t* file_path,
// to capture all of the header data. // to capture all of the header data.
size_t size_of_headers = reinterpret_cast<IMAGE_NT_HEADERS*>( size_t size_of_headers = reinterpret_cast<IMAGE_NT_HEADERS*>(
&headers[nt_headers_start])->OptionalHeader.SizeOfHeaders; &headers[nt_headers_start])->OptionalHeader.SizeOfHeaders;
if (!ReadMissingBytes(file, &headers, size_of_headers)) if (!ReadMissingBytes(file.Get(), &headers, size_of_headers))
return false; return false;
// Now we have all of the headers. This is enough to let us use the PEImage // Now we have all of the headers. This is enough to let us use the PEImage
...@@ -263,9 +263,10 @@ bool ImagePreReader::PartialPreReadImageOnDisk(const wchar_t* file_path, ...@@ -263,9 +263,10 @@ bool ImagePreReader::PartialPreReadImageOnDisk(const wchar_t* file_path,
for (UINT i = 0; (section = pe_image.GetSectionHeader(i)) != NULL; ++i) { for (UINT i = 0; (section = pe_image.GetSectionHeader(i)) != NULL; ++i) {
CHECK_LE(reinterpret_cast<const uint8*>(section + 1), CHECK_LE(reinterpret_cast<const uint8*>(section + 1),
&headers[0] + headers.size()); &headers[0] + headers.size());
if (!ReadThroughSection( if (!ReadThroughSection(file.Get(), section, percentage, buffer.get(),
file, section, percentage, buffer.get(), max_chunk_size)) max_chunk_size)) {
return false; return false;
}
} }
// We're done. // We're done.
...@@ -357,7 +358,7 @@ bool ImagePreReader::PreReadImage(const wchar_t* file_path, ...@@ -357,7 +358,7 @@ bool ImagePreReader::PreReadImage(const wchar_t* file_path,
DWORD len; DWORD len;
size_t total_read = 0; size_t total_read = 0;
while (::ReadFile(file, buffer, actual_step_size, &len, NULL) && while (::ReadFile(file.Get(), buffer, actual_step_size, &len, NULL) &&
len > 0 && len > 0 &&
(size_to_read ? total_read < size_to_read : true)) { (size_to_read ? total_read < size_to_read : true)) {
total_read += static_cast<size_t>(len); total_read += static_cast<size_t>(len);
......
...@@ -69,7 +69,7 @@ bool AddDeviceInfo(HANDLE interface_enumerator, ...@@ -69,7 +69,7 @@ bool AddDeviceInfo(HANDLE interface_enumerator,
0, // No optional flags. 0, // No optional flags.
NULL)); // No template file. NULL)); // No template file.
if (!device_handle) { if (!device_handle.IsValid()) {
PLOG(ERROR) << "Opening device handle failed."; PLOG(ERROR) << "Opening device handle failed.";
return false; return false;
} }
...@@ -77,7 +77,7 @@ bool AddDeviceInfo(HANDLE interface_enumerator, ...@@ -77,7 +77,7 @@ bool AddDeviceInfo(HANDLE interface_enumerator,
DISK_GEOMETRY geometry; DISK_GEOMETRY geometry;
DWORD bytes_returned; DWORD bytes_returned;
status = DeviceIoControl( status = DeviceIoControl(
device_handle, // Device handle. device_handle.Get(), // Device handle.
IOCTL_DISK_GET_DRIVE_GEOMETRY, // Flag to request disk size. IOCTL_DISK_GET_DRIVE_GEOMETRY, // Flag to request disk size.
NULL, // Optional additional parameters. NULL, // Optional additional parameters.
0, // Optional parameter size. 0, // Optional parameter size.
...@@ -103,7 +103,7 @@ bool AddDeviceInfo(HANDLE interface_enumerator, ...@@ -103,7 +103,7 @@ bool AddDeviceInfo(HANDLE interface_enumerator,
scoped_ptr<char[]> output_buf(new char[1024]); scoped_ptr<char[]> output_buf(new char[1024]);
status = DeviceIoControl( status = DeviceIoControl(
device_handle, // Device handle. device_handle.Get(), // Device handle.
IOCTL_STORAGE_QUERY_PROPERTY, // Flag to request device properties. IOCTL_STORAGE_QUERY_PROPERTY, // Flag to request device properties.
&query, // Query parameters. &query, // Query parameters.
sizeof(STORAGE_PROPERTY_QUERY), // query parameters size. sizeof(STORAGE_PROPERTY_QUERY), // query parameters size.
...@@ -131,7 +131,7 @@ bool AddDeviceInfo(HANDLE interface_enumerator, ...@@ -131,7 +131,7 @@ bool AddDeviceInfo(HANDLE interface_enumerator,
// Create a drive identifier from the drive number. // Create a drive identifier from the drive number.
STORAGE_DEVICE_NUMBER device_number = {0}; STORAGE_DEVICE_NUMBER device_number = {0};
status = DeviceIoControl( status = DeviceIoControl(
device_handle, // Device handle. device_handle.Get(), // Device handle.
IOCTL_STORAGE_GET_DEVICE_NUMBER,// Flag to request device number. IOCTL_STORAGE_GET_DEVICE_NUMBER,// Flag to request device number.
NULL, // Query parameters, should be NULL. NULL, // Query parameters, should be NULL.
0, // Query parameters size, should be 0. 0, // Query parameters size, should be 0.
......
...@@ -264,7 +264,7 @@ bool SwapNewChromeExeIfPresent() { ...@@ -264,7 +264,7 @@ bool SwapNewChromeExeIfPresent() {
options.start_hidden = true; options.start_hidden = true;
if (base::LaunchProcess(rename_cmd, options, &handle)) { if (base::LaunchProcess(rename_cmd, options, &handle)) {
DWORD exit_code; DWORD exit_code;
::GetExitCodeProcess(handle, &exit_code); ::GetExitCodeProcess(handle.Get(), &exit_code);
if (exit_code == installer::RENAME_SUCCESSFUL) if (exit_code == installer::RENAME_SUCCESSFUL)
return true; return true;
} }
......
...@@ -85,7 +85,7 @@ void MemoryDetails::CollectProcessData( ...@@ -85,7 +85,7 @@ void MemoryDetails::CollectProcessData(
LOG(ERROR) << "CreateToolhelp32Snaphot failed: " << GetLastError(); LOG(ERROR) << "CreateToolhelp32Snaphot failed: " << GetLastError();
return; return;
} }
if (!::Process32First(snapshot, &process_entry)) { if (!::Process32First(snapshot.Get(), &process_entry)) {
LOG(ERROR) << "Process32First failed: " << GetLastError(); LOG(ERROR) << "Process32First failed: " << GetLastError();
return; return;
} }
...@@ -93,12 +93,12 @@ void MemoryDetails::CollectProcessData( ...@@ -93,12 +93,12 @@ void MemoryDetails::CollectProcessData(
base::ProcessId pid = process_entry.th32ProcessID; base::ProcessId pid = process_entry.th32ProcessID;
base::win::ScopedHandle process_handle(::OpenProcess( base::win::ScopedHandle process_handle(::OpenProcess(
PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)); PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid));
if (!process_handle.Get()) if (!process_handle.IsValid())
continue; continue;
bool is_64bit_process = bool is_64bit_process =
((windows_architecture == base::win::OSInfo::X64_ARCHITECTURE) || ((windows_architecture == base::win::OSInfo::X64_ARCHITECTURE) ||
(windows_architecture == base::win::OSInfo::IA64_ARCHITECTURE)) && (windows_architecture == base::win::OSInfo::IA64_ARCHITECTURE)) &&
(base::win::OSInfo::GetWOW64StatusForProcess(process_handle) == (base::win::OSInfo::GetWOW64StatusForProcess(process_handle.Get()) ==
base::win::OSInfo::WOW64_DISABLED); base::win::OSInfo::WOW64_DISABLED);
for (unsigned int index2 = 0; index2 < process_data_.size(); index2++) { for (unsigned int index2 = 0; index2 < process_data_.size(); index2++) {
if (_wcsicmp(process_data_[index2].process_name.c_str(), if (_wcsicmp(process_data_[index2].process_name.c_str(),
...@@ -115,7 +115,8 @@ void MemoryDetails::CollectProcessData( ...@@ -115,7 +115,8 @@ void MemoryDetails::CollectProcessData(
info.process_type = content::PROCESS_TYPE_UNKNOWN; info.process_type = content::PROCESS_TYPE_UNKNOWN;
scoped_ptr<base::ProcessMetrics> metrics; scoped_ptr<base::ProcessMetrics> metrics;
metrics.reset(base::ProcessMetrics::CreateProcessMetrics(process_handle)); metrics.reset(base::ProcessMetrics::CreateProcessMetrics(
process_handle.Get()));
metrics->GetCommittedKBytes(&info.committed); metrics->GetCommittedKBytes(&info.committed);
metrics->GetWorkingSetKBytes(&info.working_set); metrics->GetWorkingSetKBytes(&info.working_set);
...@@ -134,7 +135,7 @@ void MemoryDetails::CollectProcessData( ...@@ -134,7 +135,7 @@ void MemoryDetails::CollectProcessData(
info.process_type = child_info[child].process_type; info.process_type = child_info[child].process_type;
break; break;
} }
} else if (GetModuleFileNameEx(process_handle, NULL, name, } else if (GetModuleFileNameEx(process_handle.Get(), NULL, name,
MAX_PATH - 1)) { MAX_PATH - 1)) {
std::wstring str_name(name); std::wstring str_name(name);
scoped_ptr<FileVersionInfo> version_info( scoped_ptr<FileVersionInfo> version_info(
...@@ -154,7 +155,7 @@ void MemoryDetails::CollectProcessData( ...@@ -154,7 +155,7 @@ void MemoryDetails::CollectProcessData(
} }
break; break;
} }
} while (::Process32Next(snapshot, &process_entry)); } while (::Process32Next(snapshot.Get(), &process_entry));
// Finally return to the browser thread. // Finally return to the browser thread.
BrowserThread::PostTask( BrowserThread::PostTask(
......
...@@ -356,9 +356,12 @@ bool ProcessSingleton::Create() { ...@@ -356,9 +356,12 @@ bool ProcessSingleton::Create() {
// since it isn't guaranteed we will get it. It is better to create it // since it isn't guaranteed we will get it. It is better to create it
// without ownership and explicitly get the ownership afterward. // without ownership and explicitly get the ownership afterward.
base::win::ScopedHandle only_me(::CreateMutex(NULL, FALSE, kMutexName)); base::win::ScopedHandle only_me(::CreateMutex(NULL, FALSE, kMutexName));
DPCHECK(only_me.IsValid()); if (!only_me.IsValid()) {
DPLOG(FATAL) << "CreateMutex failed";
return false;
}
AutoLockMutex auto_lock_only_me(only_me); AutoLockMutex auto_lock_only_me(only_me.Get());
// We now own the mutex so we are the only process that can create the // We now own the mutex so we are the only process that can create the
// window at this time, but we must still check if someone created it // window at this time, but we must still check if someone created it
...@@ -402,9 +405,9 @@ bool ProcessSingleton::Create() { ...@@ -402,9 +405,9 @@ bool ProcessSingleton::Create() {
// until the event is signaled (i.e. Metro Chrome was successfully // until the event is signaled (i.e. Metro Chrome was successfully
// activated). Ignore timeout waiting for |metro_activation_event|. // activated). Ignore timeout waiting for |metro_activation_event|.
{ {
AutoUnlockMutex auto_unlock_only_me(only_me); AutoUnlockMutex auto_unlock_only_me(only_me.Get());
DWORD result = ::WaitForSingleObject(metro_activation_event, DWORD result = ::WaitForSingleObject(metro_activation_event.Get(),
kMetroChromeActivationTimeoutMs); kMetroChromeActivationTimeoutMs);
DPCHECK(result == WAIT_OBJECT_0 || result == WAIT_TIMEOUT) DPCHECK(result == WAIT_OBJECT_0 || result == WAIT_TIMEOUT)
<< "Result = " << result; << "Result = " << result;
...@@ -450,7 +453,7 @@ bool ProcessSingleton::Create() { ...@@ -450,7 +453,7 @@ bool ProcessSingleton::Create() {
base::win::ScopedHandle metro_activation_event( base::win::ScopedHandle metro_activation_event(
::OpenEvent(EVENT_MODIFY_STATE, FALSE, kMetroActivationEventName)); ::OpenEvent(EVENT_MODIFY_STATE, FALSE, kMetroActivationEventName));
if (metro_activation_event.IsValid()) if (metro_activation_event.IsValid())
::SetEvent(metro_activation_event); ::SetEvent(metro_activation_event.Get());
} }
} }
} }
......
...@@ -103,7 +103,7 @@ bool CheckServiceProcessReady() { ...@@ -103,7 +103,7 @@ bool CheckServiceProcessReady() {
if (!event.IsValid()) if (!event.IsValid())
return false; return false;
// Check if the event is signaled. // Check if the event is signaled.
return WaitForSingleObject(event, 0) == WAIT_OBJECT_0; return WaitForSingleObject(event.Get(), 0) == WAIT_OBJECT_0;
} }
struct ServiceProcessState::StateData { struct ServiceProcessState::StateData {
......
...@@ -478,7 +478,8 @@ BOOL __stdcall LaunchGoogleChrome() { ...@@ -478,7 +478,8 @@ BOOL __stdcall LaunchGoogleChrome() {
if (process_handle.IsValid()) { if (process_handle.IsValid()) {
HANDLE process_token = NULL; HANDLE process_token = NULL;
HANDLE user_token = NULL; HANDLE user_token = NULL;
if (::OpenProcessToken(process_handle, TOKEN_DUPLICATE | TOKEN_QUERY, if (::OpenProcessToken(process_handle.Get(),
TOKEN_DUPLICATE | TOKEN_QUERY,
&process_token) && &process_token) &&
::DuplicateTokenEx(process_token, ::DuplicateTokenEx(process_token,
TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_IMPERSONATE | TOKEN_QUERY |
......
...@@ -479,7 +479,8 @@ ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) ...@@ -479,7 +479,8 @@ ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name)
tp.Privileges[0].Luid = privilege_luid; tp.Privileges[0].Luid = privilege_luid;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
DWORD return_length; DWORD return_length;
if (!::AdjustTokenPrivileges(token_, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), if (!::AdjustTokenPrivileges(token_.Get(), FALSE, &tp,
sizeof(TOKEN_PRIVILEGES),
&previous_privileges_, &return_length)) { &previous_privileges_, &return_length)) {
token_.Close(); token_.Close();
return; return;
...@@ -490,7 +491,7 @@ ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name) ...@@ -490,7 +491,7 @@ ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name)
ScopedTokenPrivilege::~ScopedTokenPrivilege() { ScopedTokenPrivilege::~ScopedTokenPrivilege() {
if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) {
::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, ::AdjustTokenPrivileges(token_.Get(), FALSE, &previous_privileges_,
sizeof(TOKEN_PRIVILEGES), NULL, NULL); sizeof(TOKEN_PRIVILEGES), NULL, NULL);
} }
} }
......
...@@ -66,13 +66,15 @@ bool CurrentProcessHasPrivilege(const wchar_t* privilege_name) { ...@@ -66,13 +66,15 @@ bool CurrentProcessHasPrivilege(const wchar_t* privilege_name) {
// First get the size of the buffer needed for |privileges| below. // First get the size of the buffer needed for |privileges| below.
DWORD size; DWORD size;
EXPECT_FALSE(::GetTokenInformation(token, TokenPrivileges, NULL, 0, &size)); EXPECT_FALSE(::GetTokenInformation(token.Get(), TokenPrivileges, NULL, 0,
&size));
scoped_ptr<BYTE[]> privileges_bytes(new BYTE[size]); scoped_ptr<BYTE[]> privileges_bytes(new BYTE[size]);
TOKEN_PRIVILEGES* privileges = TOKEN_PRIVILEGES* privileges =
reinterpret_cast<TOKEN_PRIVILEGES*>(privileges_bytes.get()); reinterpret_cast<TOKEN_PRIVILEGES*>(privileges_bytes.get());
if (!::GetTokenInformation(token, TokenPrivileges, privileges, size, &size)) { if (!::GetTokenInformation(token.Get(), TokenPrivileges, privileges, size,
&size)) {
ADD_FAILURE(); ADD_FAILURE();
return false; return false;
} }
......
...@@ -282,13 +282,13 @@ void CloseChromeFrameHelperProcess() { ...@@ -282,13 +282,13 @@ void CloseChromeFrameHelperProcess() {
::GetWindowThreadProcessId(window, &pid); ::GetWindowThreadProcessId(window, &pid);
DCHECK_NE(pid, 0U); DCHECK_NE(pid, 0U);
base::win::ScopedHandle process(::OpenProcess(SYNCHRONIZE, FALSE, pid)); base::win::ScopedHandle process(::OpenProcess(SYNCHRONIZE, FALSE, pid));
PLOG_IF(INFO, !process) << "Failed to open process: " << pid; PLOG_IF(INFO, !process.IsValid()) << "Failed to open process: " << pid;
bool kill = true; bool kill = true;
if (SendMessageTimeout(window, WM_CLOSE, 0, 0, SMTO_BLOCK, kWaitMs, NULL) && if (SendMessageTimeout(window, WM_CLOSE, 0, 0, SMTO_BLOCK, kWaitMs, NULL) &&
process) { process.IsValid()) {
VLOG(1) << "Waiting for " << installer::kChromeFrameHelperExe; VLOG(1) << "Waiting for " << installer::kChromeFrameHelperExe;
DWORD wait = ::WaitForSingleObject(process, kWaitMs); DWORD wait = ::WaitForSingleObject(process.Get(), kWaitMs);
if (wait != WAIT_OBJECT_0) { if (wait != WAIT_OBJECT_0) {
LOG(WARNING) << "Wait for " << installer::kChromeFrameHelperExe LOG(WARNING) << "Wait for " << installer::kChromeFrameHelperExe
<< " to exit failed or timed out."; << " to exit failed or timed out.";
......
...@@ -95,7 +95,8 @@ bool LaunchProcessAndWaitWithTimeout(const base::string16& cmd_string, ...@@ -95,7 +95,8 @@ bool LaunchProcessAndWaitWithTimeout(const base::string16& cmd_string,
if (!base::LaunchProcess(cmd_string, base::LaunchOptions(), if (!base::LaunchProcess(cmd_string, base::LaunchOptions(),
&process)) { &process)) {
PLOG(ERROR) << "Failed to launch (" << cmd_string << ")"; PLOG(ERROR) << "Failed to launch (" << cmd_string << ")";
} else if (!base::WaitForExitCodeWithTimeout(process, &exit_code, timeout)) { } else if (!base::WaitForExitCodeWithTimeout(process.Get(), &exit_code,
timeout)) {
// The GetExitCodeProcess failed or timed-out. // The GetExitCodeProcess failed or timed-out.
LOG(ERROR) <<"Command (" << cmd_string << ") is taking more than " LOG(ERROR) <<"Command (" << cmd_string << ") is taking more than "
<< timeout.InMilliseconds() << " milliseconds to complete."; << timeout.InMilliseconds() << " milliseconds to complete.";
......
...@@ -486,7 +486,7 @@ TEST_F(InstallerStateTest, IsFileInUse) { ...@@ -486,7 +486,7 @@ TEST_F(InstallerStateTest, IsFileInUse) {
SYNCHRONIZE | FILE_EXECUTE, SYNCHRONIZE | FILE_EXECUTE,
FILE_SHARE_DELETE | FILE_SHARE_READ, FILE_SHARE_DELETE | FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, 0)); NULL, OPEN_EXISTING, 0, 0));
ASSERT_TRUE(temp_handle != NULL); ASSERT_TRUE(temp_handle.IsValid());
// The file should now be in use. // The file should now be in use.
EXPECT_TRUE(MockInstallerState::IsFileInUse(temp_file)); EXPECT_TRUE(MockInstallerState::IsFileInUse(temp_file));
......
...@@ -84,7 +84,8 @@ int GetDirectoryWriteTimeInHours(const wchar_t* path) { ...@@ -84,7 +84,8 @@ int GetDirectoryWriteTimeInHours(const wchar_t* path) {
return -1; return -1;
FILETIME time; FILETIME time;
return ::GetFileTime(file, NULL, NULL, &time) ? FileTimeToHours(time) : -1; return ::GetFileTime(file.Get(), NULL, NULL, &time) ?
FileTimeToHours(time) : -1;
} }
// Returns the time in hours since the last write to the user data directory. // Returns the time in hours since the last write to the user data directory.
...@@ -513,7 +514,7 @@ void InactiveUserToastExperiment(int flavor, ...@@ -513,7 +514,7 @@ void InactiveUserToastExperiment(int flavor,
break; break;
default: default:
outcome = kToastExpTriesErrorGroup; outcome = kToastExpTriesErrorGroup;
}; }
// Write to the |client| key for the last time. // Write to the |client| key for the last time.
SetClient(experiment_group + outcome, true); SetClient(experiment_group + outcome, true);
......
...@@ -33,9 +33,10 @@ scoped_ptr<DEVMODE, base::FreeDeleter> CjtToDevMode( ...@@ -33,9 +33,10 @@ scoped_ptr<DEVMODE, base::FreeDeleter> CjtToDevMode(
ColorTicketItem color; ColorTicketItem color;
if (color.LoadFrom(description)) { if (color.LoadFrom(description)) {
bool is_color = color.value().type == STANDARD_COLOR; bool is_color = color.value().type == STANDARD_COLOR;
dev_mode = CreateDevModeWithColor(printer, printer_name, is_color); dev_mode = printing::CreateDevModeWithColor(printer.Get(), printer_name,
is_color);
} else { } else {
dev_mode = printing::CreateDevMode(printer, NULL); dev_mode = printing::CreateDevMode(printer.Get(), NULL);
} }
} }
...@@ -124,7 +125,7 @@ scoped_ptr<DEVMODE, base::FreeDeleter> CjtToDevMode( ...@@ -124,7 +125,7 @@ scoped_ptr<DEVMODE, base::FreeDeleter> CjtToDevMode(
} }
} }
return printing::CreateDevMode(printer, dev_mode.get()); return printing::CreateDevMode(printer.Get(), dev_mode.get());
} }
} // namespace cloud_print } // namespace cloud_print
...@@ -68,9 +68,9 @@ class PrintSystemWatcherWin : public base::win::ObjectWatcher::Delegate { ...@@ -68,9 +68,9 @@ class PrintSystemWatcherWin : public base::win::ObjectWatcher::Delegate {
bool ret = false; bool ret = false;
if (printer_.OpenPrinter(printer_name_to_use)) { if (printer_.OpenPrinter(printer_name_to_use)) {
printer_change_.Set(FindFirstPrinterChangeNotification( printer_change_.Set(FindFirstPrinterChangeNotification(
printer_, PRINTER_CHANGE_PRINTER|PRINTER_CHANGE_JOB, 0, NULL)); printer_.Get(), PRINTER_CHANGE_PRINTER|PRINTER_CHANGE_JOB, 0, NULL));
if (printer_change_.IsValid()) { if (printer_change_.IsValid()) {
ret = watcher_.StartWatching(printer_change_, this); ret = watcher_.StartWatching(printer_change_.Get(), this);
} }
} }
if (!ret) { if (!ret) {
...@@ -108,12 +108,12 @@ class PrintSystemWatcherWin : public base::win::ObjectWatcher::Delegate { ...@@ -108,12 +108,12 @@ class PrintSystemWatcherWin : public base::win::ObjectWatcher::Delegate {
delegate_->OnJobChanged(); delegate_->OnJobChanged();
} }
} }
watcher_.StartWatching(printer_change_, this); watcher_.StartWatching(printer_change_.Get(), this);
} }
bool GetCurrentPrinterInfo(printing::PrinterBasicInfo* printer_info) { bool GetCurrentPrinterInfo(printing::PrinterBasicInfo* printer_info) {
DCHECK(printer_info); DCHECK(printer_info);
return InitBasicPrinterInfo(printer_, printer_info); return InitBasicPrinterInfo(printer_.Get(), printer_info);
} }
private: private:
...@@ -153,7 +153,7 @@ class PrintServerWatcherWin ...@@ -153,7 +153,7 @@ class PrintServerWatcherWin
virtual void OnPrinterChanged() OVERRIDE {} virtual void OnPrinterChanged() OVERRIDE {}
virtual void OnJobChanged() OVERRIDE {} virtual void OnJobChanged() OVERRIDE {}
protected: protected:
virtual ~PrintServerWatcherWin() {} virtual ~PrintServerWatcherWin() {}
private: private:
...@@ -204,7 +204,7 @@ class PrinterWatcherWin ...@@ -204,7 +204,7 @@ class PrinterWatcherWin
delegate_->OnJobChanged(); delegate_->OnJobChanged();
} }
protected: protected:
virtual ~PrinterWatcherWin() {} virtual ~PrinterWatcherWin() {}
private: private:
...@@ -752,14 +752,14 @@ bool PrintSystemWin::GetJobDetails(const std::string& printer_name, ...@@ -752,14 +752,14 @@ bool PrintSystemWin::GetJobDetails(const std::string& printer_name,
bool ret = false; bool ret = false;
if (printer_handle.IsValid()) { if (printer_handle.IsValid()) {
DWORD bytes_needed = 0; DWORD bytes_needed = 0;
GetJob(printer_handle, job_id, 1, NULL, 0, &bytes_needed); GetJob(printer_handle.Get(), job_id, 1, NULL, 0, &bytes_needed);
DWORD last_error = GetLastError(); DWORD last_error = GetLastError();
if (ERROR_INVALID_PARAMETER != last_error) { if (ERROR_INVALID_PARAMETER != last_error) {
// ERROR_INVALID_PARAMETER normally means that the job id is not valid. // ERROR_INVALID_PARAMETER normally means that the job id is not valid.
DCHECK(last_error == ERROR_INSUFFICIENT_BUFFER); DCHECK(last_error == ERROR_INSUFFICIENT_BUFFER);
scoped_ptr<BYTE[]> job_info_buffer(new BYTE[bytes_needed]); scoped_ptr<BYTE[]> job_info_buffer(new BYTE[bytes_needed]);
if (GetJob(printer_handle, job_id, 1, job_info_buffer.get(), bytes_needed, if (GetJob(printer_handle.Get(), job_id, 1, job_info_buffer.get(),
&bytes_needed)) { bytes_needed, &bytes_needed)) {
JOB_INFO_1 *job_info = JOB_INFO_1 *job_info =
reinterpret_cast<JOB_INFO_1 *>(job_info_buffer.get()); reinterpret_cast<JOB_INFO_1 *>(job_info_buffer.get());
if (job_info->pStatus) { if (job_info->pStatus) {
......
...@@ -22,7 +22,7 @@ bool ImageWriter::IsValidDevice() { ...@@ -22,7 +22,7 @@ bool ImageWriter::IsValidDevice() {
OPEN_EXISTING, OPEN_EXISTING,
FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH, FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH,
NULL)); NULL));
if (device_handle == INVALID_HANDLE_VALUE) { if (!device_handle.IsValid()) {
Error(error::kOpenDevice); Error(error::kOpenDevice);
return false; return false;
} }
...@@ -34,7 +34,7 @@ bool ImageWriter::IsValidDevice() { ...@@ -34,7 +34,7 @@ bool ImageWriter::IsValidDevice() {
scoped_ptr<char[]> output_buf(new char[kStorageQueryBufferSize]); scoped_ptr<char[]> output_buf(new char[kStorageQueryBufferSize]);
BOOL status = DeviceIoControl( BOOL status = DeviceIoControl(
device_handle, // Device handle. device_handle.Get(), // Device handle.
IOCTL_STORAGE_QUERY_PROPERTY, // Flag to request device properties. IOCTL_STORAGE_QUERY_PROPERTY, // Flag to request device properties.
&query, // Query parameters. &query, // Query parameters.
sizeof(STORAGE_PROPERTY_QUERY), // query parameters size. sizeof(STORAGE_PROPERTY_QUERY), // query parameters size.
......
...@@ -72,7 +72,9 @@ base::Time GetFileCreationTime(const base::string16& file) { ...@@ -72,7 +72,9 @@ base::Time GetFileCreationTime(const base::string16& file) {
NULL, OPEN_EXISTING, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL)); FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL));
FILETIME creation_filetime; FILETIME creation_filetime;
if (GetFileTime(file_handle, &creation_filetime, NULL, NULL)) if (!file_handle.IsValid())
return creation_time;
if (GetFileTime(file_handle.Get(), &creation_filetime, NULL, NULL))
creation_time = base::Time::FromFileTime(creation_filetime); creation_time = base::Time::FromFileTime(creation_filetime);
return creation_time; return creation_time;
} }
......
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