| Index: third_party/grpc/src/core/iomgr/wakeup_fd_eventfd.c
|
| diff --git a/third_party/WebKit/public/web/modules/notifications/WebNotificationPermissionCallback.h b/third_party/grpc/src/core/iomgr/wakeup_fd_eventfd.c
|
| similarity index 53%
|
| copy from third_party/WebKit/public/web/modules/notifications/WebNotificationPermissionCallback.h
|
| copy to third_party/grpc/src/core/iomgr/wakeup_fd_eventfd.c
|
| index 0699fd7d872c6af29ee79f08128704636cd487a5..f67379e4fcfaf709bf9964e4eebd58b7e2481c13 100644
|
| --- a/third_party/WebKit/public/web/modules/notifications/WebNotificationPermissionCallback.h
|
| +++ b/third_party/grpc/src/core/iomgr/wakeup_fd_eventfd.c
|
| @@ -1,5 +1,7 @@
|
| /*
|
| - * Copyright (C) 2009 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,25 +28,58 @@
|
| * 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 WebNotificationPermissionCallback_h
|
| -#define WebNotificationPermissionCallback_h
|
| +#include <grpc/support/port_platform.h>
|
| +
|
| +#ifdef GPR_LINUX_EVENTFD
|
| +
|
| +#include <errno.h>
|
| +#include <sys/eventfd.h>
|
| +#include <unistd.h>
|
| +
|
| +#include <grpc/support/log.h>
|
| +
|
| +#include "src/core/iomgr/wakeup_fd_posix.h"
|
| +#include "src/core/profiling/timers.h"
|
| +
|
| +static void eventfd_create(grpc_wakeup_fd* fd_info) {
|
| + int efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
|
| + /* TODO(klempner): Handle failure more gracefully */
|
| + GPR_ASSERT(efd >= 0);
|
| + fd_info->read_fd = efd;
|
| + fd_info->write_fd = -1;
|
| +}
|
|
|
| -#include "public/platform/modules/permissions/permission_status.mojom.h"
|
| +static void eventfd_consume(grpc_wakeup_fd* fd_info) {
|
| + eventfd_t value;
|
| + int err;
|
| + do {
|
| + err = eventfd_read(fd_info->read_fd, &value);
|
| + } while (err < 0 && errno == EINTR);
|
| +}
|
|
|
| -namespace blink {
|
| +static void eventfd_wakeup(grpc_wakeup_fd* fd_info) {
|
| + int err;
|
| + GPR_TIMER_BEGIN("eventfd_wakeup", 0);
|
| + do {
|
| + err = eventfd_write(fd_info->read_fd, 1);
|
| + } while (err < 0 && errno == EINTR);
|
| + GPR_TIMER_END("eventfd_wakeup", 0);
|
| +}
|
|
|
| -// Callback object used for Web Notification permission requests.
|
| -class WebNotificationPermissionCallback {
|
| -public:
|
| - virtual ~WebNotificationPermissionCallback() { }
|
| +static void eventfd_destroy(grpc_wakeup_fd* fd_info) {
|
| + if (fd_info->read_fd != 0) close(fd_info->read_fd);
|
| +}
|
|
|
| - // Method to be invoked when the asynchronous permission request for the
|
| - // ability to display Web Notifications has been completed.
|
| - virtual void permissionRequestComplete(mojom::PermissionStatus) = 0;
|
| -};
|
| +static int eventfd_check_availability(void) {
|
| + /* TODO(klempner): Actually check if eventfd is available */
|
| + return 1;
|
| +}
|
|
|
| -} // namespace blink
|
| +const grpc_wakeup_fd_vtable grpc_specialized_wakeup_fd_vtable = {
|
| + eventfd_create, eventfd_consume, eventfd_wakeup, eventfd_destroy,
|
| + eventfd_check_availability};
|
|
|
| -#endif
|
| +#endif /* GPR_LINUX_EVENTFD */
|
|
|