OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 MOJO_COMMON_MESSAGE_PUMP_MOJO_H_ | 5 #ifndef MOJO_COMMON_MESSAGE_PUMP_MOJO_H_ |
6 #define MOJO_COMMON_MESSAGE_PUMP_MOJO_H_ | 6 #define MOJO_COMMON_MESSAGE_PUMP_MOJO_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 virtual ~MessagePumpMojo(); | 26 virtual ~MessagePumpMojo(); |
27 | 27 |
28 // Static factory function (for using with |base::Thread::Options|, wrapped | 28 // Static factory function (for using with |base::Thread::Options|, wrapped |
29 // using |base::Bind()|). | 29 // using |base::Bind()|). |
30 static scoped_ptr<base::MessagePump> Create(); | 30 static scoped_ptr<base::MessagePump> Create(); |
31 | 31 |
32 // Registers a MessagePumpMojoHandler for the specified handle. Only one | 32 // Registers a MessagePumpMojoHandler for the specified handle. Only one |
33 // handler can be registered for a specified handle. | 33 // handler can be registered for a specified handle. |
34 void AddHandler(MessagePumpMojoHandler* handler, | 34 void AddHandler(MessagePumpMojoHandler* handler, |
35 const Handle& handle, | 35 const Handle& handle, |
36 MojoWaitFlags wait_flags, | 36 MojoHandleSignals wait_signals, |
37 base::TimeTicks deadline); | 37 base::TimeTicks deadline); |
38 | 38 |
39 void RemoveHandler(const Handle& handle); | 39 void RemoveHandler(const Handle& handle); |
40 | 40 |
41 // MessagePump: | 41 // MessagePump: |
42 virtual void Run(Delegate* delegate) OVERRIDE; | 42 virtual void Run(Delegate* delegate) OVERRIDE; |
43 virtual void Quit() OVERRIDE; | 43 virtual void Quit() OVERRIDE; |
44 virtual void ScheduleWork() OVERRIDE; | 44 virtual void ScheduleWork() OVERRIDE; |
45 virtual void ScheduleDelayedWork( | 45 virtual void ScheduleDelayedWork( |
46 const base::TimeTicks& delayed_work_time) OVERRIDE; | 46 const base::TimeTicks& delayed_work_time) OVERRIDE; |
47 | 47 |
48 private: | 48 private: |
49 struct RunState; | 49 struct RunState; |
50 struct WaitState; | 50 struct WaitState; |
51 | 51 |
52 // Contains the data needed to track a request to AddHandler(). | 52 // Contains the data needed to track a request to AddHandler(). |
53 struct Handler { | 53 struct Handler { |
54 Handler() : handler(NULL), wait_flags(MOJO_WAIT_FLAG_NONE), id(0) {} | 54 Handler() : handler(NULL), wait_signals(MOJO_WAIT_FLAG_NONE), id(0) {} |
55 | 55 |
56 MessagePumpMojoHandler* handler; | 56 MessagePumpMojoHandler* handler; |
57 MojoWaitFlags wait_flags; | 57 MojoHandleSignals wait_signals; |
58 base::TimeTicks deadline; | 58 base::TimeTicks deadline; |
59 // See description of |MessagePumpMojo::next_handler_id_| for details. | 59 // See description of |MessagePumpMojo::next_handler_id_| for details. |
60 int id; | 60 int id; |
61 }; | 61 }; |
62 | 62 |
63 typedef std::map<Handle, Handler> HandleToHandler; | 63 typedef std::map<Handle, Handler> HandleToHandler; |
64 | 64 |
65 // Implementation of Run(). | 65 // Implementation of Run(). |
66 void DoRunLoop(RunState* run_state, Delegate* delegate); | 66 void DoRunLoop(RunState* run_state, Delegate* delegate); |
67 | 67 |
(...skipping 30 matching lines...) Expand all Loading... |
98 // notify it. | 98 // notify it. |
99 int next_handler_id_; | 99 int next_handler_id_; |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(MessagePumpMojo); | 101 DISALLOW_COPY_AND_ASSIGN(MessagePumpMojo); |
102 }; | 102 }; |
103 | 103 |
104 } // namespace common | 104 } // namespace common |
105 } // namespace mojo | 105 } // namespace mojo |
106 | 106 |
107 #endif // MOJO_COMMON_MESSAGE_PUMP_MOJO_H_ | 107 #endif // MOJO_COMMON_MESSAGE_PUMP_MOJO_H_ |
OLD | NEW |