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 BIN_EVENTHANDLER_ANDROID_H_ | 5 #ifndef BIN_EVENTHANDLER_ANDROID_H_ |
6 #define BIN_EVENTHANDLER_ANDROID_H_ | 6 #define BIN_EVENTHANDLER_ANDROID_H_ |
7 | 7 |
8 #if !defined(BIN_EVENTHANDLER_H_) | 8 #if !defined(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 | |
22 namespace dart { | 21 namespace dart { |
23 namespace bin { | 22 namespace bin { |
24 | 23 |
25 class DescriptorInfo : public DescriptorInfoBase { | 24 class DescriptorInfo : public DescriptorInfoBase { |
26 public: | 25 public: |
27 explicit DescriptorInfo(intptr_t fd) : DescriptorInfoBase(fd) { } | 26 explicit DescriptorInfo(intptr_t fd) : DescriptorInfoBase(fd) { } |
28 | 27 |
29 virtual ~DescriptorInfo() { } | 28 virtual ~DescriptorInfo() { } |
30 | 29 |
31 intptr_t GetPollEvents(); | 30 intptr_t GetPollEvents(); |
32 | 31 |
33 virtual void Close() { | 32 virtual void Close() { |
34 VOID_TEMP_FAILURE_RETRY(close(fd_)); | 33 VOID_TEMP_FAILURE_RETRY(close(fd_)); |
35 fd_ = -1; | 34 fd_ = -1; |
36 } | 35 } |
| 36 |
| 37 private: |
| 38 DISALLOW_COPY_AND_ASSIGN(DescriptorInfo); |
37 }; | 39 }; |
38 | 40 |
39 | 41 |
40 class DescriptorInfoSingle | 42 class DescriptorInfoSingle |
41 : public DescriptorInfoSingleMixin<DescriptorInfo> { | 43 : public DescriptorInfoSingleMixin<DescriptorInfo> { |
42 public: | 44 public: |
43 explicit DescriptorInfoSingle(intptr_t fd) | 45 explicit DescriptorInfoSingle(intptr_t fd) |
44 : DescriptorInfoSingleMixin(fd, false) {} | 46 : DescriptorInfoSingleMixin(fd, false) {} |
45 virtual ~DescriptorInfoSingle() {} | 47 virtual ~DescriptorInfoSingle() {} |
| 48 |
| 49 private: |
| 50 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoSingle); |
46 }; | 51 }; |
47 | 52 |
48 | 53 |
49 class DescriptorInfoMultiple | 54 class DescriptorInfoMultiple |
50 : public DescriptorInfoMultipleMixin<DescriptorInfo> { | 55 : public DescriptorInfoMultipleMixin<DescriptorInfo> { |
51 public: | 56 public: |
52 explicit DescriptorInfoMultiple(intptr_t fd) | 57 explicit DescriptorInfoMultiple(intptr_t fd) |
53 : DescriptorInfoMultipleMixin(fd, false) {} | 58 : DescriptorInfoMultipleMixin(fd, false) {} |
54 virtual ~DescriptorInfoMultiple() {} | 59 virtual ~DescriptorInfoMultiple() {} |
| 60 |
| 61 private: |
| 62 DISALLOW_COPY_AND_ASSIGN(DescriptorInfoMultiple); |
55 }; | 63 }; |
56 | 64 |
57 | 65 |
58 class EventHandlerImplementation { | 66 class EventHandlerImplementation { |
59 public: | 67 public: |
60 EventHandlerImplementation(); | 68 EventHandlerImplementation(); |
61 ~EventHandlerImplementation(); | 69 ~EventHandlerImplementation(); |
62 | 70 |
63 void UpdateEpollInstance(intptr_t old_mask, DescriptorInfo *di); | 71 void UpdateEpollInstance(intptr_t old_mask, DescriptorInfo *di); |
64 | 72 |
(...skipping 14 matching lines...) Expand all Loading... |
79 void SetPort(intptr_t fd, Dart_Port dart_port, intptr_t mask); | 87 void SetPort(intptr_t fd, Dart_Port dart_port, intptr_t mask); |
80 intptr_t GetPollEvents(intptr_t events, DescriptorInfo* di); | 88 intptr_t GetPollEvents(intptr_t events, DescriptorInfo* di); |
81 static void* GetHashmapKeyFromFd(intptr_t fd); | 89 static void* GetHashmapKeyFromFd(intptr_t fd); |
82 static uint32_t GetHashmapHashFromFd(intptr_t fd); | 90 static uint32_t GetHashmapHashFromFd(intptr_t fd); |
83 | 91 |
84 HashMap socket_map_; | 92 HashMap socket_map_; |
85 TimeoutQueue timeout_queue_; | 93 TimeoutQueue timeout_queue_; |
86 bool shutdown_; | 94 bool shutdown_; |
87 int interrupt_fds_[2]; | 95 int interrupt_fds_[2]; |
88 int epoll_fd_; | 96 int epoll_fd_; |
| 97 |
| 98 DISALLOW_COPY_AND_ASSIGN(EventHandlerImplementation); |
89 }; | 99 }; |
90 | 100 |
91 } // namespace bin | 101 } // namespace bin |
92 } // namespace dart | 102 } // namespace dart |
93 | 103 |
94 #endif // BIN_EVENTHANDLER_ANDROID_H_ | 104 #endif // BIN_EVENTHANDLER_ANDROID_H_ |
OLD | NEW |