Chromium Code Reviews| Index: dart/runtime/bin/eventhandler_android.h |
| diff --git a/dart/runtime/bin/eventhandler_android.h b/dart/runtime/bin/eventhandler_android.h |
| index 2eee0af7997f89e108c956cde09c0bcc8547eb9a..bd8848664b9fd6d6a14ea0affe0642c4aacc4515 100644 |
| --- a/dart/runtime/bin/eventhandler_android.h |
| +++ b/dart/runtime/bin/eventhandler_android.h |
| @@ -22,60 +22,35 @@ |
| namespace dart { |
| namespace bin { |
| -class InterruptMessage { |
| +class DescriptorInfoAndroid : public DescriptorInfo { |
|
Søren Gjesse
2015/02/02 10:56:14
How about just calling the class DescriptorInfo he
kustermann
2015/02/03 10:45:35
Done. Also renamed the other two to Mixins.
|
| public: |
| - intptr_t id; |
| - Dart_Port dart_port; |
| - int64_t data; |
| -}; |
| + explicit DescriptorInfoAndroid(intptr_t fd) : DescriptorInfo(fd) { } |
| + virtual ~DescriptorInfoAndroid() { } |
| -class SocketData { |
| - public: |
| - explicit SocketData(intptr_t fd) |
| - : fd_(fd), port_(0), mask_(0), tokens_(16) { |
| - ASSERT(fd_ != -1); |
| - } |
| intptr_t GetPollEvents(); |
| - void Close() { |
| - port_ = 0; |
| - mask_ = 0; |
| + virtual void Close() { |
| VOID_TEMP_FAILURE_RETRY(close(fd_)); |
| fd_ = -1; |
| } |
| +}; |
| - void SetPortAndMask(Dart_Port port, intptr_t mask) { |
| - ASSERT(fd_ != -1); |
| - port_ = port; |
| - mask_ = mask; |
| - } |
| - |
| - intptr_t fd() { return fd_; } |
| - Dart_Port port() { return port_; } |
| - |
| - bool IsListeningSocket() { return (mask_ & (1 << kListeningSocket)) != 0; } |
| - |
| - // Returns true if the last token was taken. |
| - bool TakeToken() { |
| - ASSERT(tokens_ > 0); |
| - tokens_--; |
| - return tokens_ == 0; |
| - } |
| +class DescriptorInfoSingleLinux |
|
Søren Gjesse
2015/02/02 10:56:14
DescriptorInfoSingleLinux -> DescriptorInfoSingle
kustermann
2015/02/03 10:45:35
Done.
|
| + : public DescriptorInfoSingle<DescriptorInfoLinux> { |
| + public: |
| + explicit DescriptorInfoSingleLinux(intptr_t fd) : DescriptorInfoSingle(fd) { } |
| + virtual ~DescriptorInfoSingleLinux() { } |
| +}; |
| - // Returns true if the tokens was 0 before adding. |
| - bool ReturnToken() { |
| - ASSERT(tokens_ >= 0); |
| - tokens_++; |
| - return tokens_ == 1; |
| - } |
| - private: |
| - intptr_t fd_; |
| - Dart_Port port_; |
| - intptr_t mask_; |
| - int tokens_; |
| +class DescriptorInfoMultipleLinux |
|
Søren Gjesse
2015/02/02 10:56:14
Ditto.
kustermann
2015/02/03 10:45:35
Done.
|
| + : public DescriptorInfoMultiple<DescriptorInfoLinux> { |
| + public: |
| + explicit DescriptorInfoMultipleLinux(intptr_t fd) |
| + : DescriptorInfoMultiple(fd) {} |
| + virtual ~DescriptorInfoMultipleLinux() {} |
| }; |
| @@ -86,8 +61,9 @@ class EventHandlerImplementation { |
| // Gets the socket data structure for a given file |
| // descriptor. Creates a new one if one is not found. |
| - SocketData* GetSocketData(intptr_t fd); |
| - void SendData(intptr_t id, Dart_Port dart_port, intptr_t data); |
| + DescriptorInfoAndroid* GetDescriptorInfoAndroid( |
| + intptr_t fd, bool is_listening); |
| + void SendData(intptr_t id, Dart_Port dart_port, int64_t data); |
| void Start(EventHandler* handler); |
| void Shutdown(); |
| @@ -99,7 +75,7 @@ class EventHandlerImplementation { |
| void WakeupHandler(intptr_t id, Dart_Port dart_port, int64_t data); |
| void HandleInterruptFd(); |
| void SetPort(intptr_t fd, Dart_Port dart_port, intptr_t mask); |
| - intptr_t GetPollEvents(intptr_t events, SocketData* sd); |
| + intptr_t GetPollEvents(intptr_t events, DescriptorInfoAndroid* sd); |
| static void* GetHashmapKeyFromFd(intptr_t fd); |
| static uint32_t GetHashmapHashFromFd(intptr_t fd); |