| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_THREAD_ARGS_H_ | |
| 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_THREAD_ARGS_H_ | |
| 7 | |
| 8 #include "native_client/src/trusted/plugin/plugin_error.h" | |
| 9 | |
| 10 #include "ppapi/cpp/completion_callback.h" | |
| 11 | |
| 12 namespace plugin { | |
| 13 | |
| 14 class BrowserInterface; | |
| 15 class NaClSubprocess; | |
| 16 class PnaclCoordinator; | |
| 17 | |
| 18 // Base structure for storing pnacl helper thread arguments. | |
| 19 struct PnaclThreadArgs { | |
| 20 PnaclThreadArgs(NaClSubprocess* subprocess_, | |
| 21 BrowserInterface* browser_, | |
| 22 pp::CompletionCallback finish_cb_) | |
| 23 : should_die(false), | |
| 24 subprocess(subprocess_), | |
| 25 browser(browser_), | |
| 26 finish_cb(finish_cb_) { | |
| 27 } | |
| 28 | |
| 29 // Bool to signal to the thread that it should end whenever possible. | |
| 30 bool should_die; | |
| 31 | |
| 32 // SRPC Nexe subprocess that does the work. | |
| 33 NaClSubprocess* subprocess; | |
| 34 // Browser Interface for SRPC setup. | |
| 35 BrowserInterface* browser; | |
| 36 | |
| 37 // Callback to run when task is completed or an error has occurred. | |
| 38 pp::CompletionCallback finish_cb; | |
| 39 | |
| 40 ErrorInfo error_info; | |
| 41 }; | |
| 42 | |
| 43 //---------------------------------------------------------------------- | |
| 44 // Helper thread arguments. | |
| 45 | |
| 46 // TODO(jvoung): Move these to the compile / link files when we separate | |
| 47 // those bits from pnacl_coordinator. | |
| 48 | |
| 49 // Arguments needed to run LLVM in a separate thread, to go from | |
| 50 // bitcode -> object file. This prevents LLVM from blocking the main thread. | |
| 51 struct DoTranslateArgs : PnaclThreadArgs { | |
| 52 DoTranslateArgs(NaClSubprocess* subprocess_, | |
| 53 BrowserInterface* browser_, | |
| 54 pp::CompletionCallback finish_cb_, | |
| 55 nacl::DescWrapper* pexe_fd_) | |
| 56 : PnaclThreadArgs(subprocess_, browser_, finish_cb_), | |
| 57 pexe_fd(pexe_fd_), | |
| 58 obj_fd(kNaClSrpcInvalidImcDesc), | |
| 59 obj_len(-1) { | |
| 60 } | |
| 61 | |
| 62 // Borrowed references which must outlive the thread. | |
| 63 nacl::DescWrapper* pexe_fd; | |
| 64 | |
| 65 // Output. | |
| 66 NaClSrpcImcDescType obj_fd; | |
| 67 int32_t obj_len; | |
| 68 }; | |
| 69 | |
| 70 // Arguments needed to run LD in a separate thread, to go from | |
| 71 // object file -> nexe. | |
| 72 struct DoLinkArgs : PnaclThreadArgs { | |
| 73 DoLinkArgs(NaClSubprocess* subprocess_, | |
| 74 BrowserInterface* browser_, | |
| 75 pp::CompletionCallback finish_cb_, | |
| 76 PnaclCoordinator* coordinator_, | |
| 77 nacl::DescWrapper* obj_fd_, | |
| 78 int32_t obj_len_) | |
| 79 : PnaclThreadArgs(subprocess_, browser_, finish_cb_), | |
| 80 coordinator(coordinator_), | |
| 81 obj_fd(obj_fd_), | |
| 82 obj_len(obj_len_), | |
| 83 nexe_fd(kNaClSrpcInvalidImcDesc) { | |
| 84 } | |
| 85 PnaclCoordinator* coordinator; // Punch hole in abstraction. | |
| 86 | |
| 87 // Borrowed references which must outlive the thread. | |
| 88 nacl::DescWrapper* obj_fd; | |
| 89 int32_t obj_len; | |
| 90 | |
| 91 // Output. | |
| 92 NaClSrpcImcDescType nexe_fd; | |
| 93 }; | |
| 94 | |
| 95 | |
| 96 } // namespace plugin; | |
| 97 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_THREAD_ARGS_H_ | |
| OLD | NEW |