| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef RUNTIME_BIN_EVENTHANDLER_ANDROID_H_ | 5 #ifndef RUNTIME_BIN_EVENTHANDLER_ANDROID_H_ |
| 6 #define RUNTIME_BIN_EVENTHANDLER_ANDROID_H_ | 6 #define RUNTIME_BIN_EVENTHANDLER_ANDROID_H_ |
| 7 | 7 |
| 8 #if !defined(RUNTIME_BIN_EVENTHANDLER_H_) | 8 #if !defined(RUNTIME_BIN_EVENTHANDLER_H_) |
| 9 #error Do not include eventhandler_android.h directly; | 9 #error Do not include eventhandler_android.h directly; |
| 10 #error use eventhandler.h instead. | 10 #error use eventhandler.h instead. |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include <errno.h> | 13 #include <errno.h> |
| 14 #include <sys/epoll.h> | 14 #include <sys/epoll.h> |
| 15 #include <sys/socket.h> | 15 #include <sys/socket.h> |
| 16 #include <unistd.h> | 16 #include <unistd.h> |
| 17 | 17 |
| 18 #include "platform/hashmap.h" | 18 #include "platform/hashmap.h" |
| 19 #include "platform/signal_blocker.h" | 19 #include "platform/signal_blocker.h" |
| 20 | 20 |
| 21 namespace dart { | 21 namespace dart { |
| 22 namespace bin { | 22 namespace bin { |
| 23 | 23 |
| 24 class DescriptorInfo : public DescriptorInfoBase { | 24 class DescriptorInfo : public DescriptorInfoBase { |
| 25 public: | 25 public: |
| 26 explicit DescriptorInfo(intptr_t fd) : DescriptorInfoBase(fd) { } | 26 explicit DescriptorInfo(intptr_t fd) : DescriptorInfoBase(fd) {} |
| 27 | 27 |
| 28 virtual ~DescriptorInfo() { } | 28 virtual ~DescriptorInfo() {} |
| 29 | 29 |
| 30 intptr_t GetPollEvents(); | 30 intptr_t GetPollEvents(); |
| 31 | 31 |
| 32 virtual void Close() { | 32 virtual void Close() { |
| 33 VOID_TEMP_FAILURE_RETRY(close(fd_)); | 33 VOID_TEMP_FAILURE_RETRY(close(fd_)); |
| 34 fd_ = -1; | 34 fd_ = -1; |
| 35 } | 35 } |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 DISALLOW_COPY_AND_ASSIGN(DescriptorInfo); | 38 DISALLOW_COPY_AND_ASSIGN(DescriptorInfo); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 | 41 |
| 42 class DescriptorInfoSingle | 42 class DescriptorInfoSingle : public DescriptorInfoSingleMixin<DescriptorInfo> { |
| 43 : public DescriptorInfoSingleMixin<DescriptorInfo> { | |
| 44 public: | 43 public: |
| 45 explicit DescriptorInfoSingle(intptr_t fd) | 44 explicit DescriptorInfoSingle(intptr_t fd) |
| 46 : DescriptorInfoSingleMixin(fd, false) {} | 45 : DescriptorInfoSingleMixin(fd, false) {} |
| 47 virtual ~DescriptorInfoSingle() {} | 46 virtual ~DescriptorInfoSingle() {} |
| 48 | 47 |
| 49 private: | 48 private: |
| 50 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoSingle); | 49 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoSingle); |
| 51 }; | 50 }; |
| 52 | 51 |
| 53 | 52 |
| 54 class DescriptorInfoMultiple | 53 class DescriptorInfoMultiple |
| 55 : public DescriptorInfoMultipleMixin<DescriptorInfo> { | 54 : public DescriptorInfoMultipleMixin<DescriptorInfo> { |
| 56 public: | 55 public: |
| 57 explicit DescriptorInfoMultiple(intptr_t fd) | 56 explicit DescriptorInfoMultiple(intptr_t fd) |
| 58 : DescriptorInfoMultipleMixin(fd, false) {} | 57 : DescriptorInfoMultipleMixin(fd, false) {} |
| 59 virtual ~DescriptorInfoMultiple() {} | 58 virtual ~DescriptorInfoMultiple() {} |
| 60 | 59 |
| 61 private: | 60 private: |
| 62 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoMultiple); | 61 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoMultiple); |
| 63 }; | 62 }; |
| 64 | 63 |
| 65 | 64 |
| 66 class EventHandlerImplementation { | 65 class EventHandlerImplementation { |
| 67 public: | 66 public: |
| 68 EventHandlerImplementation(); | 67 EventHandlerImplementation(); |
| 69 ~EventHandlerImplementation(); | 68 ~EventHandlerImplementation(); |
| 70 | 69 |
| 71 void UpdateEpollInstance(intptr_t old_mask, DescriptorInfo *di); | 70 void UpdateEpollInstance(intptr_t old_mask, DescriptorInfo* di); |
| 72 | 71 |
| 73 // Gets the socket data structure for a given file | 72 // Gets the socket data structure for a given file |
| 74 // descriptor. Creates a new one if one is not found. | 73 // descriptor. Creates a new one if one is not found. |
| 75 DescriptorInfo* GetDescriptorInfo(intptr_t fd, bool is_listening); | 74 DescriptorInfo* GetDescriptorInfo(intptr_t fd, bool is_listening); |
| 76 void SendData(intptr_t id, Dart_Port dart_port, int64_t data); | 75 void SendData(intptr_t id, Dart_Port dart_port, int64_t data); |
| 77 void Start(EventHandler* handler); | 76 void Start(EventHandler* handler); |
| 78 void Shutdown(); | 77 void Shutdown(); |
| 79 | 78 |
| 80 private: | 79 private: |
| 81 int64_t GetTimeout(); | 80 int64_t GetTimeout(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 95 int interrupt_fds_[2]; | 94 int interrupt_fds_[2]; |
| 96 int epoll_fd_; | 95 int epoll_fd_; |
| 97 | 96 |
| 98 DISALLOW_COPY_AND_ASSIGN(EventHandlerImplementation); | 97 DISALLOW_COPY_AND_ASSIGN(EventHandlerImplementation); |
| 99 }; | 98 }; |
| 100 | 99 |
| 101 } // namespace bin | 100 } // namespace bin |
| 102 } // namespace dart | 101 } // namespace dart |
| 103 | 102 |
| 104 #endif // RUNTIME_BIN_EVENTHANDLER_ANDROID_H_ | 103 #endif // RUNTIME_BIN_EVENTHANDLER_ANDROID_H_ |
| OLD | NEW |