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

Unified Diff: mojo/edk/system/raw_channel_win.cc

Issue 1389513002: Fix XP builds after r352208. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/raw_channel_win.cc
diff --git a/mojo/edk/system/raw_channel_win.cc b/mojo/edk/system/raw_channel_win.cc
index b4fdb72f83432367658cf99dec8082f08197ef01..3b0e96a3c9655aee9a77df79cc0237895d38736c 100644
--- a/mojo/edk/system/raw_channel_win.cc
+++ b/mojo/edk/system/raw_channel_win.cc
@@ -51,7 +51,8 @@ class VistaOrHigherFunctions {
: is_vista_or_higher_(
base::win::GetVersion() >= base::win::VERSION_VISTA),
set_file_completion_notification_modes_(nullptr),
- cancel_io_ex_(nullptr) {
+ cancel_io_ex_(nullptr),
+ get_file_information_by_handle_ex_(nullptr) {
if (!is_vista_or_higher_)
return;
@@ -64,6 +65,11 @@ class VistaOrHigherFunctions {
cancel_io_ex_ =
reinterpret_cast<CancelIoExFunc>(GetProcAddress(module, "CancelIoEx"));
DCHECK(cancel_io_ex_);
+
+ get_file_information_by_handle_ex_ =
+ reinterpret_cast<GetFileInformationByHandleExFunc>(
+ GetProcAddress(module, "GetFileInformationByHandleEx"));
+ DCHECK(get_file_information_by_handle_ex_);
}
bool is_vista_or_higher() const { return is_vista_or_higher_; }
@@ -76,14 +82,25 @@ class VistaOrHigherFunctions {
return cancel_io_ex_(handle, overlapped);
}
+ BOOL GetFileInformationByHandleEx(HANDLE handle,
+ FILE_INFO_BY_HANDLE_CLASS file_info_class,
+ LPVOID file_info,
+ DWORD buffer_size) {
+ return get_file_information_by_handle_ex_(
+ handle, file_info_class, file_info, buffer_size);
+ }
+
private:
using SetFileCompletionNotificationModesFunc = BOOL(WINAPI*)(HANDLE, UCHAR);
using CancelIoExFunc = BOOL(WINAPI*)(HANDLE, LPOVERLAPPED);
+ using GetFileInformationByHandleExFunc = BOOL(WINAPI*)(
+ HANDLE, FILE_INFO_BY_HANDLE_CLASS, LPVOID, DWORD);
bool is_vista_or_higher_;
SetFileCompletionNotificationModesFunc
set_file_completion_notification_modes_;
CancelIoExFunc cancel_io_ex_;
+ GetFileInformationByHandleExFunc get_file_information_by_handle_ex_;
};
base::LazyInstance<VistaOrHigherFunctions> g_vista_or_higher_functions =
@@ -245,8 +262,12 @@ class RawChannelWin final : public RawChannel {
}
ScopedPlatformHandle ReleaseHandle(std::vector<char>* read_buffer) {
- // TODO(jam): handle XP
- CancelIoEx(handle(), NULL);
+ if (g_vista_or_higher_functions.Get().is_vista_or_higher()) {
+ g_vista_or_higher_functions.Get().CancelIoEx(handle(), nullptr);
+ } else {
+ CHECK(false) << "TODO(jam): handle XP";
+ }
+
// NOTE: The above call will cancel pending IO calls.
size_t read_buffer_byte_size = owner_->read_buffer()->num_valid_bytes();
@@ -848,18 +869,23 @@ bool RawChannel::IsOtherEndOf(RawChannel* other) {
PlatformHandle this_handle = HandleForDebuggingNoLock();
PlatformHandle other_handle = other->HandleForDebuggingNoLock();
- // TODO: XP: see http://stackoverflow.com/questions/65170/how-to-get-name-associated-with-open-handle/5286888#5286888
- WCHAR data1[_MAX_PATH + sizeof(FILE_NAME_INFO)];
- WCHAR data2[_MAX_PATH + sizeof(FILE_NAME_INFO)];
- FILE_NAME_INFO* fileinfo1 = reinterpret_cast<FILE_NAME_INFO *>(data1);
- FILE_NAME_INFO* fileinfo2 = reinterpret_cast<FILE_NAME_INFO *>(data2);
- CHECK(GetFileInformationByHandleEx(
- this_handle.handle, FileNameInfo, fileinfo1, arraysize(data1)));
- CHECK(GetFileInformationByHandleEx(
- other_handle.handle, FileNameInfo, fileinfo2, arraysize(data2)));
- std::wstring filepath1(fileinfo1->FileName, fileinfo1->FileNameLength / 2);
- std::wstring filepath2(fileinfo2->FileName, fileinfo2->FileNameLength / 2);
- return filepath1 == filepath2;
+ if (g_vista_or_higher_functions.Get().is_vista_or_higher()) {
+ WCHAR data1[_MAX_PATH + sizeof(FILE_NAME_INFO)];
+ WCHAR data2[_MAX_PATH + sizeof(FILE_NAME_INFO)];
+ FILE_NAME_INFO* fileinfo1 = reinterpret_cast<FILE_NAME_INFO *>(data1);
+ FILE_NAME_INFO* fileinfo2 = reinterpret_cast<FILE_NAME_INFO *>(data2);
+ CHECK(g_vista_or_higher_functions.Get().GetFileInformationByHandleEx(
+ this_handle.handle, FileNameInfo, fileinfo1, arraysize(data1)));
+ CHECK(g_vista_or_higher_functions.Get().GetFileInformationByHandleEx(
+ other_handle.handle, FileNameInfo, fileinfo2, arraysize(data2)));
+ std::wstring filepath1(fileinfo1->FileName, fileinfo1->FileNameLength / 2);
+ std::wstring filepath2(fileinfo2->FileName, fileinfo2->FileNameLength / 2);
+ return filepath1 == filepath2;
+ } else {
+ // TODO: XP: see http://stackoverflow.com/questions/65170/how-to-get-name-associated-with-open-handle/5286888#5286888
+ CHECK(false) << "TODO(jam): handle XP";
+ return false;
+ }
}
} // namespace edk
« 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