Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Unified Diff: remoting/host/plugin/host_plugin.cc

Issue 7648042: Change Chromoting logger to be setup in plugin's NP_Initialize. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/plugin/host_log_handler.cc ('k') | remoting/host/plugin/host_script_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/plugin/host_plugin.cc
diff --git a/remoting/host/plugin/host_plugin.cc b/remoting/host/plugin/host_plugin.cc
index 077637276f1768d00f579542df08f0139839ba7f..4c88551b24f8deedce13923440991f5c27a8789d 100644
--- a/remoting/host/plugin/host_plugin.cc
+++ b/remoting/host/plugin/host_plugin.cc
@@ -13,6 +13,7 @@
#include "base/logging.h"
#include "base/stringize_macros.h"
#include "remoting/base/plugin_message_loop_proxy.h"
+#include "remoting/host/plugin/host_log_handler.h"
#include "remoting/host/plugin/host_plugin_utils.h"
#include "remoting/host/plugin/host_script_object.h"
#include "third_party/npapi/bindings/npapi.h"
@@ -43,6 +44,7 @@ uint64_t __cdecl __udivdi3(uint64_t a, uint64_t b) {
#endif
using remoting::g_npnetscape_funcs;
+using remoting::HostLogHandler;
using remoting::HostNPScriptObject;
using remoting::StringFromNPIdentifier;
@@ -352,6 +354,12 @@ NPError CreatePlugin(NPMIMEType pluginType,
char** argv,
NPSavedData* saved) {
VLOG(2) << "CreatePlugin";
+
+ // Register a global log handler.
+ // The LogMessage registration code is not thread-safe, so we need to perform
+ // this while we're running in a single thread.
+ HostLogHandler::RegisterLogMessageHandler();
+
HostNPPlugin* plugin = new HostNPPlugin(instance, mode);
instance->pdata = plugin;
if (!plugin->Init(argc, argn, argv, saved)) {
@@ -366,6 +374,14 @@ NPError CreatePlugin(NPMIMEType pluginType,
NPError DestroyPlugin(NPP instance,
NPSavedData** save) {
VLOG(2) << "DestroyPlugin";
+
+ // Normally, we would unregister the global log handler that we registered
+ // in CreatePlugin. However, the LogHandler registration code is not thread-
+ // safe so we could crash if we update (register or unregister) the
+ // LogHandler while it's being read on another thread.
+ // At this point, all our threads should be shutdown, but it's safer to leave
+ // the handler registered until we're completely destroyed.
+
HostNPPlugin* plugin = PluginFromInstance(instance);
if (plugin) {
plugin->Save(save);
« no previous file with comments | « remoting/host/plugin/host_log_handler.cc ('k') | remoting/host/plugin/host_script_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698