Home | History | Annotate | Download | only in ozone
      1 // Copyright (c) 2013 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 UI_EVENTS_OZONE_EVENT_CONVERTER_OZONE_H_
      6 #define UI_EVENTS_OZONE_EVENT_CONVERTER_OZONE_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 #include "base/message_loop/message_pump_libevent.h"
     10 #include "ui/events/events_export.h"
     11 
     12 namespace ui {
     13 class Event;
     14 
     15 // In ozone, Chrome reads events from file descriptors created from Linux device
     16 // drivers. The |MessagePumpLibevent::Watcher| parent class provides the
     17 // functionality to watch a file descriptor for the arrival of new data and
     18 // notify its subclasses. Device-specific event converters turn bytes read from
     19 // the file descriptor into |ui::Event| instances. This class provides the
     20 // functionality needed in common across all converters: dispatching the
     21 // |ui::Event| to aura.
     22 class EVENTS_EXPORT EventConverterOzone
     23     : public base::MessagePumpLibevent::Watcher {
     24  public:
     25   EventConverterOzone();
     26   virtual ~EventConverterOzone();
     27 
     28  protected:
     29   // Subclasses should use this method to post a task that will dispatch
     30   // |event| from the UI message loop. This method takes ownership of
     31   // |event|. |event| will be deleted at the end of the posted task.
     32   virtual void DispatchEvent(scoped_ptr<ui::Event> event);
     33 
     34  private:
     35   DISALLOW_COPY_AND_ASSIGN(EventConverterOzone);
     36 };
     37 
     38 }  // namespace ui
     39 
     40 #endif  // UI_EVENTS_OZONE_EVENT_CONVERTER_OZONE_H_
     41