OLD | NEW |
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_listener.h" | 5 #include "components/nacl/loader/nacl_listener.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 156 } |
157 | 157 |
158 } // namespace | 158 } // namespace |
159 | 159 |
160 class BrowserValidationDBProxy : public NaClValidationDB { | 160 class BrowserValidationDBProxy : public NaClValidationDB { |
161 public: | 161 public: |
162 explicit BrowserValidationDBProxy(NaClListener* listener) | 162 explicit BrowserValidationDBProxy(NaClListener* listener) |
163 : listener_(listener) { | 163 : listener_(listener) { |
164 } | 164 } |
165 | 165 |
166 virtual bool QueryKnownToValidate(const std::string& signature) OVERRIDE { | 166 virtual bool QueryKnownToValidate(const std::string& signature) override { |
167 // Initialize to false so that if the Send fails to write to the return | 167 // Initialize to false so that if the Send fails to write to the return |
168 // value we're safe. For example if the message is (for some reason) | 168 // value we're safe. For example if the message is (for some reason) |
169 // dispatched as an async message the return parameter will not be written. | 169 // dispatched as an async message the return parameter will not be written. |
170 bool result = false; | 170 bool result = false; |
171 if (!listener_->Send(new NaClProcessMsg_QueryKnownToValidate(signature, | 171 if (!listener_->Send(new NaClProcessMsg_QueryKnownToValidate(signature, |
172 &result))) { | 172 &result))) { |
173 LOG(ERROR) << "Failed to query NaCl validation cache."; | 173 LOG(ERROR) << "Failed to query NaCl validation cache."; |
174 result = false; | 174 result = false; |
175 } | 175 } |
176 return result; | 176 return result; |
177 } | 177 } |
178 | 178 |
179 virtual void SetKnownToValidate(const std::string& signature) OVERRIDE { | 179 virtual void SetKnownToValidate(const std::string& signature) override { |
180 // Caching is optional: NaCl will still work correctly if the IPC fails. | 180 // Caching is optional: NaCl will still work correctly if the IPC fails. |
181 if (!listener_->Send(new NaClProcessMsg_SetKnownToValidate(signature))) { | 181 if (!listener_->Send(new NaClProcessMsg_SetKnownToValidate(signature))) { |
182 LOG(ERROR) << "Failed to update NaCl validation cache."; | 182 LOG(ERROR) << "Failed to update NaCl validation cache."; |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 // This is the "old" code path for resolving file tokens. It's only | 186 // This is the "old" code path for resolving file tokens. It's only |
187 // used for resolving the main nexe. | 187 // used for resolving the main nexe. |
188 // TODO(teravest): Remove this. | 188 // TODO(teravest): Remove this. |
189 virtual bool ResolveFileToken(struct NaClFileToken* file_token, | 189 virtual bool ResolveFileToken(struct NaClFileToken* file_token, |
190 int32* fd, std::string* path) OVERRIDE { | 190 int32* fd, std::string* path) override { |
191 *fd = -1; | 191 *fd = -1; |
192 *path = ""; | 192 *path = ""; |
193 if (!NaClFileTokenIsValid(file_token)) { | 193 if (!NaClFileTokenIsValid(file_token)) { |
194 return false; | 194 return false; |
195 } | 195 } |
196 IPC::PlatformFileForTransit ipc_fd = IPC::InvalidPlatformFileForTransit(); | 196 IPC::PlatformFileForTransit ipc_fd = IPC::InvalidPlatformFileForTransit(); |
197 base::FilePath ipc_path; | 197 base::FilePath ipc_path; |
198 if (!listener_->Send(new NaClProcessMsg_ResolveFileToken(file_token->lo, | 198 if (!listener_->Send(new NaClProcessMsg_ResolveFileToken(file_token->lo, |
199 file_token->hi, | 199 file_token->hi, |
200 &ipc_fd, | 200 &ipc_fd, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 return filter_->Send(msg); | 255 return filter_->Send(msg); |
256 } | 256 } |
257 } | 257 } |
258 | 258 |
259 // The NaClProcessMsg_ResolveFileTokenAsyncReply message must be | 259 // The NaClProcessMsg_ResolveFileTokenAsyncReply message must be |
260 // processed in a MessageFilter so it can be handled on the IO thread. | 260 // processed in a MessageFilter so it can be handled on the IO thread. |
261 // The main thread used by NaClListener is busy in | 261 // The main thread used by NaClListener is busy in |
262 // NaClChromeMainAppStart(), so it can't be used for servicing messages. | 262 // NaClChromeMainAppStart(), so it can't be used for servicing messages. |
263 class FileTokenMessageFilter : public IPC::MessageFilter { | 263 class FileTokenMessageFilter : public IPC::MessageFilter { |
264 public: | 264 public: |
265 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { | 265 virtual bool OnMessageReceived(const IPC::Message& msg) override { |
266 bool handled = true; | 266 bool handled = true; |
267 IPC_BEGIN_MESSAGE_MAP(FileTokenMessageFilter, msg) | 267 IPC_BEGIN_MESSAGE_MAP(FileTokenMessageFilter, msg) |
268 IPC_MESSAGE_HANDLER(NaClProcessMsg_ResolveFileTokenAsyncReply, | 268 IPC_MESSAGE_HANDLER(NaClProcessMsg_ResolveFileTokenAsyncReply, |
269 OnResolveFileTokenAsyncReply) | 269 OnResolveFileTokenAsyncReply) |
270 IPC_MESSAGE_UNHANDLED(handled = false) | 270 IPC_MESSAGE_UNHANDLED(handled = false) |
271 IPC_END_MESSAGE_MAP() | 271 IPC_END_MESSAGE_MAP() |
272 return handled; | 272 return handled; |
273 } | 273 } |
274 | 274 |
275 void OnResolveFileTokenAsyncReply( | 275 void OnResolveFileTokenAsyncReply( |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 491 } |
492 | 492 |
493 void NaClListener::OnFileTokenResolved( | 493 void NaClListener::OnFileTokenResolved( |
494 uint64_t token_lo, | 494 uint64_t token_lo, |
495 uint64_t token_hi, | 495 uint64_t token_hi, |
496 IPC::PlatformFileForTransit ipc_fd, | 496 IPC::PlatformFileForTransit ipc_fd, |
497 base::FilePath file_path) { | 497 base::FilePath file_path) { |
498 resolved_cb_.Run(ipc_fd, file_path); | 498 resolved_cb_.Run(ipc_fd, file_path); |
499 resolved_cb_.Reset(); | 499 resolved_cb_.Reset(); |
500 } | 500 } |
OLD | NEW |