| OLD | NEW | 
|---|
| 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 | 
| OLD | NEW | 
|---|