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

Side by Side Diff: components/nacl/loader/nacl_validation_query.cc

Issue 897353002: NaCl cleanup: Remove unneeded definition of ResolveFileToken() (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « components/nacl/loader/nacl_validation_query.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/nacl/loader/nacl_validation_query.h" 5 #include "components/nacl/loader/nacl_validation_query.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "components/nacl/loader/nacl_validation_db.h" 8 #include "components/nacl/loader/nacl_validation_db.h"
9 #include "crypto/nss_util.h" 9 #include "crypto/nss_util.h"
10 #include "native_client/src/include/portability.h" 10 #include "native_client/src/include/portability.h"
(...skipping 13 matching lines...) Expand all
24 CHECK(nacl_version.length() >= 4); 24 CHECK(nacl_version.length() >= 4);
25 } 25 }
26 26
27 NaClValidationQuery* NaClValidationQueryContext::CreateQuery() { 27 NaClValidationQuery* NaClValidationQueryContext::CreateQuery() {
28 NaClValidationQuery* query = new NaClValidationQuery(db_, profile_key_); 28 NaClValidationQuery* query = new NaClValidationQuery(db_, profile_key_);
29 // Changing the version effectively invalidates existing hashes. 29 // Changing the version effectively invalidates existing hashes.
30 query->AddData(nacl_version_); 30 query->AddData(nacl_version_);
31 return query; 31 return query;
32 } 32 }
33 33
34 bool NaClValidationQueryContext::ResolveFileToken(
35 struct NaClFileToken* file_token,
36 int32* fd,
37 std::string* path) {
38 // This should no longer be used.
39 CHECK(false);
40 return false;
41 }
42
43 NaClValidationQuery::NaClValidationQuery(NaClValidationDB* db, 34 NaClValidationQuery::NaClValidationQuery(NaClValidationDB* db,
44 const std::string& profile_key) 35 const std::string& profile_key)
45 : state_(READY), 36 : state_(READY),
46 hasher_(crypto::HMAC::SHA256), 37 hasher_(crypto::HMAC::SHA256),
47 db_(db), 38 db_(db),
48 buffer_length_(0) { 39 buffer_length_(0) {
49 // Without this line on Linux, HMAC::Init will instantiate a singleton that 40 // Without this line on Linux, HMAC::Init will instantiate a singleton that
50 // in turn attempts to open a file. Disabling this behavior avoids a ~70 ms 41 // in turn attempts to open a file. Disabling this behavior avoids a ~70 ms
51 // stall the first time HMAC is used. 42 // stall the first time HMAC is used.
52 // This function is also called in nacl_helper_linux.cc, but nacl_helper may 43 // This function is also called in nacl_helper_linux.cc, but nacl_helper may
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 122 }
132 123
133 static void SetKnownToValidate(void* query) { 124 static void SetKnownToValidate(void* query) {
134 static_cast<NaClValidationQuery*>(query)->SetKnownToValidate(); 125 static_cast<NaClValidationQuery*>(query)->SetKnownToValidate();
135 } 126 }
136 127
137 static void DestroyQuery(void* query) { 128 static void DestroyQuery(void* query) {
138 delete static_cast<NaClValidationQuery*>(query); 129 delete static_cast<NaClValidationQuery*>(query);
139 } 130 }
140 131
141 static int ResolveFileToken(void* handle, struct NaClFileToken* file_token,
142 int32* fd, char** file_path,
143 uint32* file_path_length) {
144 std::string path;
145 *file_path = NULL;
146 *file_path_length = 0;
147 bool ok = static_cast<NaClValidationQueryContext*>(handle)->
148 ResolveFileToken(file_token, fd, &path);
149 if (ok) {
150 *file_path = static_cast<char*>(malloc(path.length() + 1));
151 CHECK(*file_path);
152 memcpy(*file_path, path.data(), path.length());
153 (*file_path)[path.length()] = 0;
154 *file_path_length = static_cast<uint32>(path.length());
155 }
156 return ok;
157 }
158
159 struct NaClValidationCache* CreateValidationCache( 132 struct NaClValidationCache* CreateValidationCache(
160 NaClValidationDB* db, const std::string& profile_key, 133 NaClValidationDB* db, const std::string& profile_key,
161 const std::string& nacl_version) { 134 const std::string& nacl_version) {
162 NaClValidationCache* cache = 135 NaClValidationCache* cache =
163 static_cast<NaClValidationCache*>(malloc(sizeof(NaClValidationCache))); 136 static_cast<NaClValidationCache*>(malloc(sizeof(NaClValidationCache)));
164 // Make sure any fields introduced in a cross-repo change are zeroed. 137 // Make sure any fields introduced in a cross-repo change are zeroed.
165 memset(cache, 0, sizeof(*cache)); 138 memset(cache, 0, sizeof(*cache));
166 cache->handle = new NaClValidationQueryContext(db, profile_key, nacl_version); 139 cache->handle = new NaClValidationQueryContext(db, profile_key, nacl_version);
167 cache->CreateQuery = CreateQuery; 140 cache->CreateQuery = CreateQuery;
168 cache->AddData = AddData; 141 cache->AddData = AddData;
169 cache->QueryKnownToValidate = QueryKnownToValidate; 142 cache->QueryKnownToValidate = QueryKnownToValidate;
170 cache->SetKnownToValidate = SetKnownToValidate; 143 cache->SetKnownToValidate = SetKnownToValidate;
171 cache->DestroyQuery = DestroyQuery; 144 cache->DestroyQuery = DestroyQuery;
172 cache->ResolveFileToken = ResolveFileToken;
173 return cache; 145 return cache;
174 } 146 }
OLDNEW
« no previous file with comments | « components/nacl/loader/nacl_validation_query.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698