1eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// Copyright 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#ifndef CONTENT_PUBLIC_TEST_NESTED_MESSAGE_PUMP_ANDROID_
6eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#define CONTENT_PUBLIC_TEST_NESTED_MESSAGE_PUMP_ANDROID_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/android/jni_android.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/compiler_specific.h"
107d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/message_loop/message_pump_android.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace content {
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
14eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// A nested message pump to be used for content browsertests and layout tests
15eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// on Android. It overrides the default UI message pump to allow nested loops.
16eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochclass NestedMessagePumpAndroid : public base::MessagePumpForUI {
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
18eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  NestedMessagePumpAndroid();
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void Run(Delegate* delegate) OVERRIDE;
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void Quit() OVERRIDE;
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void ScheduleWork() OVERRIDE;
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void ScheduleDelayedWork(
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      const base::TimeTicks& delayed_work_time) OVERRIDE;
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void Start(Delegate* delegate) OVERRIDE;
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static bool RegisterJni(JNIEnv* env);
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) protected:
30eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  virtual ~NestedMessagePumpAndroid();
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // We may make recursive calls to Run, so we save state that needs to be
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // separate between them in this structure type.
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  struct RunState;
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  RunState* state_;
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
39eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  DISALLOW_COPY_AND_ASSIGN(NestedMessagePumpAndroid);
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace content
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
44eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#endif  // CONTENT_PUBLIC_TEST_NESTED_MESSAGE_PUMP_ANDROID_
45