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

Side by Side Diff: base/message_loop/message_pump_win.cc

Issue 421173003: base: Remove now-unused MessagePumpObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tot-merge Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/message_loop/message_pump_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/message_loop/message_pump_win.h" 5 #include "base/message_loop/message_pump_win.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 17 matching lines...) Expand all
28 28
29 static const wchar_t kWndClassFormat[] = L"Chrome_MessagePumpWindow_%p"; 29 static const wchar_t kWndClassFormat[] = L"Chrome_MessagePumpWindow_%p";
30 30
31 // Message sent to get an additional time slice for pumping (processing) another 31 // Message sent to get an additional time slice for pumping (processing) another
32 // task (a series of such messages creates a continuous task pump). 32 // task (a series of such messages creates a continuous task pump).
33 static const int kMsgHaveWork = WM_USER + 1; 33 static const int kMsgHaveWork = WM_USER + 1;
34 34
35 //----------------------------------------------------------------------------- 35 //-----------------------------------------------------------------------------
36 // MessagePumpWin public: 36 // MessagePumpWin public:
37 37
38 void MessagePumpWin::AddObserver(MessagePumpObserver* observer) {
39 observers_.AddObserver(observer);
40 }
41
42 void MessagePumpWin::RemoveObserver(MessagePumpObserver* observer) {
43 observers_.RemoveObserver(observer);
44 }
45
46 void MessagePumpWin::WillProcessMessage(const MSG& msg) {
47 FOR_EACH_OBSERVER(MessagePumpObserver, observers_, WillProcessEvent(msg));
48 }
49
50 void MessagePumpWin::DidProcessMessage(const MSG& msg) {
51 FOR_EACH_OBSERVER(MessagePumpObserver, observers_, DidProcessEvent(msg));
52 }
53
54 void MessagePumpWin::RunWithDispatcher( 38 void MessagePumpWin::RunWithDispatcher(
55 Delegate* delegate, MessagePumpDispatcher* dispatcher) { 39 Delegate* delegate, MessagePumpDispatcher* dispatcher) {
56 RunState s; 40 RunState s;
57 s.delegate = delegate; 41 s.delegate = delegate;
58 s.dispatcher = dispatcher; 42 s.dispatcher = dispatcher;
59 s.should_quit = false; 43 s.should_quit = false;
60 s.run_depth = state_ ? state_->run_depth + 1 : 1; 44 s.run_depth = state_ ? state_->run_depth + 1 : 1;
61 45
62 RunState* previous_state = state_; 46 RunState* previous_state = state_;
63 state_ = &s; 47 state_ = &s;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 return false; 346 return false;
363 } 347 }
364 348
365 // While running our main message pump, we discard kMsgHaveWork messages. 349 // While running our main message pump, we discard kMsgHaveWork messages.
366 if (msg.message == kMsgHaveWork && msg.hwnd == message_hwnd_) 350 if (msg.message == kMsgHaveWork && msg.hwnd == message_hwnd_)
367 return ProcessPumpReplacementMessage(); 351 return ProcessPumpReplacementMessage();
368 352
369 if (CallMsgFilter(const_cast<MSG*>(&msg), kMessageFilterCode)) 353 if (CallMsgFilter(const_cast<MSG*>(&msg), kMessageFilterCode))
370 return true; 354 return true;
371 355
372 WillProcessMessage(msg);
373
374 uint32_t action = MessagePumpDispatcher::POST_DISPATCH_PERFORM_DEFAULT; 356 uint32_t action = MessagePumpDispatcher::POST_DISPATCH_PERFORM_DEFAULT;
375 if (state_->dispatcher) 357 if (state_->dispatcher)
376 action = state_->dispatcher->Dispatch(msg); 358 action = state_->dispatcher->Dispatch(msg);
377 if (action & MessagePumpDispatcher::POST_DISPATCH_QUIT_LOOP) 359 if (action & MessagePumpDispatcher::POST_DISPATCH_QUIT_LOOP)
378 state_->should_quit = true; 360 state_->should_quit = true;
379 if (action & MessagePumpDispatcher::POST_DISPATCH_PERFORM_DEFAULT) { 361 if (action & MessagePumpDispatcher::POST_DISPATCH_PERFORM_DEFAULT) {
380 TranslateMessage(&msg); 362 TranslateMessage(&msg);
381 DispatchMessage(&msg); 363 DispatchMessage(&msg);
382 } 364 }
383 365
384 DidProcessMessage(msg);
385 return true; 366 return true;
386 } 367 }
387 368
388 bool MessagePumpForUI::ProcessPumpReplacementMessage() { 369 bool MessagePumpForUI::ProcessPumpReplacementMessage() {
389 // When we encounter a kMsgHaveWork message, this method is called to peek 370 // When we encounter a kMsgHaveWork message, this method is called to peek
390 // and process a replacement message, such as a WM_PAINT or WM_TIMER. The 371 // and process a replacement message, such as a WM_PAINT or WM_TIMER. The
391 // goal is to make the kMsgHaveWork as non-intrusive as possible, even though 372 // goal is to make the kMsgHaveWork as non-intrusive as possible, even though
392 // a continuous stream of such messages are posted. This method carefully 373 // a continuous stream of such messages are posted. This method carefully
393 // peeks a message while there is no chance for a kMsgHaveWork to be pending, 374 // peeks a message while there is no chance for a kMsgHaveWork to be pending,
394 // then resets the have_work_ flag (allowing a replacement kMsgHaveWork to 375 // then resets the have_work_ flag (allowing a replacement kMsgHaveWork to
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 627
647 // static 628 // static
648 MessagePumpForIO::IOHandler* MessagePumpForIO::KeyToHandler( 629 MessagePumpForIO::IOHandler* MessagePumpForIO::KeyToHandler(
649 ULONG_PTR key, 630 ULONG_PTR key,
650 bool* has_valid_io_context) { 631 bool* has_valid_io_context) {
651 *has_valid_io_context = ((key & 1) == 0); 632 *has_valid_io_context = ((key & 1) == 0);
652 return reinterpret_cast<IOHandler*>(key & ~static_cast<ULONG_PTR>(1)); 633 return reinterpret_cast<IOHandler*>(key & ~static_cast<ULONG_PTR>(1));
653 } 634 }
654 635
655 } // namespace base 636 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_pump_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698