OLD | NEW |
---|---|
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 #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 <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
623 | 623 |
624 void AddIOObserver(IOObserver* io_observer) { | 624 void AddIOObserver(IOObserver* io_observer) { |
625 pump_io()->AddIOObserver(io_observer); | 625 pump_io()->AddIOObserver(io_observer); |
626 } | 626 } |
627 | 627 |
628 void RemoveIOObserver(IOObserver* io_observer) { | 628 void RemoveIOObserver(IOObserver* io_observer) { |
629 pump_io()->RemoveIOObserver(io_observer); | 629 pump_io()->RemoveIOObserver(io_observer); |
630 } | 630 } |
631 | 631 |
632 #if defined(OS_WIN) | 632 #if defined(OS_WIN) |
633 // Please see MessagePumpWin for definitions of these methods. | 633 // Register the handler to be used when asynchronous IO for the given file |
634 void RegisterIOHandler(HANDLE file_handle, IOHandler* handler); | 634 // completes. The registration persists as long as |file_handle| is valid, so |
635 // |handler| must be valid as long as there is pending IO for the given file. | |
636 void RegisterIOHandler(HANDLE file, IOHandler* handler); | |
637 | |
638 // Register the handler to be used to process job events. The registration | |
639 // persists as long as the job object is live, so |handler| must be valid | |
640 // until the job object is destoyed. Returns true if the registration | |
rvargas (doing something else)
2012/08/13 18:54:12
typo: destroyed
alexeypa (please no reviews)
2012/08/13 20:02:23
Done.
| |
641 // succeeded, and false otherwise. | |
642 bool RegisterJobObject(HANDLE job, IOHandler* handler); | |
643 | |
644 // Waits for the next IO completion that should be processed by |filter|, for | |
645 // up to |timeout| milliseconds. Return true if any IO operation completed, | |
646 // regardless of the involved handler, and false if the timeout expired. If | |
647 // the completion port received any message and the involved IO handler | |
648 // matches |filter|, the callback is called before returning from this code; | |
649 // if the handler is not the one that we are looking for, the callback will | |
650 // be postponed for another time, so reentrancy problems can be avoided. | |
651 // External use of this method should be reserved for the rare case when the | |
652 // caller is willing to allow pausing regular task dispatching on this thread. | |
635 bool WaitForIOCompletion(DWORD timeout, IOHandler* filter); | 653 bool WaitForIOCompletion(DWORD timeout, IOHandler* filter); |
636 | 654 |
637 protected: | 655 protected: |
638 // TODO(rvargas): Make this platform independent. | 656 // TODO(rvargas): Make this platform independent. |
639 base::MessagePumpForIO* pump_io() { | 657 base::MessagePumpForIO* pump_io() { |
640 return static_cast<base::MessagePumpForIO*>(pump_.get()); | 658 return static_cast<base::MessagePumpForIO*>(pump_.get()); |
641 } | 659 } |
642 | 660 |
643 #elif defined(OS_POSIX) | 661 #elif defined(OS_POSIX) |
644 // Please see MessagePumpLibevent for definition. | 662 // Please see MessagePumpLibevent for definition. |
(...skipping 10 matching lines...) Expand all Loading... | |
655 #endif // defined(OS_POSIX) | 673 #endif // defined(OS_POSIX) |
656 }; | 674 }; |
657 | 675 |
658 // Do not add any member variables to MessageLoopForIO! This is important b/c | 676 // Do not add any member variables to MessageLoopForIO! This is important b/c |
659 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra | 677 // MessageLoopForIO is often allocated via MessageLoop(TYPE_IO). Any extra |
660 // data that you need should be stored on the MessageLoop's pump_ instance. | 678 // data that you need should be stored on the MessageLoop's pump_ instance. |
661 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), | 679 COMPILE_ASSERT(sizeof(MessageLoop) == sizeof(MessageLoopForIO), |
662 MessageLoopForIO_should_not_have_extra_member_variables); | 680 MessageLoopForIO_should_not_have_extra_member_variables); |
663 | 681 |
664 #endif // BASE_MESSAGE_LOOP_H_ | 682 #endif // BASE_MESSAGE_LOOP_H_ |
OLD | NEW |