OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/nacl/nacl_listener.h" | 5 #include "chrome/nacl/nacl_listener.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 return result; | 123 return result; |
124 } | 124 } |
125 | 125 |
126 virtual void SetKnownToValidate(const std::string& signature) OVERRIDE { | 126 virtual void SetKnownToValidate(const std::string& signature) OVERRIDE { |
127 // Caching is optional: NaCl will still work correctly if the IPC fails. | 127 // Caching is optional: NaCl will still work correctly if the IPC fails. |
128 if (!listener_->Send(new NaClProcessMsg_SetKnownToValidate(signature))) { | 128 if (!listener_->Send(new NaClProcessMsg_SetKnownToValidate(signature))) { |
129 LOG(ERROR) << "Failed to update NaCl validation cache."; | 129 LOG(ERROR) << "Failed to update NaCl validation cache."; |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
| 133 virtual bool ResolveFileNonce(uint64 nonce, int32* fd, |
| 134 std::string* path) OVERRIDE { |
| 135 *fd = -1; |
| 136 *path = ""; |
| 137 if (nonce == 0) { |
| 138 return false; |
| 139 } |
| 140 IPC::PlatformFileForTransit ipc_fd; |
| 141 base::FilePath ipc_path; |
| 142 if (!listener_->Send(new NaClProcessMsg_ResolveFileNonce(nonce, &ipc_fd, |
| 143 &ipc_path))) { |
| 144 return false; |
| 145 } |
| 146 if (ipc_fd == IPC::InvalidPlatformFileForTransit()) { |
| 147 return false; |
| 148 } |
| 149 base::PlatformFile handle = |
| 150 IPC::PlatformFileForTransitToPlatformFile(ipc_fd); |
| 151 #if defined(OS_WIN) |
| 152 // On Windows, valid handles are 32 bit unsigned integers so this is safe. |
| 153 *fd = reinterpret_cast<uintptr_t>(handle); |
| 154 #else |
| 155 *fd = handle; |
| 156 #endif |
| 157 *path = ipc_path.AsUTF8Unsafe(); |
| 158 return true; |
| 159 } |
| 160 |
133 private: | 161 private: |
134 // The listener never dies, otherwise this might be a dangling reference. | 162 // The listener never dies, otherwise this might be a dangling reference. |
135 NaClListener* listener_; | 163 NaClListener* listener_; |
136 }; | 164 }; |
137 | 165 |
138 | 166 |
139 NaClListener::NaClListener() : shutdown_event_(true, false), | 167 NaClListener::NaClListener() : shutdown_event_(true, false), |
140 io_thread_("NaCl_IOThread"), | 168 io_thread_("NaCl_IOThread"), |
141 #if defined(OS_LINUX) | 169 #if defined(OS_LINUX) |
142 prereserved_sandbox_size_(0), | 170 prereserved_sandbox_size_(0), |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 #if defined(OS_WIN) | 304 #if defined(OS_WIN) |
277 args->broker_duplicate_handle_func = BrokerDuplicateHandle; | 305 args->broker_duplicate_handle_func = BrokerDuplicateHandle; |
278 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; | 306 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; |
279 #endif | 307 #endif |
280 #if defined(OS_LINUX) | 308 #if defined(OS_LINUX) |
281 args->prereserved_sandbox_size = prereserved_sandbox_size_; | 309 args->prereserved_sandbox_size = prereserved_sandbox_size_; |
282 #endif | 310 #endif |
283 NaClChromeMainStart(args); | 311 NaClChromeMainStart(args); |
284 NOTREACHED(); | 312 NOTREACHED(); |
285 } | 313 } |
OLD | NEW |