| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef BASE_MESSAGE_LOOP_H_ | 5 #ifndef BASE_MESSAGE_LOOP_H_ |
| 6 #define BASE_MESSAGE_LOOP_H_ | 6 #define BASE_MESSAGE_LOOP_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 // Please see MessagePumpWin for definitions of these methods. | 419 // Please see MessagePumpWin for definitions of these methods. |
| 420 void Run(Dispatcher* dispatcher); | 420 void Run(Dispatcher* dispatcher); |
| 421 void AddObserver(Observer* observer); | 421 void AddObserver(Observer* observer); |
| 422 void RemoveObserver(Observer* observer); | 422 void RemoveObserver(Observer* observer); |
| 423 void WillProcessMessage(const MSG& message); | 423 void WillProcessMessage(const MSG& message); |
| 424 void DidProcessMessage(const MSG& message); | 424 void DidProcessMessage(const MSG& message); |
| 425 void PumpOutPendingPaintMessages(); | 425 void PumpOutPendingPaintMessages(); |
| 426 | 426 |
| 427 protected: | 427 protected: |
| 428 // TODO(rvargas): Make this platform independent. | 428 // TODO(rvargas): Make this platform independent. |
| 429 base::MessagePumpWin* pump_ui() { | 429 base::MessagePumpForUI* pump_ui() { |
| 430 return static_cast<base::MessagePumpForUI*>(pump_.get()); | 430 return static_cast<base::MessagePumpForUI*>(pump_.get()); |
| 431 } | 431 } |
| 432 #endif // defined(OS_WIN) | 432 #endif // defined(OS_WIN) |
| 433 }; | 433 }; |
| 434 | 434 |
| 435 // Do not add any member variables to MessageLoopForUI! This is important b/c | 435 // Do not add any member variables to MessageLoopForUI! This is important b/c |
| 436 // MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra | 436 // MessageLoopForUI is often allocated via MessageLoop(TYPE_UI). Any extra |
| 437 // data that you need should be stored on the MessageLoop's pump_ instance. | 437 // data that you need should be stored on the MessageLoop's pump_ instance. |
| 438 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForUI), | 438 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForUI), |
| 439 MessageLoopForUI_should_not_have_extra_member_variables); | 439 MessageLoopForUI_should_not_have_extra_member_variables); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 451 } | 451 } |
| 452 | 452 |
| 453 // Returns the MessageLoopForIO of the current thread. | 453 // Returns the MessageLoopForIO of the current thread. |
| 454 static MessageLoopForIO* current() { | 454 static MessageLoopForIO* current() { |
| 455 MessageLoop* loop = MessageLoop::current(); | 455 MessageLoop* loop = MessageLoop::current(); |
| 456 DCHECK_EQ(MessageLoop::TYPE_IO, loop->type()); | 456 DCHECK_EQ(MessageLoop::TYPE_IO, loop->type()); |
| 457 return static_cast<MessageLoopForIO*>(loop); | 457 return static_cast<MessageLoopForIO*>(loop); |
| 458 } | 458 } |
| 459 | 459 |
| 460 #if defined(OS_WIN) | 460 #if defined(OS_WIN) |
| 461 typedef base::MessagePumpForIO::Watcher Watcher; | |
| 462 typedef base::MessagePumpForIO::IOHandler IOHandler; | 461 typedef base::MessagePumpForIO::IOHandler IOHandler; |
| 462 typedef base::MessagePumpForIO::IOContext IOContext; |
| 463 | 463 |
| 464 // Please see MessagePumpWin for definitions of these methods. | 464 // Please see MessagePumpWin for definitions of these methods. |
| 465 void WatchObject(HANDLE object, Watcher* watcher); | |
| 466 void RegisterIOHandler(HANDLE file_handle, IOHandler* handler); | 465 void RegisterIOHandler(HANDLE file_handle, IOHandler* handler); |
| 467 void RegisterIOContext(OVERLAPPED* context, IOHandler* handler); | 466 bool WaitForIOCompletion(DWORD timeout, IOHandler* filter); |
| 468 | 467 |
| 469 protected: | 468 protected: |
| 470 // TODO(rvargas): Make this platform independent. | 469 // TODO(rvargas): Make this platform independent. |
| 471 base::MessagePumpForIO* pump_io() { | 470 base::MessagePumpForIO* pump_io() { |
| 472 return static_cast<base::MessagePumpForIO*>(pump_.get()); | 471 return static_cast<base::MessagePumpForIO*>(pump_.get()); |
| 473 } | 472 } |
| 474 | 473 |
| 475 #elif defined(OS_POSIX) | 474 #elif defined(OS_POSIX) |
| 476 typedef base::MessagePumpLibevent::Watcher Watcher; | 475 typedef base::MessagePumpLibevent::Watcher Watcher; |
| 477 | 476 |
| 478 // Please see MessagePumpLibevent for definitions of these methods. | 477 // Please see MessagePumpLibevent for definitions of these methods. |
| 479 void WatchSocket(int socket, short interest_mask, | 478 void WatchSocket(int socket, short interest_mask, |
| 480 struct event* e, Watcher* watcher); | 479 struct event* e, Watcher* watcher); |
| 481 void UnwatchSocket(struct event* e); | 480 void UnwatchSocket(struct event* e); |
| 482 #endif // defined(OS_POSIX) | 481 #endif // defined(OS_POSIX) |
| 483 }; | 482 }; |
| 484 | 483 |
| 485 // Do not add any member variables to MessageLoopForIO! This is important b/c | 484 // Do not add any member variables to MessageLoopForIO! This is important b/c |
| 486 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 485 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
| 487 // data that you need should be stored on the MessageLoop's pump_ instance. | 486 // data that you need should be stored on the MessageLoop's pump_ instance. |
| 488 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 487 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
| 489 MessageLoopForIO_should_not_have_extra_member_variables); | 488 MessageLoopForIO_should_not_have_extra_member_variables); |
| 490 | 489 |
| 491 #endif // BASE_MESSAGE_LOOP_H_ | 490 #endif // BASE_MESSAGE_LOOP_H_ |
| OLD | NEW |