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 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ | 5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ |
6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ | 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "native_client/src/include/nacl_macros.h" | 11 #include "native_client/src/include/nacl_macros.h" |
12 #include "native_client/src/include/nacl_scoped_ptr.h" | 12 #include "native_client/src/include/nacl_scoped_ptr.h" |
13 #include "native_client/src/include/nacl_string.h" | 13 #include "native_client/src/include/nacl_string.h" |
14 #include "native_client/src/shared/platform/nacl_threads.h" | 14 #include "native_client/src/shared/platform/nacl_threads.h" |
15 #include "native_client/src/shared/platform/nacl_sync_checked.h" | 15 #include "native_client/src/shared/platform/nacl_sync_checked.h" |
16 #include "native_client/src/trusted/plugin/plugin_error.h" | 16 #include "native_client/src/trusted/plugin/plugin_error.h" |
17 #include "native_client/src/trusted/plugin/service_runtime.h" | 17 #include "native_client/src/trusted/plugin/service_runtime.h" |
18 | 18 |
19 #include "ppapi/cpp/completion_callback.h" | 19 #include "ppapi/cpp/completion_callback.h" |
20 | 20 |
21 namespace nacl { | 21 namespace nacl { |
22 class DescWrapper; | 22 class DescWrapper; |
23 } | 23 } |
24 | 24 |
25 | 25 |
26 namespace plugin { | 26 namespace plugin { |
27 | 27 |
28 class LocalTempFile; | |
29 class Manifest; | 28 class Manifest; |
30 class NaClSubprocess; | 29 class NaClSubprocess; |
31 class Plugin; | 30 class Plugin; |
32 class PnaclResources; | 31 class PnaclResources; |
33 class TempFile; | 32 class TempFile; |
34 | 33 |
35 class PnaclTranslateThread { | 34 class PnaclTranslateThread { |
36 public: | 35 public: |
37 PnaclTranslateThread(); | 36 PnaclTranslateThread(); |
38 ~PnaclTranslateThread(); | 37 ~PnaclTranslateThread(); |
39 | 38 |
40 // Start the translation process. It will continue to run and consume data | 39 // Start the translation process. It will continue to run and consume data |
41 // as it is passed in with PutBytes. | 40 // as it is passed in with PutBytes. |
42 void RunTranslate(const pp::CompletionCallback& finish_callback, | 41 void RunTranslate(const pp::CompletionCallback& finish_callback, |
43 const Manifest* manifest, | 42 const Manifest* manifest, |
44 const Manifest* ld_manifest, | 43 const Manifest* ld_manifest, |
45 TempFile* obj_file, | 44 TempFile* obj_file, |
46 LocalTempFile* nexe_file, | 45 TempFile* nexe_file, |
47 ErrorInfo* error_info, | 46 ErrorInfo* error_info, |
48 PnaclResources* resources, | 47 PnaclResources* resources, |
49 Plugin* plugin); | 48 Plugin* plugin); |
50 | 49 |
51 // Kill the llc and/or ld subprocesses. This happens by closing the command | 50 // Kill the llc and/or ld subprocesses. This happens by closing the command |
52 // channel on the plugin side, which causes the trusted code in the nexe to | 51 // channel on the plugin side, which causes the trusted code in the nexe to |
53 // exit, which will cause any pending SRPCs to error. Because this is called | 52 // exit, which will cause any pending SRPCs to error. Because this is called |
54 // on the main thread, the translation thread must not use the subprocess | 53 // on the main thread, the translation thread must not use the subprocess |
55 // objects without the lock, other than InvokeSrpcMethod, which does not | 54 // objects without the lock, other than InvokeSrpcMethod, which does not |
56 // race with service runtime shutdown. | 55 // race with service runtime shutdown. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // main thread to the SRPC thread. Protected by cond_mu_ | 100 // main thread to the SRPC thread. Protected by cond_mu_ |
102 std::deque<std::vector<char> > data_buffers_; | 101 std::deque<std::vector<char> > data_buffers_; |
103 // Whether all data has been downloaded and copied to translation thread. | 102 // Whether all data has been downloaded and copied to translation thread. |
104 // Associated with buffer_cond_ | 103 // Associated with buffer_cond_ |
105 bool done_; | 104 bool done_; |
106 | 105 |
107 // Data about the translation files, owned by the coordinator | 106 // Data about the translation files, owned by the coordinator |
108 const Manifest* manifest_; | 107 const Manifest* manifest_; |
109 const Manifest* ld_manifest_; | 108 const Manifest* ld_manifest_; |
110 TempFile* obj_file_; | 109 TempFile* obj_file_; |
111 LocalTempFile* nexe_file_; | 110 TempFile* nexe_file_; |
112 ErrorInfo* coordinator_error_info_; | 111 ErrorInfo* coordinator_error_info_; |
113 PnaclResources* resources_; | 112 PnaclResources* resources_; |
114 Plugin* plugin_; | 113 Plugin* plugin_; |
115 private: | 114 private: |
116 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclTranslateThread); | 115 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclTranslateThread); |
117 }; | 116 }; |
118 | 117 |
119 } | 118 } |
120 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ | 119 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_TRANSLATE_THREAD_H_ |
OLD | NEW |