OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Native Client Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NATIVE_CLIENT_SRC_UNTRUSTED_INIT_NAME_SERVICE_H_ |
| 6 #define NATIVE_CLIENT_SRC_UNTRUSTED_INIT_NAME_SERVICE_H_ |
| 7 |
| 8 #include "native_client/src/untrusted/init/simple_service.h" |
| 9 |
| 10 namespace nacl { |
| 11 |
| 12 class NameService : public SimpleService { |
| 13 public: |
| 14 NameService(); |
| 15 ~NameService(); |
| 16 |
| 17 virtual bool CreateEntry(string name, int mode, int *out); |
| 18 |
| 19 virtual bool Resolve(string name, int flags); |
| 20 |
| 21 virtual bool DeleteName(string name, int *out); |
| 22 |
| 23 virtual size_t Enumerate(string dest, size_t nbytes); |
| 24 // template typename<Cont> List(Cont::insert_iterator<Cont> it); |
| 25 |
| 26 private: |
| 27 std::map<string, int> entries_; |
| 28 |
| 29 DISALLOW_COPY_AND_ASSIGN(NameService); |
| 30 }; |
| 31 |
| 32 // Basic name service related utilities. |
| 33 class NameServiceClient : public SrpcClientConnection { |
| 34 public: |
| 35 NameServiceClient() {} |
| 36 |
| 37 std::vector<std::string> List(); |
| 38 // TODO(bsy) consider instead implementing: |
| 39 // template typename<Cont> List(Cont::insert_iterator<Cont> it); |
| 40 |
| 41 int Resolve(std::string name); |
| 42 }; |
| 43 |
| 44 class NameServiceFactory { |
| 45 public: |
| 46 // Init must be called before any other operation. May fail, which |
| 47 // is typically a fatal error. |
| 48 static bool Init(); |
| 49 |
| 50 static NameServiceFactory *NameServiceFactorySingleton(); |
| 51 NameServiceClient *NameService(); |
| 52 private: |
| 53 NameServiceFactory(); |
| 54 |
| 55 static int name_service_cap; |
| 56 static NameServiceFactory *singleton; |
| 57 }; |
| 58 |
| 59 } // namespace nacl |
| 60 |
| 61 #endif |
OLD | NEW |