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

Unified Diff: runtime/bin/sync_socket.h

Issue 2803543006: Added synchronous socket implementation to dart:io. (Closed)
Patch Set: Small fix for MacOS Created 3 years, 8 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
Index: runtime/bin/sync_socket.h
diff --git a/runtime/bin/sync_socket.h b/runtime/bin/sync_socket.h
new file mode 100644
index 0000000000000000000000000000000000000000..f19fdcb2824650f8d7b0aad57e19c25a1c4e1560
--- /dev/null
+++ b/runtime/bin/sync_socket.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
zra 2017/04/07 05:29:28 2017
bkonyi 2017/04/10 19:20:05 Done.
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#ifndef RUNTIME_BIN_SYNC_SOCKET_H_
+#define RUNTIME_BIN_SYNC_SOCKET_H_
+
+#if defined(DART_IO_DISABLED)
+#error "sync_socket.h can only be included on builds with IO enabled"
+#endif
+
+#include "platform/globals.h"
+
+#include "bin/builtin.h"
zra 2017/04/07 05:29:28 It looks like some of these includes are probably
bkonyi 2017/04/10 19:20:05 Done.
+#include "bin/dartutils.h"
+#include "bin/socket_base.h"
+#include "bin/thread.h"
+#include "bin/utils.h"
+#include "platform/hashmap.h"
+
+namespace dart {
+namespace bin {
+
+class SynchronousSocket {
+ public:
+ explicit SynchronousSocket(intptr_t fd);
+
+ intptr_t fd() const { return fd_; }
+ void SetClosedFd();
+
+ static bool Initialize();
+
+ static intptr_t CreateConnect(const RawAddr& addr);
+
+ static void SetSocketIdNativeField(Dart_Handle handle, intptr_t id);
+ static void ReuseSocketIdNativeField(Dart_Handle handle,
zra 2017/04/07 05:29:28 The native wrapper instances won't be reused, so t
bkonyi 2017/04/10 19:20:05 Done.
+ SynchronousSocket* socket);
+ static SynchronousSocket* GetSocketIdNativeField(Dart_Handle socket);
+
+ static void ShutdownRead(intptr_t fd);
+ static void ShutdownWrite(intptr_t fd);
+
+ private:
+ ~SynchronousSocket() { ASSERT(fd_ == kClosedFd); }
zra 2017/04/07 05:29:28 This should be public since SynchronousSocket isn'
bkonyi 2017/04/10 19:20:05 Done.
+
+ static const int kClosedFd = -1;
+
+ intptr_t fd_;
+ Dart_Port port_;
zra 2017/04/07 05:29:28 I think this field isn't needed.
bkonyi 2017/04/10 19:20:05 You're right. Removed.
+
+ DISALLOW_COPY_AND_ASSIGN(SynchronousSocket);
+};
+
+} // namespace bin
+} // namespace dart
+
+#endif // RUNTIME_BIN_SYNC_SOCKET_H_

Powered by Google App Engine
This is Rietveld 408576698