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

Unified Diff: base/native_sync_socket.h

Issue 499233003: Binding media stream audio track to speech recognition [renderer] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Platform checks removed from dispatcher Created 6 years, 4 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: base/native_sync_socket.h
diff --git a/base/native_sync_socket.h b/base/native_sync_socket.h
new file mode 100644
index 0000000000000000000000000000000000000000..b15edb30907162607da374d1e7fbdc615237aff6
--- /dev/null
+++ b/base/native_sync_socket.h
@@ -0,0 +1,56 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_NATIVE_SYNC_SOCKET_H_
+#define BASE_NATIVE_SYNC_SOCKET_H_
+
+#include "base/process/process_handle.h"
+#include "base/sync_socket.h"
+
+#if defined(OS_POSIX)
+#include "base/file_descriptor_posix.h"
+#endif
+
+namespace base {
+
+// Helper class for using |SyncSocket| cross-platform
+class NativeSyncSocket {
tommi (sloooow) - chröme 2014/08/29 11:25:30 This class seems to rely on SyncSocket but doesn't
no longer working on chromium 2014/08/29 12:23:06 You and I should have a discussion with Tommi on i
burnik 2014/08/29 13:26:16 Agreed. Socket should be more cross-platform frien
burnik 2014/08/29 13:26:16 I agree. SyncSocket should have a descriptor which
+ public:
+#if defined(OS_WIN)
+ typedef base::SyncSocket::Handle Descriptor;
+
+ static bool PrepareForeignSocketDescriptor(
tommi (sloooow) - chröme 2014/08/29 11:25:30 implementation should be in the cc file
tommi (sloooow) - chröme 2014/08/29 11:25:30 I know that this method name comes from elsewhere,
burnik 2014/08/29 13:26:16 Acknowledged.
burnik 2014/08/29 13:26:16 Agreed. I think name should be something like |Pre
+ base::ProcessHandle process_handle,
+ base::SyncSocket * foreign_socket,
+ base::SyncSocket::Handle * foreign_handle) {
+ ::DuplicateHandle(GetCurrentProcess(), foreign_socket->handle(),
+ process_handle, foreign_handle,
+ 0, FALSE, DUPLICATE_SAME_ACCESS);
+ return (*foreign_handle != 0);
+ }
+
+ static base::SyncSocket::Handle Unwrap(const Descriptor& descriptor) {
+ return descriptor;
+ }
+
+#else
+ typedef base::FileDescriptor Descriptor;
+
+ static bool PrepareForeignSocketDescriptor(
+ base::ProcessHandle process_handle,
+ base::SyncSocket * foreign_socket,
+ base::FileDescriptor * foreign_handle) {
+ foreign_handle->fd = foreign_socket->handle();
+ foreign_handle->auto_close = false;
+ return (foreign_handle->fd != -1);
+ }
+
+ static int Unwrap(const Descriptor& descriptor) {
tommi (sloooow) - chröme 2014/08/29 11:25:30 use base::SyncSocket::Handle here as well as the r
burnik 2014/08/29 13:26:16 Good point. When impl moves to .cc it will make mo
+ return descriptor.fd;
+ }
+#endif
+};
+
+} // namespace base
+#endif // BASE_NATIVE_SYNC_SOCKET_H_

Powered by Google App Engine
This is Rietveld 408576698