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

Unified Diff: src/trusted/validator/validation_cache.h

Issue 9535001: Add validation caching interface. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: More edits Created 8 years, 10 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
« no previous file with comments | « src/trusted/validator/ncvalidate.h ('k') | src/trusted/validator/validation_cache_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/validator/validation_cache.h
diff --git a/src/trusted/validator/validation_cache.h b/src/trusted/validator/validation_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..6cb0bb8a5546b5d99f212d6bd71e3fa696a4020b
--- /dev/null
+++ b/src/trusted/validator/validation_cache.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012 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_TRUSTED_VALIDATOR_VALIDATION_CACHE_H_
+#define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_VALIDATION_CACHE_H_
+
+#include "native_client/src/include/nacl_base.h"
+
+EXTERN_C_BEGIN
+
+/*
+ * This interface allows the validator to query a database of validation results
+ * while hiding details of how the database is implemented.
+ *
+ * query = cache->CreateQuery(cache->handle);
+ * CreateQuery: create an opaque query object, given an opaque context object.
+ * The context object contains persistent variables that will be used for all
+ * queries, whereas the query object contains information relevant to a single
+ * validation result.
+ *
+ * cache->AddData(query, data, data_size);
+ * AddData: add a blob of binary data to the query. Conceptually, the query
+ * will concatenate all the binary data it is given, in the order it is given,
+ * and use the concatenated blob as a key to look up validation results in a
+ * database. In practice, all of the data is hashed into a reasonabally sized
+ * key. The validation cache doesn't care what data it is given, it is the
+ * responsibility of the validator to provide enough information to uniquely
+ * identify the validation result. This gives flexibility to use different
+ * types of keys for different validators and different sources of code.
+ *
+ * validation_passed = cache->QueryKnownToValidate(query);
+ * QueryKnownToValidate: the key is complete, query the validation status.
+ * This should only be called once. AddData must not be called after calling
+ * this function.
+ *
+ * cache->SetKnownToValidate(query);
+ * SetKnownToValidate: set the database entry for the given key.
+ * QueryKnownToValidate must be called first.
+ *
+ * cache->DestroyQuery(query);
+ * DestroyQuery: cleanup and deallocate the query object.
+ */
+
+struct NaClValidationCache {
+ void *handle;
+ void *(*CreateQuery)(void *handle);
+ void (*AddData)(void *query, const unsigned char *data, size_t length);
+ int (*QueryKnownToValidate)(void *query);
+ void (*SetKnownToValidate)(void *query);
+ void (*DestroyQuery)(void *query);
+};
+
+EXTERN_C_END
+
+#endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_VALIDATION_CACHE_H_ */
« no previous file with comments | « src/trusted/validator/ncvalidate.h ('k') | src/trusted/validator/validation_cache_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698