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

Unified Diff: base/message_loop/message_pump_win.cc

Issue 2083463003: Revert of Add chrome_crash_reporter_client_win.cc to the source file list for chrome_elf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/message_loop/message_pump_win.h ('k') | base/process/launch.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_pump_win.cc
diff --git a/base/message_loop/message_pump_win.cc b/base/message_loop/message_pump_win.cc
index 04bc3ceab2b8009e48708a16a308b5195bf27c10..53df341e5fce09a65ed087837db2bacc2aa7b8f6 100644
--- a/base/message_loop/message_pump_win.cc
+++ b/base/message_loop/message_pump_win.cc
@@ -28,85 +28,6 @@
MESSAGE_LOOP_PROBLEM_MAX,
};
-// The following define pointers to user32 API's for the API's which are used
-// in this file. These are added to avoid directly depending on user32 from
-// base as there are users of base who don't want this.
-decltype(::TranslateMessage)* g_translate_message = nullptr;
-decltype(::DispatchMessageW)* g_dispatch_message = nullptr;
-decltype(::PeekMessageW)* g_peek_message = nullptr;
-decltype(::PostMessageW)* g_post_message = nullptr;
-decltype(::DefWindowProcW)* g_def_window_proc = nullptr;
-decltype(::PostQuitMessage)* g_post_quit = nullptr;
-decltype(::UnregisterClassW)* g_unregister_class = nullptr;
-decltype(::RegisterClassExW)* g_register_class = nullptr;
-decltype(::CreateWindowExW)* g_create_window_ex = nullptr;
-decltype(::DestroyWindow)* g_destroy_window = nullptr;
-decltype(::CallMsgFilterW)* g_call_msg_filter = nullptr;
-decltype(::GetQueueStatus)* g_get_queue_status = nullptr;
-decltype(::MsgWaitForMultipleObjectsEx)* g_msg_wait_for_multiple_objects_ex =
- nullptr;
-decltype(::SetTimer)* g_set_timer = nullptr;
-decltype(::KillTimer)* g_kill_timer = nullptr;
-
-#define GET_USER32_API(module, name) \
- reinterpret_cast<decltype(name)*>(::GetProcAddress(module, #name))
-
-// Initializes the global pointers to user32 APIs for the API's used in this
-// file.
-void InitUser32APIs() {
- if (g_translate_message)
- return;
-
- HMODULE user32_module = ::GetModuleHandle(L"user32.dll");
- CHECK(user32_module);
-
- g_translate_message = GET_USER32_API(user32_module, TranslateMessage);
- CHECK(g_translate_message);
-
- g_dispatch_message = GET_USER32_API(user32_module, DispatchMessageW);
- CHECK(g_dispatch_message);
-
- g_peek_message = GET_USER32_API(user32_module, PeekMessageW);
- CHECK(g_peek_message);
-
- g_post_message = GET_USER32_API(user32_module, PostMessageW);
- CHECK(g_post_message);
-
- g_def_window_proc = GET_USER32_API(user32_module, DefWindowProcW);
- CHECK(g_def_window_proc);
-
- g_post_quit = GET_USER32_API(user32_module, PostQuitMessage);
- CHECK(g_post_quit);
-
- g_unregister_class = GET_USER32_API(user32_module, UnregisterClassW);
- CHECK(g_unregister_class);
-
- g_register_class = GET_USER32_API(user32_module, RegisterClassExW);
- CHECK(g_register_class);
-
- g_create_window_ex = GET_USER32_API(user32_module, CreateWindowExW);
- CHECK(g_create_window_ex);
-
- g_destroy_window = GET_USER32_API(user32_module, DestroyWindow);
- CHECK(g_destroy_window);
-
- g_call_msg_filter = GET_USER32_API(user32_module, CallMsgFilterW);
- CHECK(g_call_msg_filter);
-
- g_get_queue_status = GET_USER32_API(user32_module, GetQueueStatus);
- CHECK(g_get_queue_status);
-
- g_msg_wait_for_multiple_objects_ex =
- GET_USER32_API(user32_module, MsgWaitForMultipleObjectsEx);
- CHECK(g_msg_wait_for_multiple_objects_ex);
-
- g_set_timer = GET_USER32_API(user32_module, SetTimer);
- CHECK(g_set_timer);
-
- g_kill_timer = GET_USER32_API(user32_module, KillTimer);
- CHECK(g_kill_timer);
-}
-
} // namespace
static const wchar_t kWndClassFormat[] = L"Chrome_MessagePumpWindow_%p";
@@ -120,10 +41,6 @@
//-----------------------------------------------------------------------------
// MessagePumpWin public:
-
-MessagePumpWin::MessagePumpWin() {
- InitUser32APIs();
-}
void MessagePumpWin::Run(Delegate* delegate) {
RunState s;
@@ -179,8 +96,8 @@
}
MessagePumpForUI::~MessagePumpForUI() {
- g_destroy_window(message_hwnd_);
- g_unregister_class(MAKEINTATOM(atom_), CURRENT_MODULE());
+ DestroyWindow(message_hwnd_);
+ UnregisterClass(MAKEINTATOM(atom_), CURRENT_MODULE());
}
void MessagePumpForUI::ScheduleWork() {
@@ -188,8 +105,8 @@
return; // Someone else continued the pumping.
// Make sure the MessagePump does some work for us.
- BOOL ret = g_post_message(message_hwnd_, kMsgHaveWork,
- reinterpret_cast<WPARAM>(this), 0);
+ BOOL ret = PostMessage(message_hwnd_, kMsgHaveWork,
+ reinterpret_cast<WPARAM>(this), 0);
if (ret)
return; // There was room in the Window Message queue.
@@ -229,7 +146,7 @@
reinterpret_cast<MessagePumpForUI*>(wparam)->HandleTimerMessage();
break;
}
- return g_def_window_proc(hwnd, message, wparam, lparam);
+ return DefWindowProc(hwnd, message, wparam, lparam);
}
void MessagePumpForUI::DoRunLoop() {
@@ -270,7 +187,7 @@
// don't want to disturb that timer if it is already in flight. However,
// if we did do all remaining delayed work, then lets kill the WM_TIMER.
if (more_work_is_plausible && delayed_work_time_.is_null())
- g_kill_timer(message_hwnd_, reinterpret_cast<UINT_PTR>(this));
+ KillTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this));
if (state_->should_quit)
break;
@@ -298,11 +215,11 @@
wc.lpfnWndProc = base::win::WrappedWindowProc<WndProcThunk>;
wc.hInstance = instance;
wc.lpszClassName = class_name.c_str();
- atom_ = g_register_class(&wc);
+ atom_ = RegisterClassEx(&wc);
DCHECK(atom_);
- message_hwnd_ = g_create_window_ex(0, MAKEINTATOM(atom_), 0, 0, 0, 0, 0, 0,
- HWND_MESSAGE, 0, instance, 0);
+ message_hwnd_ = CreateWindow(MAKEINTATOM(atom_), 0, 0, 0, 0, 0, 0,
+ HWND_MESSAGE, 0, instance, 0);
DCHECK(message_hwnd_);
}
@@ -316,8 +233,8 @@
if (delay < 0) // Negative value means no timers waiting.
delay = INFINITE;
- DWORD result = g_msg_wait_for_multiple_objects_ex(0, nullptr, delay,
- QS_ALLINPUT, wait_flags);
+ DWORD result =
+ MsgWaitForMultipleObjectsEx(0, NULL, delay, QS_ALLINPUT, wait_flags);
if (WAIT_OBJECT_0 == result) {
// A WM_* message is available.
@@ -335,9 +252,9 @@
// current thread.
MSG msg = {0};
bool has_pending_sent_message =
- (HIWORD(g_get_queue_status(QS_SENDMESSAGE)) & QS_SENDMESSAGE) != 0;
+ (HIWORD(GetQueueStatus(QS_SENDMESSAGE)) & QS_SENDMESSAGE) != 0;
if (has_pending_sent_message ||
- g_peek_message(&msg, nullptr, 0, 0, PM_NOREMOVE)) {
+ PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
return;
}
@@ -375,7 +292,7 @@
}
void MessagePumpForUI::HandleTimerMessage() {
- g_kill_timer(message_hwnd_, reinterpret_cast<UINT_PTR>(this));
+ KillTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this));
// If we are being called outside of the context of Run, then don't do
// anything. This could correspond to a MessageBox call or something of
@@ -420,8 +337,8 @@
// Create a WM_TIMER event that will wake us up to check for any pending
// timers (in case we are running within a nested, external sub-pump).
- BOOL ret = g_set_timer(message_hwnd_, reinterpret_cast<UINT_PTR>(this),
- delay_msec, nullptr);
+ BOOL ret = SetTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this),
+ delay_msec, NULL);
if (ret)
return;
// If we can't set timers, we are in big trouble... but cross our fingers
@@ -438,12 +355,12 @@
// case to ensure that the message loop peeks again instead of calling
// MsgWaitForMultipleObjectsEx again.
bool sent_messages_in_queue = false;
- DWORD queue_status = g_get_queue_status(QS_SENDMESSAGE);
+ DWORD queue_status = GetQueueStatus(QS_SENDMESSAGE);
if (HIWORD(queue_status) & QS_SENDMESSAGE)
sent_messages_in_queue = true;
MSG msg;
- if (g_peek_message(&msg, nullptr, 0, 0, PM_REMOVE) != FALSE)
+ if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != FALSE)
return ProcessMessageHelper(msg);
return sent_messages_in_queue;
@@ -456,7 +373,7 @@
// Repost the QUIT message so that it will be retrieved by the primary
// GetMessage() loop.
state_->should_quit = true;
- g_post_quit(static_cast<int>(msg.wParam));
+ PostQuitMessage(static_cast<int>(msg.wParam));
return false;
}
@@ -464,11 +381,11 @@
if (msg.message == kMsgHaveWork && msg.hwnd == message_hwnd_)
return ProcessPumpReplacementMessage();
- if (g_call_msg_filter(const_cast<MSG*>(&msg), kMessageFilterCode))
+ if (CallMsgFilter(const_cast<MSG*>(&msg), kMessageFilterCode))
return true;
- g_translate_message(&msg);
- g_dispatch_message(&msg);
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
return true;
}
@@ -484,8 +401,7 @@
// asynchronous to this thread!!
MSG msg;
- const bool have_message =
- g_peek_message(&msg, nullptr, 0, 0, PM_REMOVE) != FALSE;
+ const bool have_message = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != FALSE;
// Expect no message or a message different than kMsgHaveWork.
DCHECK(!have_message || kMsgHaveWork != msg.message ||
@@ -615,7 +531,7 @@
debug::Alias(&delay);
DWORD result =
- g_msg_wait_for_multiple_objects_ex(1, &event_, delay, QS_ALLINPUT, 0);
+ MsgWaitForMultipleObjectsEx(1, &event_, delay, QS_ALLINPUT, 0);
DCHECK_NE(WAIT_FAILED, result) << GetLastError();
if (result != WAIT_TIMEOUT) {
// Either work or message available.
@@ -626,20 +542,20 @@
bool MessagePumpForGpu::ProcessNextMessage() {
MSG msg;
- if (!g_peek_message(&msg, nullptr, 0, 0, PM_REMOVE))
+ if (!PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
return false;
if (msg.message == WM_QUIT) {
// Repost the QUIT message so that it will be retrieved by the primary
// GetMessage() loop.
state_->should_quit = true;
- g_post_quit(static_cast<int>(msg.wParam));
+ PostQuitMessage(static_cast<int>(msg.wParam));
return false;
}
- if (!g_call_msg_filter(const_cast<MSG*>(&msg), kMessageFilterCode)) {
- g_translate_message(&msg);
- g_dispatch_message(&msg);
+ if (!CallMsgFilter(const_cast<MSG*>(&msg), kMessageFilterCode)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
}
return true;
@@ -653,8 +569,7 @@
}
MessagePumpForIO::MessagePumpForIO() {
- port_.Set(CreateIoCompletionPort(INVALID_HANDLE_VALUE, nullptr,
- reinterpret_cast<ULONG_PTR>(nullptr), 1));
+ port_.Set(CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, NULL, 1));
DCHECK(port_.IsValid());
}
@@ -722,7 +637,7 @@
if (state_->should_quit)
break;
- more_work_is_plausible |= WaitForIOCompletion(0, nullptr);
+ more_work_is_plausible |= WaitForIOCompletion(0, NULL);
if (state_->should_quit)
break;
@@ -756,7 +671,7 @@
if (timeout < 0) // Negative value means no timers waiting.
timeout = INFINITE;
- WaitForIOCompletion(timeout, nullptr);
+ WaitForIOCompletion(timeout, NULL);
}
bool MessagePumpForIO::WaitForIOCompletion(DWORD timeout, IOHandler* filter) {
@@ -783,8 +698,8 @@
// Asks the OS for another IO completion result.
bool MessagePumpForIO::GetIOItem(DWORD timeout, IOItem* item) {
memset(item, 0, sizeof(*item));
- ULONG_PTR key = reinterpret_cast<ULONG_PTR>(nullptr);
- OVERLAPPED* overlapped = nullptr;
+ ULONG_PTR key = NULL;
+ OVERLAPPED* overlapped = NULL;
if (!GetQueuedCompletionStatus(port_.Get(), &item->bytes_transfered, &key,
&overlapped, timeout)) {
if (!overlapped)
« no previous file with comments | « base/message_loop/message_pump_win.h ('k') | base/process/launch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698