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

Unified Diff: message_loop/message_pump_libevent.h

Issue 1921183002: Add a mechanism to extend a libevent based message pump. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/domokit/base@master
Patch Set: added test case Created 4 years, 7 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 | « message_loop/message_loop.cc ('k') | message_loop/message_pump_libevent.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: message_loop/message_pump_libevent.h
diff --git a/message_loop/message_pump_libevent.h b/message_loop/message_pump_libevent.h
index 8b815aea588294002662dddb2c83f873e6240d6f..d35d1bdb1308cd9b7536e774c09d6da74587dcaa 100644
--- a/message_loop/message_pump_libevent.h
+++ b/message_loop/message_pump_libevent.h
@@ -37,6 +37,18 @@ class BASE_EXPORT MessagePumpLibevent : public MessagePump {
virtual ~IOObserver() {}
};
+ // Called to poll for events during each loop.
+ // Should return true if any events were processed.
+ class EventSource {
+ public:
+ EventSource() {}
+
+ virtual bool Poll() = 0;
+
+ protected:
+ virtual ~EventSource() {}
+ };
+
// Used with WatchFileDescriptor to asynchronously monitor the I/O readiness
// of a file descriptor.
class Watcher {
@@ -122,6 +134,9 @@ class BASE_EXPORT MessagePumpLibevent : public MessagePump {
void AddIOObserver(IOObserver* obs);
void RemoveIOObserver(IOObserver* obs);
+ void SetEventSource(EventSource* event_source);
+ void ClearEventSource();
+
// MessagePump methods:
void Run(Delegate* delegate) override;
void Quit() override;
@@ -134,6 +149,8 @@ class BASE_EXPORT MessagePumpLibevent : public MessagePump {
void WillProcessIOEvent();
void DidProcessIOEvent();
+ bool PollEventSource();
+
// Risky part of constructor. Returns true on success.
bool Init();
@@ -169,6 +186,7 @@ class BASE_EXPORT MessagePumpLibevent : public MessagePump {
event* wakeup_event_;
ObserverList<IOObserver> io_observers_;
+ EventSource* event_source_;
ThreadChecker watch_file_descriptor_caller_checker_;
DISALLOW_COPY_AND_ASSIGN(MessagePumpLibevent);
};
« no previous file with comments | « message_loop/message_loop.cc ('k') | message_loop/message_pump_libevent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698