Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / mojo / common / message_pump_mojo.h
index cc21565..c761106 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "base/memory/scoped_ptr.h"
 #include "base/message_loop/message_pump.h"
+#include "base/synchronization/lock.h"
 #include "base/time/time.h"
 #include "mojo/common/mojo_common_export.h"
 #include "mojo/public/cpp/system/core.h"
@@ -61,25 +62,33 @@ class MOJO_COMMON_EXPORT MessagePumpMojo : public base::MessagePump {
 
   typedef std::map<Handle, Handler> HandleToHandler;
 
+  // Implementation of Run().
+  void DoRunLoop(RunState* run_state, Delegate* delegate);
+
   // Services the set of handles ready. If |block| is true this waits for a
   // handle to become ready, otherwise this does not block.
-  void DoInternalWork(bool block);
+  void DoInternalWork(const RunState& run_state, bool block);
 
   // Removes the first invalid handle. This is called if MojoWaitMany finds an
   // invalid handle.
   void RemoveFirstInvalidHandle(const WaitState& wait_state);
 
-  void SignalControlPipe();
+  void SignalControlPipe(const RunState& run_state);
 
-  WaitState GetWaitState() const;
+  WaitState GetWaitState(const RunState& run_state) const;
 
   // Returns the deadline for the call to MojoWaitMany().
-  MojoDeadline GetDeadlineForWait() const;
+  MojoDeadline GetDeadlineForWait(const RunState& run_state) const;
 
   // If non-NULL we're running (inside Run()). Member is reference to value on
   // stack.
   RunState* run_state_;
 
+  // Lock for accessing |run_state_|. In general the only method that we have to
+  // worry about is ScheduleWork(). All other methods are invoked on the same
+  // thread.
+  base::Lock run_state_lock_;
+
   HandleToHandler handlers_;
 
   // An ever increasing value assigned to each Handler::id. Used to detect