Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Unified Diff: dart/runtime/bin/eventhandler_android.h

Issue 879353003: Introduce optional 'bool shared' parameter to ServerSocket.bind() ... (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/runtime/bin/eventhandler.cc ('k') | dart/runtime/bin/eventhandler_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..51698da0d30de5bd75ed75bf925adc7c341e22bf 100644
--- a/dart/runtime/bin/eventhandler_android.h
+++ b/dart/runtime/bin/eventhandler_android.h
@@ -22,60 +22,36 @@
namespace dart {
namespace bin {
-class InterruptMessage {
+class DescriptorInfo : public DescriptorInfoBase {
public:
- intptr_t id;
- Dart_Port dart_port;
- int64_t data;
-};
-
+ explicit DescriptorInfo(intptr_t fd) : DescriptorInfoBase(fd) { }
-class SocketData {
- public:
- explicit SocketData(intptr_t fd)
- : fd_(fd), port_(0), mask_(0), tokens_(16) {
- ASSERT(fd_ != -1);
- }
+ virtual ~DescriptorInfo() { }
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 DescriptorInfoSingle
+ : public DescriptorInfoSingleMixin<DescriptorInfo> {
+ public:
+ explicit DescriptorInfoSingle(intptr_t fd)
+ : DescriptorInfoSingleMixin(fd) {}
+ virtual ~DescriptorInfoSingle() {}
+};
- // 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 DescriptorInfoMultiple
+ : public DescriptorInfoMultipleMixin<DescriptorInfo> {
+ public:
+ explicit DescriptorInfoMultiple(intptr_t fd)
+ : DescriptorInfoMultipleMixin(fd) {}
+ virtual ~DescriptorInfoMultiple() {}
};
@@ -86,8 +62,8 @@ 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);
+ DescriptorInfo* GetDescriptorInfo(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, DescriptorInfo* sd);
static void* GetHashmapKeyFromFd(intptr_t fd);
static uint32_t GetHashmapHashFromFd(intptr_t fd);
« no previous file with comments | « dart/runtime/bin/eventhandler.cc ('k') | dart/runtime/bin/eventhandler_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698