Index: src/untrusted/init/simple_service.h |
diff --git a/src/untrusted/init/simple_service.h b/src/untrusted/init/simple_service.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..486e20f4b108ac9806a617c88cb350831b6fcb3d |
--- /dev/null |
+++ b/src/untrusted/init/simple_service.h |
@@ -0,0 +1,64 @@ |
+// 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_KERNEL_SERVICE_H_ |
+#define NATIVE_CLIENT_SRC_UNTRUSTED_INIT_KERNEL_SERVICE_H_ |
+ |
+namespace nacl { |
+ |
+class SimpleServiceConnection; |
+ |
+class SimpleService { |
+ public: |
+ SimpleService(); |
+ |
+ ~SimpleService(); |
+ |
+ int AcceptAndSpawnHandler(); |
+ |
+ void RpcHandler(SimpleServiceConnection *conn); |
+ |
+ protected: |
+ SimpleServiceConnection *ConnectionFactoryWithInstanceData( |
+ int d, void *instance_data) |
+ SimpleServiceConnection *ConnectionFactory(int d); |
+ |
+ private: |
+ SimpleServiceConnection *AcceptConnection(); |
+ |
+ struct NaClDesc *bound_and_cap_[2]; |
+ |
+ NaClThreadIfFactoryFunction thread_factory_fn; |
+ void *thread_factory_data; |
+ |
+ // Acceptor thread |
+ scoped_ptr<Thread> acceptor_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SimpleService); |
+}; |
+ |
+class SimpleServiceConnection { |
+ public: |
+ SimpleServiceConnection(SimpleService *server, |
+ int connection, |
+ void *instance_data); |
+ |
+ ~SimpleServiceConnection(); |
+ |
+ int ServerLoop(); |
+ |
+ private: |
+ NaClSimpleService *server_; |
+ int connected_socket_; |
+ |
+ void *instance_data_; |
+ |
+ //NaClThreadInterface *thread; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SimpleServiceConnection); |
+}; |
+ |
+} // namespace nacl |
+ |
+#endif |