Index: src/untrusted/init/name_service.h |
diff --git a/src/untrusted/init/name_service.h b/src/untrusted/init/name_service.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a859812ce6560256e28d326bc9931eb97e765274 |
--- /dev/null |
+++ b/src/untrusted/init/name_service.h |
@@ -0,0 +1,61 @@ |
+// Copyright (c) 2013 The Native Client 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 NATIVE_CLIENT_SRC_UNTRUSTED_INIT_NAME_SERVICE_H_ |
+#define NATIVE_CLIENT_SRC_UNTRUSTED_INIT_NAME_SERVICE_H_ |
+ |
+#include "native_client/src/untrusted/init/simple_service.h" |
+ |
+namespace nacl { |
+ |
+class NameService : public SimpleService { |
+ public: |
+ NameService(); |
+ ~NameService(); |
+ |
+ virtual bool CreateEntry(string name, int mode, int *out); |
+ |
+ virtual bool Resolve(string name, int flags); |
+ |
+ virtual bool DeleteName(string name, int *out); |
+ |
+ virtual size_t Enumerate(string dest, size_t nbytes); |
+ // template typename<Cont> List(Cont::insert_iterator<Cont> it); |
+ |
+ private: |
+ std::map<string, int> entries_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NameService); |
+}; |
+ |
+// Basic name service related utilities. |
+class NameServiceClient : public SrpcClientConnection { |
+ public: |
+ NameServiceClient() {} |
+ |
+ std::vector<std::string> List(); |
+ // TODO(bsy) consider instead implementing: |
+ // template typename<Cont> List(Cont::insert_iterator<Cont> it); |
+ |
+ int Resolve(std::string name); |
+}; |
+ |
+class NameServiceFactory { |
+ public: |
+ // Init must be called before any other operation. May fail, which |
+ // is typically a fatal error. |
+ static bool Init(); |
+ |
+ static NameServiceFactory *NameServiceFactorySingleton(); |
+ NameServiceClient *NameService(); |
+ private: |
+ NameServiceFactory(); |
+ |
+ static int name_service_cap; |
+ static NameServiceFactory *singleton; |
+}; |
+ |
+} // namespace nacl |
+ |
+#endif |