OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_ | 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_ |
6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_ | 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_ |
7 | 7 |
8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_pump.h" | 10 #include "base/message_loop/message_pump.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 | 13 |
14 typedef struct _GMainContext GMainContext; | 14 typedef struct _GMainContext GMainContext; |
15 typedef struct _GPollFD GPollFD; | 15 typedef struct _GPollFD GPollFD; |
16 typedef struct _GSource GSource; | 16 typedef struct _GSource GSource; |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 | 19 |
20 // This class implements a base MessagePump needed for TYPE_UI MessageLoops on | 20 // This class implements a base MessagePump needed for TYPE_UI MessageLoops on |
21 // platforms using GLib. | 21 // platforms using GLib. |
22 class BASE_EXPORT MessagePumpGlib : public MessagePump { | 22 class BASE_EXPORT MessagePumpGlib : public MessagePump { |
23 public: | 23 public: |
24 MessagePumpGlib(); | 24 MessagePumpGlib(); |
25 virtual ~MessagePumpGlib(); | 25 ~MessagePumpGlib() override; |
26 | 26 |
27 // Internal methods used for processing the pump callbacks. They are | 27 // Internal methods used for processing the pump callbacks. They are |
28 // public for simplicity but should not be used directly. HandlePrepare | 28 // public for simplicity but should not be used directly. HandlePrepare |
29 // is called during the prepare step of glib, and returns a timeout that | 29 // is called during the prepare step of glib, and returns a timeout that |
30 // will be passed to the poll. HandleCheck is called after the poll | 30 // will be passed to the poll. HandleCheck is called after the poll |
31 // has completed, and returns whether or not HandleDispatch should be called. | 31 // has completed, and returns whether or not HandleDispatch should be called. |
32 // HandleDispatch is called if HandleCheck returned true. | 32 // HandleDispatch is called if HandleCheck returned true. |
33 int HandlePrepare(); | 33 int HandlePrepare(); |
34 bool HandleCheck(); | 34 bool HandleCheck(); |
35 void HandleDispatch(); | 35 void HandleDispatch(); |
36 | 36 |
37 // Overridden from MessagePump: | 37 // Overridden from MessagePump: |
38 virtual void Run(Delegate* delegate) override; | 38 void Run(Delegate* delegate) override; |
39 virtual void Quit() override; | 39 void Quit() override; |
40 virtual void ScheduleWork() override; | 40 void ScheduleWork() override; |
41 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override; | 41 void ScheduleDelayedWork(const TimeTicks& delayed_work_time) override; |
42 | 42 |
43 private: | 43 private: |
44 bool ShouldQuit() const; | 44 bool ShouldQuit() const; |
45 | 45 |
46 // We may make recursive calls to Run, so we save state that needs to be | 46 // We may make recursive calls to Run, so we save state that needs to be |
47 // separate between them in this structure type. | 47 // separate between them in this structure type. |
48 struct RunState; | 48 struct RunState; |
49 | 49 |
50 RunState* state_; | 50 RunState* state_; |
51 | 51 |
(...skipping 17 matching lines...) Expand all Loading... |
69 int wakeup_pipe_write_; | 69 int wakeup_pipe_write_; |
70 // Use a scoped_ptr to avoid needing the definition of GPollFD in the header. | 70 // Use a scoped_ptr to avoid needing the definition of GPollFD in the header. |
71 scoped_ptr<GPollFD> wakeup_gpollfd_; | 71 scoped_ptr<GPollFD> wakeup_gpollfd_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(MessagePumpGlib); | 73 DISALLOW_COPY_AND_ASSIGN(MessagePumpGlib); |
74 }; | 74 }; |
75 | 75 |
76 } // namespace base | 76 } // namespace base |
77 | 77 |
78 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_ | 78 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_GLIB_H_ |
OLD | NEW |