Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1038)

Side by Side Diff: ui/events/ozone/event_factory_ozone.cc

Issue 133233008: evdev: Move EventConverterOzone ownership from EventFactoryOzone to subclass (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unbreak events_unittests Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/events/ozone/event_factory_ozone.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/ozone/event_factory_ozone.h" 5 #include "ui/events/ozone/event_factory_ozone.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_pump_ozone.h" 8 #include "base/message_loop/message_pump_ozone.h"
9 #include "base/stl_util.h"
10 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
11 #include "ui/events/event_switches.h" 10 #include "ui/events/event_switches.h"
12 11
13 namespace ui { 12 namespace ui {
14 13
15 // static 14 // static
16 EventFactoryOzone* EventFactoryOzone::impl_ = NULL; 15 EventFactoryOzone* EventFactoryOzone::impl_ = NULL;
17 16
18 EventFactoryOzone::EventFactoryOzone() {} 17 EventFactoryOzone::EventFactoryOzone() {}
19 18
20 EventFactoryOzone::~EventFactoryOzone() { 19 EventFactoryOzone::~EventFactoryOzone() {}
21 // Always delete watchers before converters to prevent a possible race.
22 STLDeleteValues<std::map<int, FDWatcher> >(&watchers_);
23 STLDeleteValues<std::map<int, Converter> >(&converters_);
24 }
25 20
26 EventFactoryOzone* EventFactoryOzone::GetInstance() { 21 EventFactoryOzone* EventFactoryOzone::GetInstance() {
27 CHECK(impl_) << "No EventFactoryOzone implementation set."; 22 CHECK(impl_) << "No EventFactoryOzone implementation set.";
28 return impl_; 23 return impl_;
29 } 24 }
30 25
31 void EventFactoryOzone::SetInstance(EventFactoryOzone* impl) { impl_ = impl; } 26 void EventFactoryOzone::SetInstance(EventFactoryOzone* impl) { impl_ = impl; }
32 27
33 void EventFactoryOzone::StartProcessingEvents() {} 28 void EventFactoryOzone::StartProcessingEvents() {}
34 29
35 void EventFactoryOzone::AddEventConverter(
36 int fd,
37 scoped_ptr<EventConverterOzone> converter) {
38 CHECK(watchers_.count(fd) == 0 && converters_.count(fd) == 0);
39
40 FDWatcher watcher = new base::MessagePumpLibevent::FileDescriptorWatcher();
41
42 base::MessagePumpOzone::Current()->WatchFileDescriptor(
43 fd,
44 true,
45 base::MessagePumpLibevent::WATCH_READ,
46 watcher,
47 converter.get());
48
49 converters_[fd] = converter.release();
50 watchers_[fd] = watcher;
51 }
52
53 void EventFactoryOzone::RemoveEventConverter(int fd) {
54 // Always delete watchers before converters to prevent a possible race.
55 delete watchers_[fd];
56 delete converters_[fd];
57 watchers_.erase(fd);
58 converters_.erase(fd);
59 }
60
61 } // namespace ui 30 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/event_factory_ozone.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698