ipc/chromium/src/base/message_pump_android.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:6783768fc33b
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_MESSAGE_PUMP_ANDROID_H_
6 #define BASE_MESSAGE_PUMP_ANDROID_H_
7
8 #include "base/message_pump.h"
9 #include "base/time.h"
10
11 namespace base {
12
13 class MessagePumpForUI;
14
15 class MessagePumpAndroid {
16
17 public:
18 MessagePumpAndroid(MessagePumpForUI &pump);
19 ~MessagePumpAndroid();
20
21 private:
22 base::MessagePumpForUI &pump;
23 };
24
25 // This class implements a MessagePump needed for TYPE_UI MessageLoops on
26 // Android
27 class MessagePumpForUI : public MessagePump {
28
29 public:
30 MessagePumpForUI();
31 ~MessagePumpForUI();
32
33 virtual void Run(Delegate* delegate);
34 virtual void Quit();
35 virtual void ScheduleWork();
36 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time);
37
38 // Internal methods used for processing the pump callbacks. They are
39 // public for simplicity but should not be used directly.
40 // HandleDispatch is called after the poll has completed.
41 void HandleDispatch();
42
43 private:
44 // We may make recursive calls to Run, so we save state that needs to be
45 // separate between them in this structure type.
46 struct RunState {
47 Delegate* delegate;
48
49 // Used to flag that the current Run() invocation should return ASAP.
50 bool should_quit;
51
52 // Used to count how many Run() invocations are on the stack.
53 int run_depth;
54
55 // Used internally for controlling whether we want a message pump
56 // iteration to be blocking or not.
57 bool more_work_is_plausible;
58 };
59
60 RunState* state_;
61
62 // This is the time when we need to do delayed work.
63 TimeTicks delayed_work_time_;
64
65 bool work_scheduled;
66
67 // MessagePump implementation for Android based on the GLib implement.
68 MessagePumpAndroid pump;
69
70 DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI);
71 };
72
73 } // namespace base
74
75 #endif // BASE_MESSAGE_PUMP_ANDROID_H_

mercurial