Index: mojo/edk/embedder/named_platform_handle.h |
diff --git a/mojo/edk/embedder/named_platform_handle.h b/mojo/edk/embedder/named_platform_handle.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..15ca6565d51580a7e7f2fd58a2c7fc20e0a38256 |
--- /dev/null |
+++ b/mojo/edk/embedder/named_platform_handle.h |
@@ -0,0 +1,51 @@ |
+// Copyright 2016 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 MOJO_EDK_EMBEDDER_NAMED_PLATFORM_HANDLE_H_ |
+#define MOJO_EDK_EMBEDDER_NAMED_PLATFORM_HANDLE_H_ |
+ |
+#include <string> |
+ |
+#include "base/strings/string16.h" |
+#include "base/strings/string_piece.h" |
+#include "base/strings/utf_string_conversions.h" |
+#include "build/build_config.h" |
+#include "mojo/edk/system/system_impl_export.h" |
+ |
+namespace mojo { |
+namespace edk { |
+ |
+#if defined(OS_POSIX) |
+struct MOJO_SYSTEM_IMPL_EXPORT NamedPlatformHandle { |
+ NamedPlatformHandle() {} |
+ explicit NamedPlatformHandle(const base::StringPiece& name) |
+ : name(name.as_string()) {} |
+ |
+ bool is_valid() const { return !name.empty(); } |
+ |
+ std::string name; |
+}; |
+#elif defined(OS_WIN) |
+struct MOJO_SYSTEM_IMPL_EXPORT NamedPlatformHandle { |
+ NamedPlatformHandle() {} |
+ explicit NamedPlatformHandle(const base::StringPiece& name) |
+ : name(base::UTF8ToUTF16(name)) {} |
+ |
+ explicit NamedPlatformHandle(const base::StringPiece16& name) |
+ : name(name.as_string()) {} |
+ |
+ bool is_valid() const { return !name.empty(); } |
+ |
+ base::string16 pipe_name() const { return L"\\\\.\\pipe\\mojo." + name; } |
+ |
+ base::string16 name; |
+}; |
+#else |
+#error "Platform not yet supported." |
+#endif |
+ |
+} // namespace edk |
+} // namespace mojo |
+ |
+#endif // MOJO_EDK_EMBEDDER_NAMED_PLATFORM_HANDLE_H_ |