OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/nacl/renderer/ppb_nacl_private_impl.h" | 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/containers/scoped_ptr_hash_map.h" | 10 #include "base/containers/scoped_ptr_hash_map.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 } | 151 } |
152 | 152 |
153 private: | 153 private: |
154 int num_remaining_calls_; | 154 int num_remaining_calls_; |
155 PP_CompletionCallback callback_; | 155 PP_CompletionCallback callback_; |
156 int32_t result_; | 156 int32_t result_; |
157 | 157 |
158 DISALLOW_COPY_AND_ASSIGN(ChannelConnectedCallback); | 158 DISALLOW_COPY_AND_ASSIGN(ChannelConnectedCallback); |
159 }; | 159 }; |
160 | 160 |
161 // Thin adapter from PP_ManifestService to ManifestServiceChannel::Delegate. | 161 // Thin adapter from PPP_ManifestService to ManifestServiceChannel::Delegate. |
162 // Note that user_data is managed by the caller of LaunchSelLdr. Please see | 162 // Note that user_data is managed by the caller of LaunchSelLdr. Please see |
163 // also PP_ManifestService's comment for more details about resource | 163 // also PP_ManifestService's comment for more details about resource |
164 // management. | 164 // management. |
165 class ManifestServiceProxy : public ManifestServiceChannel::Delegate { | 165 class ManifestServiceProxy : public ManifestServiceChannel::Delegate { |
166 public: | 166 public: |
167 ManifestServiceProxy(const PP_ManifestService* manifest_service, | 167 ManifestServiceProxy(const PPP_ManifestService* manifest_service, |
168 void* user_data) | 168 void* user_data) |
169 : manifest_service_(*manifest_service), | 169 : manifest_service_(*manifest_service), |
170 user_data_(user_data) { | 170 user_data_(user_data) { |
171 } | 171 } |
172 | 172 |
173 virtual ~ManifestServiceProxy() { | 173 virtual ~ManifestServiceProxy() { |
174 Quit(); | 174 Quit(); |
175 } | 175 } |
176 | 176 |
177 virtual void StartupInitializationComplete() OVERRIDE { | 177 virtual void StartupInitializationComplete() OVERRIDE { |
178 if (!user_data_) | 178 if (!user_data_) |
179 return; | 179 return; |
180 | 180 |
181 if (!PP_ToBool( | 181 if (!PP_ToBool( |
182 manifest_service_.StartupInitializationComplete(user_data_))) { | 182 manifest_service_.StartupInitializationComplete(user_data_))) { |
183 user_data_ = NULL; | 183 user_data_ = NULL; |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 virtual void OpenResource( | |
188 const std::string& key, | |
189 const ManifestServiceChannel::OpenResourceCallback& callback) OVERRIDE { | |
190 if (!user_data_) | |
191 return; | |
192 | |
193 // The allocated callback will be freed in DidOpenResource, which is always | |
194 // called regardless whether OpenResource() succeeds or fails. | |
195 if (!PP_ToBool(manifest_service_.OpenResource( | |
196 user_data_, | |
197 key.c_str(), | |
198 DidOpenResource, | |
199 new ManifestServiceChannel::OpenResourceCallback(callback)))) { | |
200 user_data_ = NULL; | |
201 } | |
202 } | |
203 | |
187 private: | 204 private: |
205 static void DidOpenResource(void* user_data, PP_FileHandle file_handle) { | |
206 scoped_ptr<ManifestServiceChannel::OpenResourceCallback> callback( | |
207 static_cast<ManifestServiceChannel::OpenResourceCallback*>(user_data)); | |
208 callback->Run(file_handle); | |
209 } | |
210 | |
188 void Quit() { | 211 void Quit() { |
189 if (!user_data_) | 212 if (!user_data_) |
190 return; | 213 return; |
191 | 214 |
192 bool result = PP_ToBool(manifest_service_.Quit(user_data_)); | 215 bool result = PP_ToBool(manifest_service_.Quit(user_data_)); |
193 DCHECK(!result); | 216 DCHECK(!result); |
194 user_data_ = NULL; | 217 user_data_ = NULL; |
195 } | 218 } |
196 | 219 |
197 PP_ManifestService manifest_service_; | 220 PPP_ManifestService manifest_service_; |
198 void* user_data_; | 221 void* user_data_; |
199 DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy); | 222 DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy); |
200 }; | 223 }; |
201 | 224 |
202 // Launch NaCl's sel_ldr process. | 225 // Launch NaCl's sel_ldr process. |
203 void LaunchSelLdr(PP_Instance instance, | 226 void LaunchSelLdr(PP_Instance instance, |
204 const char* alleged_url, | 227 const char* alleged_url, |
205 PP_Bool uses_irt, | 228 PP_Bool uses_irt, |
206 PP_Bool uses_ppapi, | 229 PP_Bool uses_ppapi, |
207 PP_Bool uses_nonsfi_mode, | 230 PP_Bool uses_nonsfi_mode, |
208 PP_Bool enable_ppapi_dev, | 231 PP_Bool enable_ppapi_dev, |
209 PP_Bool enable_dyncode_syscalls, | 232 PP_Bool enable_dyncode_syscalls, |
210 PP_Bool enable_exception_handling, | 233 PP_Bool enable_exception_handling, |
211 PP_Bool enable_crash_throttling, | 234 PP_Bool enable_crash_throttling, |
212 const PP_ManifestService* manifest_service_interface, | 235 const PPP_ManifestService* manifest_service_interface, |
213 void* manifest_service_user_data, | 236 void* manifest_service_user_data, |
214 void* imc_handle, | 237 void* imc_handle, |
215 struct PP_Var* error_message, | 238 struct PP_Var* error_message, |
216 PP_CompletionCallback callback) { | 239 PP_CompletionCallback callback) { |
217 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> | 240 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> |
218 BelongsToCurrentThread()); | 241 BelongsToCurrentThread()); |
219 | 242 |
220 // Create the manifest service proxy here, so on error case, it will be | 243 // Create the manifest service proxy here, so on error case, it will be |
221 // destructed (without passing it to ManifestServiceChannel), and QUIT | 244 // destructed (without passing it to ManifestServiceChannel), and QUIT |
222 // will be called in its destructor so that the caller of this function | 245 // will be called in its destructor so that the caller of this function |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 } else { | 342 } else { |
320 connected_callback.Run(PP_ERROR_FAILED); | 343 connected_callback.Run(PP_ERROR_FAILED); |
321 } | 344 } |
322 | 345 |
323 // Stash the manifest service handle as well. | 346 // Stash the manifest service handle as well. |
324 if (load_manager && | 347 if (load_manager && |
325 IsValidChannelHandle( | 348 IsValidChannelHandle( |
326 launch_result.manifest_service_ipc_channel_handle)) { | 349 launch_result.manifest_service_ipc_channel_handle)) { |
327 scoped_ptr<ManifestServiceChannel> manifest_service_channel( | 350 scoped_ptr<ManifestServiceChannel> manifest_service_channel( |
328 new ManifestServiceChannel( | 351 new ManifestServiceChannel( |
352 !enable_dyncode_syscalls, // true, on a plugin in PNaCl mode. | |
Mark Seaborn
2014/05/01 06:32:35
Actually, let's make this stricter and use:
!ena
hidehiko
2014/05/01 13:05:40
Done.
| |
329 launch_result.manifest_service_ipc_channel_handle, | 353 launch_result.manifest_service_ipc_channel_handle, |
330 connected_callback, | 354 connected_callback, |
331 manifest_service_proxy.Pass(), | 355 manifest_service_proxy.Pass(), |
332 content::RenderThread::Get()->GetShutdownEvent())); | 356 content::RenderThread::Get()->GetShutdownEvent())); |
333 load_manager->set_manifest_service_channel( | 357 load_manager->set_manifest_service_channel( |
334 manifest_service_channel.Pass()); | 358 manifest_service_channel.Pass()); |
335 } else { | 359 } else { |
336 // Currently, manifest service works only on linux/non-SFI mode. | 360 // Currently, manifest service works only on linux/non-SFI mode. |
337 // On other platforms, the socket will not be created, and thus this | 361 // On other platforms, the socket will not be created, and thus this |
338 // condition needs to be handled as success. | 362 // condition needs to be handled as success. |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
892 &DevInterfacesEnabled | 916 &DevInterfacesEnabled |
893 }; | 917 }; |
894 | 918 |
895 } // namespace | 919 } // namespace |
896 | 920 |
897 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 921 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
898 return &nacl_interface; | 922 return &nacl_interface; |
899 } | 923 } |
900 | 924 |
901 } // namespace nacl | 925 } // namespace nacl |
OLD | NEW |