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_COORDINATOR_H_ | 5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ |
6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ | 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 21 matching lines...) Expand all Loading... | |
32 #include "ppapi/cpp/file_system.h" | 32 #include "ppapi/cpp/file_system.h" |
33 | 33 |
34 | 34 |
35 namespace plugin { | 35 namespace plugin { |
36 | 36 |
37 class Manifest; | 37 class Manifest; |
38 class Plugin; | 38 class Plugin; |
39 class PnaclCoordinator; | 39 class PnaclCoordinator; |
40 class PnaclTranslateThread; | 40 class PnaclTranslateThread; |
41 | 41 |
42 // A thread safe reference counting class Needed for CompletionCallbackFactory | |
43 // in PnaclCoordinator. | |
44 class PnaclRefCount { | |
45 public: | |
46 PnaclRefCount() : ref_(0) { NaClXMutexCtor(&mu_); } | |
47 ~PnaclRefCount() { NaClMutexDtor(&mu_); } | |
48 int32_t AddRef() { | |
49 nacl::MutexLocker ml(&mu_); | |
50 return ++ref_; | |
51 } | |
52 int32_t Release() { | |
53 nacl::MutexLocker ml(&mu_); | |
54 return --ref_; | |
55 } | |
56 | |
57 private: | |
58 int32_t ref_; | |
59 struct NaClMutex mu_; | |
60 }; | |
61 | |
62 // A class invoked by Plugin to handle PNaCl client-side translation. | 42 // A class invoked by Plugin to handle PNaCl client-side translation. |
63 // Usage: | 43 // Usage: |
64 // (1) Invoke the factory method, e.g., | 44 // (1) Invoke the factory method, e.g., |
65 // PnaclCoordinator* coord = BitcodeToNative(plugin, | 45 // PnaclCoordinator* coord = BitcodeToNative(plugin, |
66 // "http://foo.com/my.pexe", | 46 // "http://foo.com/my.pexe", |
67 // TranslateNotifyCallback); | 47 // TranslateNotifyCallback); |
68 // (2) TranslateNotifyCallback gets invoked when translation is complete. | 48 // (2) TranslateNotifyCallback gets invoked when translation is complete. |
69 // If the translation was successful, the pp_error argument is PP_OK. | 49 // If the translation was successful, the pp_error argument is PP_OK. |
70 // Other values indicate errors. | 50 // Other values indicate errors. |
71 // (3) After finish_callback runs, get the file descriptor of the translated | 51 // (3) After finish_callback runs, get the file descriptor of the translated |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 | 178 |
199 void TranslateFinished(int32_t pp_error); | 179 void TranslateFinished(int32_t pp_error); |
200 // Keeps track of the pp_error upon entry to TranslateFinished, | 180 // Keeps track of the pp_error upon entry to TranslateFinished, |
201 // for inspection after cleanup. | 181 // for inspection after cleanup. |
202 int32_t translate_finish_error_; | 182 int32_t translate_finish_error_; |
203 | 183 |
204 // The plugin owning the nexe for which we are doing translation. | 184 // The plugin owning the nexe for which we are doing translation. |
205 Plugin* plugin_; | 185 Plugin* plugin_; |
206 | 186 |
207 pp::CompletionCallback translate_notify_callback_; | 187 pp::CompletionCallback translate_notify_callback_; |
208 // PnaclRefCount is only needed to support file lookups. | |
209 // TODO(sehr): remove this when file lookup is through ReverseService. | 188 // TODO(sehr): remove this when file lookup is through ReverseService. |
Derek Schuff
2012/07/10 20:31:54
this comment goes with the previous comment that w
brettw
2012/07/10 21:06:09
Done.
| |
210 pp::CompletionCallbackFactory<PnaclCoordinator, | 189 pp::CompletionCallbackFactory<PnaclCoordinator, |
211 PnaclRefCount> callback_factory_; | 190 pp::ThreadSafeThreadTraits> callback_factory_; |
212 | 191 |
213 // Nexe from the final native Link. | 192 // Nexe from the final native Link. |
214 nacl::scoped_ptr<nacl::DescWrapper> translated_fd_; | 193 nacl::scoped_ptr<nacl::DescWrapper> translated_fd_; |
215 | 194 |
216 // Translation creates local temporary files. | 195 // Translation creates local temporary files. |
217 nacl::scoped_ptr<pp::FileSystem> file_system_; | 196 nacl::scoped_ptr<pp::FileSystem> file_system_; |
218 // The manifest used by resource loading and llc's reverse service to look up | 197 // The manifest used by resource loading and llc's reverse service to look up |
219 // objects and libraries. | 198 // objects and libraries. |
220 nacl::scoped_ptr<const Manifest> manifest_; | 199 nacl::scoped_ptr<const Manifest> manifest_; |
221 // TEMPORARY: ld needs to look up dynamic libraries in the nexe's manifest | 200 // TEMPORARY: ld needs to look up dynamic libraries in the nexe's manifest |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 // Keep this last in declaration order to ensure the other variables | 235 // Keep this last in declaration order to ensure the other variables |
257 // haven't been destroyed yet when its destructor runs. | 236 // haven't been destroyed yet when its destructor runs. |
258 nacl::scoped_ptr<PnaclTranslateThread> translate_thread_; | 237 nacl::scoped_ptr<PnaclTranslateThread> translate_thread_; |
259 | 238 |
260 }; | 239 }; |
261 | 240 |
262 //---------------------------------------------------------------------- | 241 //---------------------------------------------------------------------- |
263 | 242 |
264 } // namespace plugin; | 243 } // namespace plugin; |
265 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ | 244 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ |
OLD | NEW |