summaryrefslogtreecommitdiffstats
path: root/mojo/common/message_pump_mojo.h
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-23 19:04:19 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-23 19:04:19 +0000
commita6881fd2964534fefe923c19fa583e3a3b905558 (patch)
treec13f43ea9e799b7f999a9c2e4fdc3eba2b86d6ec /mojo/common/message_pump_mojo.h
parentf5bb7644f532f263921483dc4593e0bf9e5011b8 (diff)
downloadchromium_src-a6881fd2964534fefe923c19fa583e3a3b905558.zip
chromium_src-a6881fd2964534fefe923c19fa583e3a3b905558.tar.gz
chromium_src-a6881fd2964534fefe923c19fa583e3a3b905558.tar.bz2
Implements HandleWatcher in terms of MessagePumpMojo
BUG=none TEST=none R=darin@chromium.org Review URL: https://codereview.chromium.org/69883008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236954 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/common/message_pump_mojo.h')
-rw-r--r--mojo/common/message_pump_mojo.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/mojo/common/message_pump_mojo.h b/mojo/common/message_pump_mojo.h
index 4eba660..3d12eee 100644
--- a/mojo/common/message_pump_mojo.h
+++ b/mojo/common/message_pump_mojo.h
@@ -8,6 +8,7 @@
#include <map>
#include "base/message_loop/message_pump.h"
+#include "base/time/time.h"
#include "mojo/common/mojo_common_export.h"
#include "mojo/public/system/core.h"
@@ -23,13 +24,11 @@ class MOJO_COMMON_EXPORT MessagePumpMojo : public base::MessagePump {
virtual ~MessagePumpMojo();
// Registers a MessagePumpMojoHandler for the specified handle. Only one
- // handler can be registered for a specified handle. If there is an existing
- // handler registered it is clobbered and silently removed.
- // The handler is notified either when the handle is ready, or when it becomes
- // invalid. If the handle becomes invalid the handler is removed and notified.
+ // handler can be registered for a specified handle.
void AddHandler(MessagePumpMojoHandler* handler,
MojoHandle handle,
- MojoWaitFlags wait_flags);
+ MojoWaitFlags wait_flags,
+ base::TimeTicks deadline);
void RemoveHandler(MojoHandle handle);
@@ -47,10 +46,13 @@ class MOJO_COMMON_EXPORT MessagePumpMojo : public base::MessagePump {
// Creates a MessagePumpMojoHandler and the set of MojoWaitFlags it was
// registered with.
struct Handler {
- Handler() : handler(NULL), wait_flags(MOJO_WAIT_FLAG_NONE) {}
+ Handler() : handler(NULL), wait_flags(MOJO_WAIT_FLAG_NONE), id(0) {}
MessagePumpMojoHandler* handler;
MojoWaitFlags wait_flags;
+ base::TimeTicks deadline;
+ // See description of |MessagePumpMojo::next_handler_id_| for details.
+ int id;
};
typedef std::map<MojoHandle, Handler> HandleToHandler;
@@ -67,12 +69,22 @@ class MOJO_COMMON_EXPORT MessagePumpMojo : public base::MessagePump {
WaitState GetWaitState() const;
+ // Returns the deadline for the call to MojoWaitMany().
+ MojoDeadline GetDeadlineForWait() const;
+
// If non-NULL we're running (inside Run()). Member is reference to value on
// stack.
RunState* run_state_;
HandleToHandler handlers_;
+ // An ever increasing value assigned to each Handler::id. Used to detect
+ // uniqueness while notifying. That is, while notifying expired timers we copy
+ // |handlers_| and only notify handlers whose id match. If the id does not
+ // match it means the handler was removed then added so that we shouldn't
+ // notify it.
+ int next_handler_id_;
+
DISALLOW_COPY_AND_ASSIGN(MessagePumpMojo);
};