| 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 f1ec727e7c63c8259e07f99d33b717e857d3a8d2..30638df789eac0032190734b703659798ee3bfa8 100644
|
| --- a/base/message_loop/message_pump_win.cc
|
| +++ b/base/message_loop/message_pump_win.cc
|
| @@ -400,143 +400,6 @@ bool MessagePumpForUI::ProcessPumpReplacementMessage() {
|
| }
|
|
|
| //-----------------------------------------------------------------------------
|
| -// MessagePumpForGpu public:
|
| -
|
| -MessagePumpForGpu::MessagePumpForGpu() {
|
| - event_.Set(CreateEvent(nullptr, FALSE, FALSE, nullptr));
|
| -}
|
| -
|
| -MessagePumpForGpu::~MessagePumpForGpu() = default;
|
| -
|
| -// static
|
| -void MessagePumpForGpu::InitFactory() {
|
| - bool init_result = MessageLoop::InitMessagePumpForUIFactory(
|
| - &MessagePumpForGpu::CreateMessagePumpForGpu);
|
| - DCHECK(init_result);
|
| -}
|
| -
|
| -// static
|
| -std::unique_ptr<MessagePump> MessagePumpForGpu::CreateMessagePumpForGpu() {
|
| - return WrapUnique<MessagePump>(new MessagePumpForGpu);
|
| -}
|
| -
|
| -void MessagePumpForGpu::ScheduleWork() {
|
| - if (InterlockedExchange(&work_state_, HAVE_WORK) != READY)
|
| - return; // Someone else continued the pumping.
|
| -
|
| - // TODO(stanisc): crbug.com/596190: Preserve for crash dump analysis.
|
| - // Remove this when the bug is fixed.
|
| - last_set_event_timeticks_ = TimeTicks::Now();
|
| -
|
| - // Make sure the MessagePump does some work for us.
|
| - SetEvent(event_.Get());
|
| -}
|
| -
|
| -void MessagePumpForGpu::ScheduleDelayedWork(
|
| - const TimeTicks& delayed_work_time) {
|
| - // We know that we can't be blocked right now since this method can only be
|
| - // called on the same thread as Run, so we only need to update our record of
|
| - // how long to sleep when we do sleep.
|
| - delayed_work_time_ = delayed_work_time;
|
| -}
|
| -
|
| -//-----------------------------------------------------------------------------
|
| -// MessagePumpForGpu private:
|
| -
|
| -void MessagePumpForGpu::DoRunLoop() {
|
| - while (!state_->should_quit) {
|
| - // Indicate that the loop is handling the work.
|
| - // If there is a race condition between switching to WORKING state here and
|
| - // the producer thread setting the HAVE_WORK state after exiting the wait,
|
| - // the event might remain in the signalled state. That might be less than
|
| - // optimal but wouldn't result in failing to handle the work.
|
| - InterlockedExchange(&work_state_, WORKING);
|
| -
|
| - bool more_work_is_plausible = ProcessNextMessage();
|
| - if (state_->should_quit)
|
| - break;
|
| -
|
| - more_work_is_plausible |= state_->delegate->DoWork();
|
| - if (state_->should_quit)
|
| - break;
|
| -
|
| - more_work_is_plausible |=
|
| - state_->delegate->DoDelayedWork(&delayed_work_time_);
|
| - if (state_->should_quit)
|
| - break;
|
| -
|
| - if (more_work_is_plausible)
|
| - continue;
|
| -
|
| - more_work_is_plausible = state_->delegate->DoIdleWork();
|
| - if (state_->should_quit)
|
| - break;
|
| -
|
| - if (more_work_is_plausible)
|
| - continue;
|
| -
|
| - // Switch that working state to READY to indicate that the loop is
|
| - // waiting for accepting new work if it is still in WORKING state and hasn't
|
| - // been signalled. Otherwise if it is in HAVE_WORK state skip the wait
|
| - // and proceed to handing the work.
|
| - if (InterlockedCompareExchange(&work_state_, READY, WORKING) == HAVE_WORK)
|
| - continue; // Skip wait, more work was requested.
|
| -
|
| - WaitForWork(); // Wait (sleep) until we have work to do again.
|
| - }
|
| -}
|
| -
|
| -void MessagePumpForGpu::WaitForWork() {
|
| - // Wait until a message is available, up to the time needed by the timer
|
| - // manager to fire the next set of timers.
|
| - int delay;
|
| -
|
| - // The while loop handles the situation where on Windows 7 and later versions
|
| - // MsgWaitForMultipleObjectsEx might time out slightly earlier (less than one
|
| - // ms) than the specified |delay|. In that situation it is more optimal to
|
| - // just wait again rather than waste a DoRunLoop cycle.
|
| - while ((delay = GetCurrentDelay()) != 0) {
|
| - if (delay < 0) // Negative value means no timers waiting.
|
| - delay = INFINITE;
|
| -
|
| - // TODO(stanisc): crbug.com/596190: Preserve for crash dump analysis.
|
| - // Remove this when the bug is fixed.
|
| - TimeTicks wait_for_work_timeticks = TimeTicks::Now();
|
| - debug::Alias(&wait_for_work_timeticks);
|
| - debug::Alias(&delay);
|
| -
|
| - HANDLE handle = event_.Get();
|
| - DWORD result =
|
| - MsgWaitForMultipleObjectsEx(1, &handle, delay, QS_ALLINPUT, 0);
|
| - DCHECK_NE(WAIT_FAILED, result) << GetLastError();
|
| - if (result != WAIT_TIMEOUT) {
|
| - // Either work or message available.
|
| - return;
|
| - }
|
| - }
|
| -}
|
| -
|
| -bool MessagePumpForGpu::ProcessNextMessage() {
|
| - MSG msg;
|
| - if (!PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
|
| - return false;
|
| -
|
| - if (msg.message == WM_QUIT) {
|
| - UMA_HISTOGRAM_ENUMERATION("Chrome.MessageLoopProblem",
|
| - RECEIVED_WM_QUIT_ERROR, MESSAGE_LOOP_PROBLEM_MAX);
|
| - // WM_QUIT messages shouldn't be received by any threads in the GPU
|
| - // process. If they are, just ignore them instead of causing threads to
|
| - // exit prematurely.
|
| - return true;
|
| - }
|
| -
|
| - TranslateMessage(&msg);
|
| - DispatchMessage(&msg);
|
| -
|
| - return true;
|
| -}
|
| -
|
| -//-----------------------------------------------------------------------------
|
| // MessagePumpForIO public:
|
|
|
| MessagePumpForIO::IOContext::IOContext() {
|
|
|