OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 subprocesses_should_die_(false) { | 83 subprocesses_should_die_(false) { |
84 NaClXMutexCtor(&subprocess_mu_); | 84 NaClXMutexCtor(&subprocess_mu_); |
85 } | 85 } |
86 | 86 |
87 virtual ~PnaclCoordinator(); | 87 virtual ~PnaclCoordinator(); |
88 | 88 |
89 // Initialize() can only be called once during the lifetime of this instance. | 89 // Initialize() can only be called once during the lifetime of this instance. |
90 void Initialize(Plugin* instance); | 90 void Initialize(Plugin* instance); |
91 | 91 |
92 void BitcodeToNative(const nacl::string& pexe_url, | 92 void BitcodeToNative(const nacl::string& pexe_url, |
93 const nacl::string& llc_url, | |
94 const nacl::string& ld_url, | |
95 const pp::CompletionCallback& finish_callback); | 93 const pp::CompletionCallback& finish_callback); |
96 | 94 |
97 // Call this to take ownership of the FD of the translated nexe after | 95 // Call this to take ownership of the FD of the translated nexe after |
98 // BitcodeToNative has completed (and the finish_callback called). | 96 // BitcodeToNative has completed (and the finish_callback called). |
99 nacl::DescWrapper* ReleaseTranslatedFD() { | 97 nacl::DescWrapper* ReleaseTranslatedFD() { |
100 return translated_fd_.release(); | 98 return translated_fd_.release(); |
101 } | 99 } |
102 | 100 |
103 int32_t GetLoadedFileDesc(int32_t pp_error, | 101 int32_t GetLoadedFileDesc(int32_t pp_error, |
104 const nacl::string& url, | 102 const nacl::string& url, |
105 const nacl::string& component); | 103 const nacl::string& component); |
106 | 104 |
107 // Run when faced with a PPAPI error condition. It brings control back to the | 105 // Run when faced with a PPAPI error condition. It brings control back to the |
108 // plugin by invoking the |translate_notify_callback_|. | 106 // plugin by invoking the |translate_notify_callback_|. |
109 void PnaclPpapiError(int32_t pp_error); | 107 void PnaclPpapiError(int32_t pp_error); |
110 // Run |translate_notify_callback_| with an error condition that is not | 108 // Run |translate_notify_callback_| with an error condition that is not |
111 // PPAPI specific. | 109 // PPAPI specific. |
112 void PnaclNonPpapiError(); | 110 void PnaclNonPpapiError(); |
113 // Wrapper for Plugin ReportLoadAbort. | 111 // Wrapper for Plugin ReportLoadAbort. |
114 void ReportLoadAbort(); | 112 void ReportLoadAbort(); |
115 // Wrapper for Plugin ReportLoadError. | 113 // Wrapper for Plugin ReportLoadError. |
116 void ReportLoadError(const ErrorInfo& error); | 114 void ReportLoadError(const ErrorInfo& error); |
117 | 115 |
118 | |
119 | |
120 // Accessors for use by helper threads. | 116 // Accessors for use by helper threads. |
| 117 nacl::string resource_base_url() const { return resource_base_url_; } |
121 Plugin* plugin() const { return plugin_; } | 118 Plugin* plugin() const { return plugin_; } |
122 nacl::string llc_url() const { return llc_url_; } | 119 nacl::string llc_url() const { return llc_url_; } |
123 NaClSubprocess* llc_subprocess() const { return llc_subprocess_; } | 120 NaClSubprocess* llc_subprocess() const { return llc_subprocess_; } |
124 bool StartLlcSubProcess(); | 121 bool StartLlcSubProcess(); |
125 nacl::string ld_url() const { return ld_url_; } | 122 nacl::string ld_url() const { return ld_url_; } |
126 NaClSubprocess* ld_subprocess() const { return ld_subprocess_; } | 123 NaClSubprocess* ld_subprocess() const { return ld_subprocess_; } |
127 bool StartLdSubProcess(); | 124 bool StartLdSubProcess(); |
128 bool SubprocessesShouldDie(); | 125 bool SubprocessesShouldDie(); |
129 void SetSubprocessesShouldDie(bool subprocesses_should_die); | 126 void SetSubprocessesShouldDie(bool subprocesses_should_die); |
130 PnaclResources* resources() const { return resources_.get(); } | 127 PnaclResources* resources() const { return resources_.get(); } |
(...skipping 15 matching lines...) Expand all Loading... |
146 void PnaclDidFinish(int32_t pp_error, PnaclTranslationUnit* translation_unit); | 143 void PnaclDidFinish(int32_t pp_error, PnaclTranslationUnit* translation_unit); |
147 | 144 |
148 private: | 145 private: |
149 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclCoordinator); | 146 NACL_DISALLOW_COPY_AND_ASSIGN(PnaclCoordinator); |
150 | 147 |
151 Plugin* plugin_; | 148 Plugin* plugin_; |
152 pp::CompletionCallback translate_notify_callback_; | 149 pp::CompletionCallback translate_notify_callback_; |
153 pp::CompletionCallbackFactory<PnaclCoordinator> callback_factory_; | 150 pp::CompletionCallbackFactory<PnaclCoordinator> callback_factory_; |
154 | 151 |
155 // URLs used to lookup downloaded resources. | 152 // URLs used to lookup downloaded resources. |
| 153 nacl::string resource_base_url_; |
156 nacl::string llc_url_; | 154 nacl::string llc_url_; |
157 nacl::string ld_url_; | 155 nacl::string ld_url_; |
158 | 156 |
159 // Helper subprocesses loaded by the plugin (deleted by the plugin). | 157 // Helper subprocesses loaded by the plugin (deleted by the plugin). |
160 // We may want to do cleanup ourselves when we are in the | 158 // We may want to do cleanup ourselves when we are in the |
161 // business of compiling multiple bitcode objects / libraries, and | 159 // business of compiling multiple bitcode objects / libraries, and |
162 // if we truly cannot reuse existing loaded subprocesses. | 160 // if we truly cannot reuse existing loaded subprocesses. |
163 NaClSubprocess* llc_subprocess_; | 161 NaClSubprocess* llc_subprocess_; |
164 NaClSubprocess* ld_subprocess_; | 162 NaClSubprocess* ld_subprocess_; |
165 bool subprocesses_should_die_; | 163 bool subprocesses_should_die_; |
(...skipping 10 matching lines...) Expand all Loading... |
176 nacl::scoped_ptr<NaClThread> link_thread_; | 174 nacl::scoped_ptr<NaClThread> link_thread_; |
177 | 175 |
178 // An auxiliary class that manages downloaded resources. | 176 // An auxiliary class that manages downloaded resources. |
179 nacl::scoped_ptr<PnaclResources> resources_; | 177 nacl::scoped_ptr<PnaclResources> resources_; |
180 }; | 178 }; |
181 | 179 |
182 //---------------------------------------------------------------------- | 180 //---------------------------------------------------------------------- |
183 | 181 |
184 } // namespace plugin; | 182 } // namespace plugin; |
185 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ | 183 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_PNACL_COORDINATOR_H_ |
OLD | NEW |