Media Galleries API Metadata: Fix bugs in utility process cleanup.
[chromium-blink-merge.git] / ui / events / ozone / event_factory_ozone.h
blob438a57f59849ee3273be9946c9b077190d77a406
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.
5 #ifndef UI_EVENTS_OZONE_EVENT_FACTORY_OZONE_H_
6 #define UI_EVENTS_OZONE_EVENT_FACTORY_OZONE_H_
8 #include <map>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_pump_libevent.h"
12 #include "base/task_runner.h"
13 #include "ui/events/events_export.h"
15 namespace ui {
17 class Event;
19 // Creates and dispatches |ui.Event|'s. Ozone assumes that events arrive on file
20 // descriptors with one |EventConverterOzone| instance for each descriptor.
21 // Ozone presumes that the set of file desctiprtors can vary at runtime so this
22 // class supports dynamically adding and removing |EventConverterOzone|
23 // instances as necessary.
24 class EVENTS_EXPORT EventFactoryOzone {
25 public:
26 EventFactoryOzone();
27 virtual ~EventFactoryOzone();
29 // Called from WindowTreeHostOzone to initialize and start processing events.
30 // This should create the initial set of converters, and potentially arrange
31 // for more converters to be created as new event sources become available.
32 // No events processing should happen until this is called. All processes have
33 // an EventFactoryOzone but not all of them should process events. In chrome,
34 // events are dispatched in the browser process on the UI thread.
35 virtual void StartProcessingEvents();
37 // Sets the TaskRunner to use for file I/O. The thread that calls
38 // StartProcessingEvents() should only be used for I/O that is critical
39 // to event dispatching.
40 virtual void SetFileTaskRunner(scoped_refptr<base::TaskRunner> task_runner);
42 // Returns the static instance last set using SetInstance().
43 static EventFactoryOzone* GetInstance();
45 // Sets the implementation delegate. Ownership is retained by the caller.
46 static void SetInstance(EventFactoryOzone*);
48 // Subclasses should use this method to post a task that will dispatch
49 // |event| from the UI message loop. This method takes ownership of
50 // |event|. |event| will be deleted at the end of the posted task.
51 static void DispatchEvent(scoped_ptr<ui::Event> event);
53 private:
54 static EventFactoryOzone* impl_; // not owned
56 DISALLOW_COPY_AND_ASSIGN(EventFactoryOzone);
59 } // namespace ui
61 #endif // UI_EVENTS_OZONE_EVENT_FACTORY_OZONE_H_