Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Unified Diff: src/trusted/reverse_service/reverse_service.cc

Issue 7108031: this patch adds the manifest proxy server to sel_ldr and the manifest (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/trusted/reverse_service/reverse_service.cc
===================================================================
--- src/trusted/reverse_service/reverse_service.cc (revision 5616)
+++ src/trusted/reverse_service/reverse_service.cc (working copy)
@@ -4,6 +4,10 @@
* found in the LICENSE file.
*/
+#include "native_client/src/include/portability_io.h"
+
noelallen_use_chromium 2011/06/14 02:25:45 Why is portability_io.h included before string.h?
bsy 2011/06/14 20:30:03 several of our portability* files had to be includ
noelallen_use_chromium 2011/06/14 22:08:14 I mentioned portability vs portability_io, because
+#include <string.h>
+
#include "native_client/src/trusted/reverse_service/reverse_service.h"
#include "native_client/src/include/nacl_compiler_annotations.h"
@@ -15,6 +19,8 @@
#include "native_client/src/shared/platform/nacl_threads.h"
#include "native_client/src/shared/srpc/nacl_srpc.h"
+#include "native_client/src/trusted/desc/nacl_desc_invalid.h"
+
namespace {
void Test(NaClSrpcRpc* rpc,
@@ -37,10 +43,12 @@
NaClSrpcClosure* done) {
nacl::ReverseService* service = reinterpret_cast<nacl::ReverseService*>(
rpc->channel->server_instance_data);
+
UNREFERENCED_PARAMETER(in_args);
- UNREFERENCED_PARAMETER(out_args);
+
NaClLog(4, "Entered AddChannel\n");
- out_args[0]->u.bval = service->Start();
+ service->Start();
+ out_args[0]->u.bval = 1;
NaClLog(4, "Leaving AddChannel\n");
rpc->result = NACL_SRPC_RESULT_OK;
done->Run(done);
@@ -63,6 +71,73 @@
done->Run(done);
}
+// Manifest name service, internal APIs.
+//
+// Manifest file lookups result in read-only file descriptors with a
+// handle. When the descriptor is closed, the service runtime must
+// inform the plugin of this using the handle, so that the File object
+// reference can be closed (thereby allowing the browser to delete or
+// otherwise garbage collect the file). Files, being from the
+// manifest, cannot be deleted. The manifest is also a read-only
+// object, so no new entries can be made to it.
+//
+// Read-only proxies do not require quota support per se, since we do
+// not limit read bandwidth. Quota support is needed for storage
+// limits, though could also be used to limit write bandwidth (prevent
+// disk output saturation, limit malicious code's ability to cause
+// disk failures, especially with flash disks with limited write
+// cycles).
+
+// NACL_NAME_SERVICE_LIST list::C -- enumerate all names in the manifest
+void ManifestListRpc(NaClSrpcRpc* rpc,
+ NaClSrpcArg** in_args,
+ NaClSrpcArg** out_args,
+ NaClSrpcClosure* done) {
+ size_t nbytes = out_args[0]->u.count;
+ char* dest = out_args[0]->arrays.carr;
+
noelallen_use_chromium 2011/06/14 02:25:45 No NaClLog?
+ UNREFERENCED_PARAMETER(in_args);
+ // temporary test return value. TODO(bsy) hook up to real manifest info
+ out_args[0]->u.count = SNPRINTF(dest, nbytes,
+ "This is a reply from the manifest reverse"
+ " service in the plugin.");
+ rpc->result = NACL_SRPC_RESULT_OK;
+ done->Run(done);
+}
+
+// NACL_NAME_SERVICE_LOOKUP lookup:si:ihC -- look up by string name,
+// resulting in a handle (if name is in the preimage), a object proxy
+// handle, and an error code.
+void ManifestLookupRpc(NaClSrpcRpc* rpc,
+ NaClSrpcArg** in_args,
+ NaClSrpcArg** out_args,
+ NaClSrpcClosure* done) {
+ char* fname = in_args[0]->arrays.str;
+ int flags = in_args[0]->u.ival;
+
+ NaClLog(0, "ManifestLookupRpc: %s, %d\n", fname, flags);
+ out_args[0]->u.ival = 0; // ok
+ out_args[1]->u.hval = (struct NaClDesc*) NaClDescInvalidMake();
+ out_args[2]->u.count = 10;
noelallen_use_chromium 2011/06/14 02:25:45 Either u.count above should be set as sizeof('stri
bsy 2011/06/14 20:30:03 this is stub code that will be removed once the ma
+ strncpy(out_args[2]->arrays.carr, "123456789", 10);
+ rpc->result = NACL_SRPC_RESULT_OK;
+ done->Run(done);
+}
+
+// unref:C:i -- dereferences the file by object proxy handle. The
+// file descriptor should have been closed.
+void ManifestUnrefRpc(NaClSrpcRpc* rpc,
+ NaClSrpcArg** in_args,
+ NaClSrpcArg** out_args,
+ NaClSrpcClosure* done) {
+ char* proxy_handle = in_args[0]->arrays.carr;
+
+ NaClLog(0, "ManifestUnrefRpc: %s\n", proxy_handle);
+ out_args[0]->u.ival = 0; // ok
+ rpc->result = NACL_SRPC_RESULT_OK;
+ done->Run(done);
+}
+
} // namespace
namespace nacl {
@@ -187,6 +262,9 @@
{ "test:s:", Test, },
{ "revlog:s:", RevLog, },
{ "add_channel::b", AddChannel, },
+ { NACL_MANIFEST_LIST, ManifestListRpc, },
+ { NACL_MANIFEST_LOOKUP, ManifestLookupRpc, },
+ { NACL_MANIFEST_UNREF, ManifestUnrefRpc, },
{ NULL, NULL, },
};
@@ -220,6 +298,7 @@
bool ReverseService::Start() {
+ NaClLog(4, "Entered ReverseService::Start\n");
return service_socket_->StartService(reinterpret_cast<void*>(this));
}

Powered by Google App Engine
This is Rietveld 408576698