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

Unified Diff: runtime/bin/eventhandler_fuchsia.h

Issue 2515643004: Fuchsia: Partial implementation of dart:io sockets (Closed)
Patch Set: Formatting Created 4 years, 1 month 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 | « runtime/bin/builtin_impl_sources.gypi ('k') | runtime/bin/eventhandler_fuchsia.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_fuchsia.h
diff --git a/runtime/bin/eventhandler_fuchsia.h b/runtime/bin/eventhandler_fuchsia.h
index acd47937460dd17a2edf7dc5f2c16f3322e58fea..545fdb8fab4acf53bf4259ab3d35b087b331e325 100644
--- a/runtime/bin/eventhandler_fuchsia.h
+++ b/runtime/bin/eventhandler_fuchsia.h
@@ -10,7 +10,9 @@
#endif
#include <errno.h>
-#include <magenta/syscalls.h>
+#include <sys/epoll.h>
+#include <sys/socket.h>
+#include <unistd.h>
#include "platform/signal_blocker.h"
@@ -23,8 +25,11 @@ class DescriptorInfo : public DescriptorInfoBase {
virtual ~DescriptorInfo() {}
+ intptr_t GetPollEvents();
+
virtual void Close() {
- VOID_TEMP_FAILURE_RETRY(close(fd_));
+ // Should be VOID_TEMP_FAILURE_RETRY
+ VOID_NO_RETRY_EXPECTED(close(fd_));
fd_ = -1;
}
@@ -53,57 +58,37 @@ class DescriptorInfoMultiple
DISALLOW_COPY_AND_ASSIGN(DescriptorInfoMultiple);
};
-// Information needed to call mx_handle_wait_many(), and to handle events.
-class MagentaWaitManyInfo {
- public:
- MagentaWaitManyInfo();
- ~MagentaWaitManyInfo();
-
- intptr_t capacity() const { return capacity_; }
- intptr_t size() const { return size_; }
- DescriptorInfo** descriptor_infos() const { return descriptor_infos_; }
- mx_wait_item_t* items() const { return items_; }
-
- void AddHandle(mx_handle_t handle, mx_signals_t signals, DescriptorInfo* di);
- void RemoveHandle(mx_handle_t handle);
-
- private:
- static const intptr_t kInitialCapacity = 32;
-
- void GrowArraysIfNeeded(intptr_t desired_size);
-
- intptr_t capacity_;
- intptr_t size_;
- DescriptorInfo** descriptor_infos_;
- mx_wait_item_t* items_;
-
- DISALLOW_COPY_AND_ASSIGN(MagentaWaitManyInfo);
-};
-
class EventHandlerImplementation {
public:
EventHandlerImplementation();
~EventHandlerImplementation();
+ void UpdateEpollInstance(intptr_t old_mask, DescriptorInfo* di);
+
+ // Gets the socket data structure for a given file
+ // descriptor. Creates a new one if one is not found.
+ 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();
- const MagentaWaitManyInfo& info() const { return info_; }
-
private:
+ static void Poll(uword args);
+ static void* GetHashmapKeyFromFd(intptr_t fd);
+ static uint32_t GetHashmapHashFromFd(intptr_t fd);
+
int64_t GetTimeout() const;
- void HandleEvents();
+ void HandleEvents(struct epoll_event* events, int size);
void HandleTimeout();
void WakeupHandler(intptr_t id, Dart_Port dart_port, int64_t data);
+ intptr_t GetPollEvents(intptr_t events, DescriptorInfo* di);
void HandleInterruptFd();
- static void Poll(uword args);
+ HashMap socket_map_;
TimeoutQueue timeout_queue_;
bool shutdown_;
- mx_handle_t interrupt_handles_[2];
-
- MagentaWaitManyInfo info_;
+ int interrupt_fds_[2];
+ int epoll_fd_;
DISALLOW_COPY_AND_ASSIGN(EventHandlerImplementation);
};
« no previous file with comments | « runtime/bin/builtin_impl_sources.gypi ('k') | runtime/bin/eventhandler_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698