Upstream version 10.39.233.0
[platform/framework/web/crosswalk.git] / src / ozone / wayland / display_poll_thread.h
1 // Copyright 2013 Intel Corporation. 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 OZONE_WAYLAND_DISPLAY_POLL_THREAD_H_
6 #define OZONE_WAYLAND_DISPLAY_POLL_THREAD_H_
7
8 #include "base/synchronization/waitable_event.h"
9 #include "base/threading/thread.h"
10
11 class wl_display;
12 namespace ozonewayland {
13 // This class lets you poll on a given Wayland display (passed in constructor),
14 // read any pending events coming from Wayland compositor and dispatch them.
15 // Caller should ensure that StopProcessingEvents is called before display is
16 // destroyed.
17 class WaylandDisplayPollThread : public base::Thread {
18  public:
19   explicit WaylandDisplayPollThread(wl_display* display);
20   ~WaylandDisplayPollThread() override;
21
22   // Starts polling on wl_display fd and read/flush requests coming from Wayland
23   // compositor.
24   void StartProcessingEvents();
25   // Stops polling and handling of any events from Wayland compositor.
26   void StopProcessingEvents();
27
28  protected:
29   void CleanUp() override;
30
31  private:
32   static void DisplayRun(WaylandDisplayPollThread* data);
33   base::WaitableEvent polling_;  // Is set as long as the thread is polling.
34   base::WaitableEvent stop_polling_;
35   wl_display* display_;
36   DISALLOW_COPY_AND_ASSIGN(WaylandDisplayPollThread);
37 };
38
39 }  // namespace ozonewayland
40
41 #endif