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

Unified Diff: third_party/grpc/src/core/iomgr/wakeup_fd_pipe.c

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « third_party/grpc/src/core/iomgr/wakeup_fd_pipe.h ('k') | third_party/grpc/src/core/iomgr/wakeup_fd_posix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/grpc/src/core/iomgr/wakeup_fd_pipe.c
diff --git a/third_party/WebKit/Source/core/css/FontFaceSetLoadEvent.h b/third_party/grpc/src/core/iomgr/wakeup_fd_pipe.c
similarity index 50%
copy from third_party/WebKit/Source/core/css/FontFaceSetLoadEvent.h
copy to third_party/grpc/src/core/iomgr/wakeup_fd_pipe.c
index da7407242133e4d68f8a047eedabb45ede1d83b7..80de181d9d1966e80c8aa20440fb164862a470b5 100644
--- a/third_party/WebKit/Source/core/css/FontFaceSetLoadEvent.h
+++ b/third_party/grpc/src/core/iomgr/wakeup_fd_pipe.c
@@ -1,5 +1,7 @@
/*
- * Copyright (C) 2013 Google Inc. All rights reserved.
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -26,54 +28,70 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
*/
-#ifndef FontFaceSetLoadEvent_h
-#define FontFaceSetLoadEvent_h
+#include <grpc/support/port_platform.h>
-#include "core/css/FontFace.h"
-#include "core/css/FontFaceSetLoadEventInit.h"
-#include "core/dom/DOMError.h"
-#include "core/events/Event.h"
-#include "wtf/PassRefPtr.h"
-#include "wtf/RefPtr.h"
+#ifdef GPR_POSIX_WAKEUP_FD
-namespace blink {
+#include "src/core/iomgr/wakeup_fd_posix.h"
-class FontFaceSetLoadEvent final : public Event {
- DEFINE_WRAPPERTYPEINFO();
-public:
- static FontFaceSetLoadEvent* create()
- {
- return new FontFaceSetLoadEvent();
- }
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
- static FontFaceSetLoadEvent* create(const AtomicString& type, const FontFaceSetLoadEventInit& initializer)
- {
- return new FontFaceSetLoadEvent(type, initializer);
- }
+#include "src/core/iomgr/socket_utils_posix.h"
+#include <grpc/support/log.h>
- static FontFaceSetLoadEvent* createForFontFaces(const AtomicString& type, const FontFaceArray& fontfaces = FontFaceArray())
- {
- return new FontFaceSetLoadEvent(type, fontfaces);
- }
-
- ~FontFaceSetLoadEvent() override;
+static void pipe_init(grpc_wakeup_fd* fd_info) {
+ int pipefd[2];
+ /* TODO(klempner): Make this nonfatal */
+ GPR_ASSERT(0 == pipe(pipefd));
+ GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[0], 1));
+ GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[1], 1));
+ fd_info->read_fd = pipefd[0];
+ fd_info->write_fd = pipefd[1];
+}
- FontFaceArray fontfaces() const { return m_fontfaces; }
+static void pipe_consume(grpc_wakeup_fd* fd_info) {
+ char buf[128];
+ ssize_t r;
- const AtomicString& interfaceName() const override;
+ for (;;) {
+ r = read(fd_info->read_fd, buf, sizeof(buf));
+ if (r > 0) continue;
+ if (r == 0) return;
+ switch (errno) {
+ case EAGAIN:
+ return;
+ case EINTR:
+ continue;
+ default:
+ gpr_log(GPR_ERROR, "error reading pipe: %s", strerror(errno));
+ return;
+ }
+ }
+}
- DECLARE_VIRTUAL_TRACE();
+static void pipe_wakeup(grpc_wakeup_fd* fd_info) {
+ char c = 0;
+ while (write(fd_info->write_fd, &c, 1) != 1 && errno == EINTR)
+ ;
+}
-private:
- FontFaceSetLoadEvent();
- FontFaceSetLoadEvent(const AtomicString&, const FontFaceArray&);
- FontFaceSetLoadEvent(const AtomicString&, const FontFaceSetLoadEventInit&);
+static void pipe_destroy(grpc_wakeup_fd* fd_info) {
+ if (fd_info->read_fd != 0) close(fd_info->read_fd);
+ if (fd_info->write_fd != 0) close(fd_info->write_fd);
+}
- FontFaceArray m_fontfaces;
-};
+static int pipe_check_availability(void) {
+ /* Assume that pipes are always available. */
+ return 1;
+}
-} // namespace blink
+const grpc_wakeup_fd_vtable grpc_pipe_wakeup_fd_vtable = {
+ pipe_init, pipe_consume, pipe_wakeup, pipe_destroy,
+ pipe_check_availability};
-#endif // FontFaceSetLoadEvent_h
+#endif /* GPR_POSIX_WAKUP_FD */
« no previous file with comments | « third_party/grpc/src/core/iomgr/wakeup_fd_pipe.h ('k') | third_party/grpc/src/core/iomgr/wakeup_fd_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698