| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // TODO(jamiewalch): Add unit tests for this. | 5 // TODO(jamiewalch): Add unit tests for this. |
| 6 | 6 |
| 7 #include "remoting/host/posix/signal_handler.h" | 7 #include "remoting/host/posix/signal_handler.h" |
| 8 | 8 |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <signal.h> | 10 #include <signal.h> |
| 11 | 11 |
| 12 #include <list> | 12 #include <list> |
| 13 #include <utility> | 13 #include <utility> |
| 14 | 14 |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/message_loop/message_pump_libevent.h" | 17 #include "base/message_loop/message_pump_libevent.h" |
| 18 #include "base/posix/eintr_wrapper.h" | 18 #include "base/posix/eintr_wrapper.h" |
| 19 #include "base/threading/platform_thread.h" | 19 #include "base/threading/platform_thread.h" |
| 20 | 20 |
| 21 namespace remoting { | 21 namespace remoting { |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 class SignalListener : public base::MessagePumpLibevent::Watcher { | 24 class SignalListener : public base::MessagePumpLibevent::Watcher { |
| 25 public: | 25 public: |
| 26 SignalListener(); | 26 SignalListener(); |
| 27 | 27 |
| 28 void AddSignalHandler(int signal, const SignalHandler& handler); | 28 void AddSignalHandler(int signal, const SignalHandler& handler); |
| 29 | 29 |
| 30 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 30 virtual void OnFileCanReadWithoutBlocking(int fd) override; |
| 31 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE {} | 31 virtual void OnFileCanWriteWithoutBlocking(int fd) override {} |
| 32 | 32 |
| 33 // WatchFileDescriptor needs a controller through which the operation can be | 33 // WatchFileDescriptor needs a controller through which the operation can be |
| 34 // canceled. We don't use it, but this is as good a place as any to store it. | 34 // canceled. We don't use it, but this is as good a place as any to store it. |
| 35 base::MessagePumpLibevent::FileDescriptorWatcher controller; | 35 base::MessagePumpLibevent::FileDescriptorWatcher controller; |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 typedef std::pair<int, SignalHandler> SignalAndHandler; | 38 typedef std::pair<int, SignalHandler> SignalAndHandler; |
| 39 typedef std::list<SignalAndHandler> SignalHandlers; | 39 typedef std::list<SignalAndHandler> SignalHandlers; |
| 40 SignalHandlers signal_handlers_; | 40 SignalHandlers signal_handlers_; |
| 41 }; | 41 }; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 108 } |
| 109 if (signal(signal_number, GlobalSignalHandler) == SIG_ERR) { | 109 if (signal(signal_number, GlobalSignalHandler) == SIG_ERR) { |
| 110 LOG(ERROR) << "signal() failed: " << errno; | 110 LOG(ERROR) << "signal() failed: " << errno; |
| 111 return false; | 111 return false; |
| 112 } | 112 } |
| 113 g_signal_listener->AddSignalHandler(signal_number, handler); | 113 g_signal_listener->AddSignalHandler(signal_number, handler); |
| 114 return true; | 114 return true; |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace remoting | 117 } // namespace remoting |
| OLD | NEW |