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 11 matching lines...) Expand all Loading... |
22 // Mojo implementation of MessagePump. | 22 // Mojo implementation of MessagePump. |
23 class MOJO_COMMON_EXPORT MessagePumpMojo : public base::MessagePump { | 23 class MOJO_COMMON_EXPORT MessagePumpMojo : public base::MessagePump { |
24 public: | 24 public: |
25 MessagePumpMojo(); | 25 MessagePumpMojo(); |
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 // Returns the MessagePumpMojo instance of the current thread, if it exists. |
| 33 static MessagePumpMojo* current(); |
| 34 |
| 35 static bool IsCurrent() { return !!current(); } |
| 36 |
32 // Registers a MessagePumpMojoHandler for the specified handle. Only one | 37 // Registers a MessagePumpMojoHandler for the specified handle. Only one |
33 // handler can be registered for a specified handle. | 38 // handler can be registered for a specified handle. |
34 // NOTE: a value of 0 for |deadline| indicates an indefinite timeout. | 39 // NOTE: a value of 0 for |deadline| indicates an indefinite timeout. |
35 void AddHandler(MessagePumpMojoHandler* handler, | 40 void AddHandler(MessagePumpMojoHandler* handler, |
36 const Handle& handle, | 41 const Handle& handle, |
37 MojoHandleSignals wait_signals, | 42 MojoHandleSignals wait_signals, |
38 base::TimeTicks deadline); | 43 base::TimeTicks deadline); |
39 | 44 |
40 void RemoveHandler(const Handle& handle); | 45 void RemoveHandler(const Handle& handle); |
41 | 46 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // notify it. | 104 // notify it. |
100 int next_handler_id_; | 105 int next_handler_id_; |
101 | 106 |
102 DISALLOW_COPY_AND_ASSIGN(MessagePumpMojo); | 107 DISALLOW_COPY_AND_ASSIGN(MessagePumpMojo); |
103 }; | 108 }; |
104 | 109 |
105 } // namespace common | 110 } // namespace common |
106 } // namespace mojo | 111 } // namespace mojo |
107 | 112 |
108 #endif // MOJO_COMMON_MESSAGE_PUMP_MOJO_H_ | 113 #endif // MOJO_COMMON_MESSAGE_PUMP_MOJO_H_ |
OLD | NEW |