Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / base / sync_socket.h
index 71addd1..9923591 100644 (file)
 
 #include "base/base_export.h"
 #include "base/compiler_specific.h"
+#include "base/process/process_handle.h"
 #include "base/synchronization/waitable_event.h"
 #include "base/time/time.h"
 
+#if defined(OS_POSIX)
+#include "base/file_descriptor_posix.h"
+#endif
+
 namespace base {
 
 class BASE_EXPORT SyncSocket {
  public:
 #if defined(OS_WIN)
   typedef HANDLE Handle;
+  typedef Handle TransitDescriptor;
 #else
   typedef int Handle;
+  typedef FileDescriptor TransitDescriptor;
 #endif
   static const Handle kInvalidHandle;
 
@@ -42,6 +49,15 @@ class BASE_EXPORT SyncSocket {
   // return, the sockets will both be valid and connected.
   static bool CreatePair(SyncSocket* socket_a, SyncSocket* socket_b);
 
+  // Returns |Handle| wrapped in a |TransitDescriptor|.
+  static Handle UnwrapHandle(const TransitDescriptor& descriptor);
+
+  // Prepares a |TransitDescriptor| which wraps |Handle| used for transit.
+  // This is used to prepare the underlying shared resource before passing back
+  // the handle to be used by the peer process.
+  bool PrepareTransitDescriptor(ProcessHandle peer_process_handle,
+                                TransitDescriptor* descriptor);
+
   // Closes the SyncSocket.  Returns true on success, false on failure.
   virtual bool Close();