1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/chromium/src/base/message_pump_android.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +// Copyright (c) 2010 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#ifndef BASE_MESSAGE_PUMP_ANDROID_H_ 1.9 +#define BASE_MESSAGE_PUMP_ANDROID_H_ 1.10 + 1.11 +#include "base/message_pump.h" 1.12 +#include "base/time.h" 1.13 + 1.14 +namespace base { 1.15 + 1.16 +class MessagePumpForUI; 1.17 + 1.18 +class MessagePumpAndroid { 1.19 + 1.20 + public: 1.21 + MessagePumpAndroid(MessagePumpForUI &pump); 1.22 + ~MessagePumpAndroid(); 1.23 + 1.24 + private: 1.25 + base::MessagePumpForUI &pump; 1.26 +}; 1.27 + 1.28 +// This class implements a MessagePump needed for TYPE_UI MessageLoops on 1.29 +// Android 1.30 +class MessagePumpForUI : public MessagePump { 1.31 + 1.32 + public: 1.33 + MessagePumpForUI(); 1.34 + ~MessagePumpForUI(); 1.35 + 1.36 + virtual void Run(Delegate* delegate); 1.37 + virtual void Quit(); 1.38 + virtual void ScheduleWork(); 1.39 + virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time); 1.40 + 1.41 + // Internal methods used for processing the pump callbacks. They are 1.42 + // public for simplicity but should not be used directly. 1.43 + // HandleDispatch is called after the poll has completed. 1.44 + void HandleDispatch(); 1.45 + 1.46 + private: 1.47 + // We may make recursive calls to Run, so we save state that needs to be 1.48 + // separate between them in this structure type. 1.49 + struct RunState { 1.50 + Delegate* delegate; 1.51 + 1.52 + // Used to flag that the current Run() invocation should return ASAP. 1.53 + bool should_quit; 1.54 + 1.55 + // Used to count how many Run() invocations are on the stack. 1.56 + int run_depth; 1.57 + 1.58 + // Used internally for controlling whether we want a message pump 1.59 + // iteration to be blocking or not. 1.60 + bool more_work_is_plausible; 1.61 + }; 1.62 + 1.63 + RunState* state_; 1.64 + 1.65 + // This is the time when we need to do delayed work. 1.66 + TimeTicks delayed_work_time_; 1.67 + 1.68 + bool work_scheduled; 1.69 + 1.70 + // MessagePump implementation for Android based on the GLib implement. 1.71 + MessagePumpAndroid pump; 1.72 + 1.73 + DISALLOW_COPY_AND_ASSIGN(MessagePumpForUI); 1.74 +}; 1.75 + 1.76 +} // namespace base 1.77 + 1.78 +#endif // BASE_MESSAGE_PUMP_ANDROID_H_