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

Side by Side Diff: content/plugin/plugin_thread.cc

Issue 10908078: Code to collect issue 97285 debugging info for crash reports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/plugin/plugin_thread.h" 5 #include "content/plugin/plugin_thread.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(TOOLKIT_GTK) 9 #if defined(TOOLKIT_GTK)
10 #include <gtk/gtk.h> 10 #include <gtk/gtk.h>
11 #elif defined(OS_MACOSX) 11 #elif defined(OS_MACOSX)
12 #include <CoreFoundation/CoreFoundation.h> 12 #include <CoreFoundation/CoreFoundation.h>
13 #endif 13 #endif
14 14
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/lazy_instance.h" 20 #include "base/lazy_instance.h"
21 #include "base/process_util.h" 21 #include "base/process_util.h"
22 #include "base/threading/thread_local.h" 22 #include "base/threading/thread_local.h"
23 #include "content/common/child_process.h" 23 #include "content/common/child_process.h"
24 #include "content/common/npobject_util.h" 24 #include "content/common/npobject_util.h"
25 #include "content/common/plugin_messages.h" 25 #include "content/common/plugin_messages.h"
26 #include "content/public/common/content_debug_logging.h"
26 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
27 #include "content/public/plugin/content_plugin_client.h" 28 #include "content/public/plugin/content_plugin_client.h"
28 #include "ipc/ipc_channel_handle.h" 29 #include "ipc/ipc_channel_handle.h"
29 #include "webkit/glue/webkit_glue.h" 30 #include "webkit/glue/webkit_glue.h"
30 #include "webkit/plugins/npapi/plugin_lib.h" 31 #include "webkit/plugins/npapi/plugin_lib.h"
31 #include "webkit/plugins/npapi/plugin_list.h" 32 #include "webkit/plugins/npapi/plugin_list.h"
32 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" 33 #include "webkit/plugins/npapi/webplugin_delegate_impl.h"
33 34
34 #if defined(TOOLKIT_GTK) 35 #if defined(TOOLKIT_GTK)
35 #include "ui/gfx/gtk_util.h" 36 #include "ui/gfx/gtk_util.h"
(...skipping 25 matching lines...) Expand all
61 base::Bind(&EnsureTerminateMessageFilter::Terminate, this), 62 base::Bind(&EnsureTerminateMessageFilter::Terminate, this),
62 kPluginProcessTerminateTimeout); 63 kPluginProcessTerminateTimeout);
63 } 64 }
64 65
65 private: 66 private:
66 void Terminate() { 67 void Terminate() {
67 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); 68 base::KillProcess(base::GetCurrentProcessHandle(), 0, false);
68 } 69 }
69 }; 70 };
70 71
72 void RecordMsg(int bug_id, const std::string& msg) {
73 PluginThread::current()->Send(
74 new PluginProcessHostMsg_RecordMsg(bug_id, msg));
75 }
76
77 bool GetMessages(int bug_id, std::vector<std::string>* msgs) {
78 PluginThread::current()->Send(
79 new PluginProcessHostMsg_GetMessages(bug_id, msgs));
80 return !msgs->empty();
81 }
82
71 } // namespace 83 } // namespace
72 84
73 static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls = 85 static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls =
74 LAZY_INSTANCE_INITIALIZER; 86 LAZY_INSTANCE_INITIALIZER;
75 87
76 PluginThread::PluginThread() 88 PluginThread::PluginThread()
77 : preloaded_plugin_module_(NULL) { 89 : preloaded_plugin_module_(NULL) {
78 FilePath plugin_path = CommandLine::ForCurrentProcess()->GetSwitchValuePath( 90 FilePath plugin_path = CommandLine::ForCurrentProcess()->GetSwitchValuePath(
79 switches::kPluginPath); 91 switches::kPluginPath);
80 92
(...skipping 19 matching lines...) Expand all
100 112
101 // GTK after 2.18 resets the environment variable. But if we're using 113 // GTK after 2.18 resets the environment variable. But if we're using
102 // nspluginwrapper, that means it'll spawn its subprocess without the 114 // nspluginwrapper, that means it'll spawn its subprocess without the
103 // environment variable! So set it again. 115 // environment variable! So set it again.
104 setenv("GDK_NATIVE_WINDOWS", "1", 1); 116 setenv("GDK_NATIVE_WINDOWS", "1", 1);
105 } 117 }
106 118
107 ui::SetDefaultX11ErrorHandlers(); 119 ui::SetDefaultX11ErrorHandlers();
108 #endif 120 #endif
109 121
122 content::debug::RegisterMessageHandlers(RecordMsg, GetMessages);
123
110 PatchNPNFunctions(); 124 PatchNPNFunctions();
111 125
112 // Preload the library to avoid loading, unloading then reloading 126 // Preload the library to avoid loading, unloading then reloading
113 preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path, NULL); 127 preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path, NULL);
114 128
115 scoped_refptr<webkit::npapi::PluginLib> plugin( 129 scoped_refptr<webkit::npapi::PluginLib> plugin(
116 webkit::npapi::PluginLib::CreatePluginLib(plugin_path)); 130 webkit::npapi::PluginLib::CreatePluginLib(plugin_path));
117 if (plugin.get()) { 131 if (plugin.get()) {
118 plugin->NP_Initialize(); 132 plugin->NP_Initialize();
119 // For OOP plugins the plugin dll will be unloaded during process shutdown 133 // For OOP plugins the plugin dll will be unloaded during process shutdown
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (channel.get()) { 184 if (channel.get()) {
171 channel_handle.name = channel->channel_handle().name; 185 channel_handle.name = channel->channel_handle().name;
172 #if defined(OS_POSIX) 186 #if defined(OS_POSIX)
173 // On POSIX, pass the renderer-side FD. 187 // On POSIX, pass the renderer-side FD.
174 channel_handle.socket = 188 channel_handle.socket =
175 base::FileDescriptor(channel->TakeRendererFileDescriptor(), true); 189 base::FileDescriptor(channel->TakeRendererFileDescriptor(), true);
176 #endif 190 #endif
177 channel->set_incognito(incognito); 191 channel->set_incognito(incognito);
178 } 192 }
179 193
194 #if defined(OS_MACOSX)
195 content::debug::RecordMsg(97285, base::StringPrintf(
196 "OnCreateChannel({%s, %d})",
197 channel_handle.name.c_str(), channel_handle.socket.fd));
198 #endif
180 Send(new PluginProcessHostMsg_ChannelCreated(channel_handle)); 199 Send(new PluginProcessHostMsg_ChannelCreated(channel_handle));
181 } 200 }
182 201
183 void PluginThread::OnNotifyRenderersOfPendingShutdown() { 202 void PluginThread::OnNotifyRenderersOfPendingShutdown() {
184 PluginChannel::NotifyRenderersOfPendingShutdown(); 203 PluginChannel::NotifyRenderersOfPendingShutdown();
185 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698