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 #include "content/ppapi_plugin/ppapi_thread.h" | 5 #include "content/ppapi_plugin/ppapi_thread.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/crash_logging.h" | 10 #include "base/debug/crash_logging.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 | 252 |
253 // If the plugin isn't internal then load it from |path|. | 253 // If the plugin isn't internal then load it from |path|. |
254 base::ScopedNativeLibrary library; | 254 base::ScopedNativeLibrary library; |
255 if (plugin_entry_points_.initialize_module == NULL) { | 255 if (plugin_entry_points_.initialize_module == NULL) { |
256 // Load the plugin from the specified library. | 256 // Load the plugin from the specified library. |
257 std::string error; | 257 std::string error; |
258 library.Reset(base::LoadNativeLibrary(path, &error)); | 258 library.Reset(base::LoadNativeLibrary(path, &error)); |
259 if (!library.is_valid()) { | 259 if (!library.is_valid()) { |
260 LOG(ERROR) << "Failed to load Pepper module from " | 260 LOG(ERROR) << "Failed to load Pepper module from " |
261 << path.value() << " (error: " << error << ")"; | 261 << path.value() << " (error: " << error << ")"; |
262 ReportPluginLoadStatus(path, ContentPluginClient::LOAD_FAILED); | |
262 return; | 263 return; |
263 } | 264 } |
264 | 265 |
265 // Get the GetInterface function (required). | 266 // Get the GetInterface function (required). |
ddorwin
2013/04/08 18:04:34
Unrelated comment: It's strange that we get this f
| |
266 plugin_entry_points_.get_interface = | 267 plugin_entry_points_.get_interface = |
267 reinterpret_cast<PP_GetInterface_Func>( | 268 reinterpret_cast<PP_GetInterface_Func>( |
268 library.GetFunctionPointer("PPP_GetInterface")); | 269 library.GetFunctionPointer("PPP_GetInterface")); |
269 if (!plugin_entry_points_.get_interface) { | 270 if (!plugin_entry_points_.get_interface) { |
270 LOG(WARNING) << "No PPP_GetInterface in plugin library"; | 271 LOG(WARNING) << "No PPP_GetInterface in plugin library"; |
272 ReportPluginLoadStatus(path, ContentPluginClient::ENTRY_POINT_MISSING); | |
271 return; | 273 return; |
272 } | 274 } |
273 | 275 |
274 // The ShutdownModule/ShutdownBroker function is optional. | 276 // The ShutdownModule/ShutdownBroker function is optional. |
275 plugin_entry_points_.shutdown_module = | 277 plugin_entry_points_.shutdown_module = |
276 is_broker_ ? | 278 is_broker_ ? |
277 reinterpret_cast<PP_ShutdownModule_Func>( | 279 reinterpret_cast<PP_ShutdownModule_Func>( |
278 library.GetFunctionPointer("PPP_ShutdownBroker")) : | 280 library.GetFunctionPointer("PPP_ShutdownBroker")) : |
279 reinterpret_cast<PP_ShutdownModule_Func>( | 281 reinterpret_cast<PP_ShutdownModule_Func>( |
280 library.GetFunctionPointer("PPP_ShutdownModule")); | 282 library.GetFunctionPointer("PPP_ShutdownModule")); |
281 | 283 |
282 if (!is_broker_) { | 284 if (!is_broker_) { |
283 // Get the InitializeModule function (required for non-broker code). | 285 // Get the InitializeModule function (required for non-broker code). |
284 plugin_entry_points_.initialize_module = | 286 plugin_entry_points_.initialize_module = |
ddorwin
2013/04/08 18:04:34
Unrelated comment: It's weird that we save the ini
| |
285 reinterpret_cast<PP_InitializeModule_Func>( | 287 reinterpret_cast<PP_InitializeModule_Func>( |
286 library.GetFunctionPointer("PPP_InitializeModule")); | 288 library.GetFunctionPointer("PPP_InitializeModule")); |
287 if (!plugin_entry_points_.initialize_module) { | 289 if (!plugin_entry_points_.initialize_module) { |
288 LOG(WARNING) << "No PPP_InitializeModule in plugin library"; | 290 LOG(WARNING) << "No PPP_InitializeModule in plugin library"; |
291 ReportPluginLoadStatus(path, ContentPluginClient::ENTRY_POINT_MISSING); | |
289 return; | 292 return; |
290 } | 293 } |
291 } | 294 } |
292 } | 295 } |
293 | 296 |
294 #if defined(OS_WIN) | 297 #if defined(OS_WIN) |
295 // If code subsequently tries to exit using abort(), force a crash (since | 298 // If code subsequently tries to exit using abort(), force a crash (since |
296 // otherwise these would be silent terminations and fly under the radar). | 299 // otherwise these would be silent terminations and fly under the radar). |
297 base::win::SetAbortBehaviorForCrashReporting(); | 300 base::win::SetAbortBehaviorForCrashReporting(); |
298 if (permissions.HasPermission(ppapi::PERMISSION_FLASH)) { | 301 if (permissions.HasPermission(ppapi::PERMISSION_FLASH)) { |
(...skipping 16 matching lines...) Expand all Loading... | |
315 g_target_services->LowerToken(); | 318 g_target_services->LowerToken(); |
316 } | 319 } |
317 #endif | 320 #endif |
318 | 321 |
319 if (is_broker_) { | 322 if (is_broker_) { |
320 // Get the InitializeBroker function (required). | 323 // Get the InitializeBroker function (required). |
321 InitializeBrokerFunc init_broker = | 324 InitializeBrokerFunc init_broker = |
322 reinterpret_cast<InitializeBrokerFunc>( | 325 reinterpret_cast<InitializeBrokerFunc>( |
323 library.GetFunctionPointer("PPP_InitializeBroker")); | 326 library.GetFunctionPointer("PPP_InitializeBroker")); |
324 if (!init_broker) { | 327 if (!init_broker) { |
325 LOG(WARNING) << "No PPP_InitializeBroker in plugin library"; | 328 LOG(WARNING) << "No PPP_InitializeBroker in plugin library"; |
ddorwin
2013/04/08 18:04:34
This is another ENTRY_POINT_MISSING. Do we want to
xhwang
2013/04/09 00:34:11
Added "is_broker" to report UMA for broker separat
| |
326 return; | 329 return; |
327 } | 330 } |
328 | 331 |
329 int32_t init_error = init_broker(&connect_instance_func_); | 332 int32_t init_error = init_broker(&connect_instance_func_); |
330 if (init_error != PP_OK) { | 333 if (init_error != PP_OK) { |
331 LOG(WARNING) << "InitBroker failed with error " << init_error; | 334 LOG(WARNING) << "InitBroker failed with error " << init_error; |
332 return; | 335 return; |
333 } | 336 } |
334 if (!connect_instance_func_) { | 337 if (!connect_instance_func_) { |
335 LOG(WARNING) << "InitBroker did not provide PP_ConnectInstance_Func"; | 338 LOG(WARNING) << "InitBroker did not provide PP_ConnectInstance_Func"; |
336 return; | 339 return; |
337 } | 340 } |
338 } else { | 341 } else { |
339 #if defined(OS_MACOSX) | 342 #if defined(OS_MACOSX) |
340 // We need to do this after getting |PPP_GetInterface()| (or presumably | 343 // We need to do this after getting |PPP_GetInterface()| (or presumably |
341 // doing something nontrivial with the library), else the sandbox | 344 // doing something nontrivial with the library), else the sandbox |
342 // intercedes. | 345 // intercedes. |
343 CHECK(InitializeSandbox()); | 346 CHECK(InitializeSandbox()); |
344 #endif | 347 #endif |
345 | 348 |
346 int32_t init_error = plugin_entry_points_.initialize_module( | 349 int32_t init_error = plugin_entry_points_.initialize_module( |
347 local_pp_module_, | 350 local_pp_module_, |
348 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); | 351 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); |
349 if (init_error != PP_OK) { | 352 if (init_error != PP_OK) { |
350 LOG(WARNING) << "InitModule failed with error " << init_error; | 353 LOG(WARNING) << "InitModule failed with error " << init_error; |
354 ReportPluginLoadStatus(path, ContentPluginClient::INIT_FAILED); | |
351 return; | 355 return; |
352 } | 356 } |
353 } | 357 } |
354 | 358 |
355 // Initialization succeeded, so keep the plugin DLL loaded. | 359 // Initialization succeeded, so keep the plugin DLL loaded. |
360 ReportPluginLoadStatus(path, ContentPluginClient::LOAD_SUCCESS); | |
356 library_.Reset(library.Release()); | 361 library_.Reset(library.Release()); |
357 } | 362 } |
358 | 363 |
359 void PpapiThread::OnCreateChannel(base::ProcessId renderer_pid, | 364 void PpapiThread::OnCreateChannel(base::ProcessId renderer_pid, |
360 int renderer_child_id, | 365 int renderer_child_id, |
361 bool incognito) { | 366 bool incognito) { |
362 IPC::ChannelHandle channel_handle; | 367 IPC::ChannelHandle channel_handle; |
363 | 368 |
364 if (!plugin_entry_points_.get_interface || // Plugin couldn't be loaded. | 369 if (!plugin_entry_points_.get_interface || // Plugin couldn't be loaded. |
365 !SetupRendererChannel(renderer_pid, renderer_child_id, incognito, | 370 !SetupRendererChannel(renderer_pid, renderer_child_id, incognito, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 | 457 |
453 // From here, the dispatcher will manage its own lifetime according to the | 458 // From here, the dispatcher will manage its own lifetime according to the |
454 // lifetime of the attached channel. | 459 // lifetime of the attached channel. |
455 return true; | 460 return true; |
456 } | 461 } |
457 | 462 |
458 void PpapiThread::SavePluginName(const base::FilePath& path) { | 463 void PpapiThread::SavePluginName(const base::FilePath& path) { |
459 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( | 464 ppapi::proxy::PluginGlobals::Get()->set_plugin_name( |
460 path.BaseName().AsUTF8Unsafe()); | 465 path.BaseName().AsUTF8Unsafe()); |
461 | 466 |
462 // plugin() is NULL when in-process. Which is fine, because this is | 467 // plugin() is NULL when in-process, which is fine, because this is |
463 // just a hook for setting the process name. | 468 // just a hook for setting the process name. |
464 if (GetContentClient()->plugin()) { | 469 if (GetContentClient()->plugin()) { |
465 GetContentClient()->plugin()->PluginProcessStarted( | 470 GetContentClient()->plugin()->PluginProcessStarted( |
466 path.BaseName().RemoveExtension().LossyDisplayName()); | 471 path.BaseName().RemoveExtension().LossyDisplayName()); |
467 } | 472 } |
468 } | 473 } |
469 | 474 |
475 void PpapiThread::ReportPluginLoadStatus( | |
476 const base::FilePath& path, | |
477 ContentPluginClient::PluginLoadStatus status) { | |
478 // plugin() is NULL when in-process, which is fine, because we only care | |
479 // about loading status for out-of-process plugins. | |
480 if (GetContentClient()->plugin()) | |
481 GetContentClient()->plugin()->PluginLoaded(path, status); | |
482 } | |
483 | |
470 } // namespace content | 484 } // namespace content |
OLD | NEW |