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

Side by Side Diff: chrome/browser/ui/hung_plugin_tab_helper.cc

Issue 10909241: Generate dumps for relevant renderers when users kill a hung pepper plugin. (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 "chrome/browser/ui/hung_plugin_tab_helper.h" 5 #include "chrome/browser/ui/hung_plugin_tab_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/process.h"
8 #include "base/process_util.h" 10 #include "base/process_util.h"
11 #include "base/rand_util.h"
9 #include "build/build_config.h" 12 #include "build/build_config.h"
10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" 13 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
11 #include "chrome/browser/infobars/infobar.h" 14 #include "chrome/browser/infobars/infobar.h"
12 #include "chrome/browser/infobars/infobar_tab_helper.h" 15 #include "chrome/browser/infobars/infobar_tab_helper.h"
13 #include "chrome/browser/ui/tab_contents/tab_contents.h" 16 #include "chrome/browser/ui/tab_contents/tab_contents.h"
14 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/chrome_version_info.h"
15 #include "content/public/browser/browser_child_process_host_iterator.h" 19 #include "content/public/browser/browser_child_process_host_iterator.h"
16 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/child_process_data.h" 21 #include "content/public/browser/child_process_data.h"
18 #include "content/public/browser/notification_details.h" 22 #include "content/public/browser/notification_details.h"
19 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
20 #include "content/public/browser/plugin_service.h" 24 #include "content/public/browser/plugin_service.h"
25 #include "content/public/browser/render_process_host.h"
21 #include "content/public/common/result_codes.h" 26 #include "content/public/common/result_codes.h"
22 #include "grit/chromium_strings.h" 27 #include "grit/chromium_strings.h"
23 #include "grit/generated_resources.h" 28 #include "grit/generated_resources.h"
24 #include "grit/locale_settings.h" 29 #include "grit/locale_settings.h"
25 #include "grit/theme_resources.h" 30 #include "grit/theme_resources.h"
26 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/resource/resource_bundle.h" 32 #include "ui/base/resource/resource_bundle.h"
28 33
29 #if defined(OS_WIN) 34 #if defined(OS_WIN)
30 #include "chrome/browser/hang_monitor/hang_crash_dump_win.h" 35 #include "chrome/browser/hang_monitor/hang_crash_dump_win.h"
(...skipping 24 matching lines...) Expand all
55 base::KillProcess(data.handle, content::RESULT_CODE_HUNG, false); 60 base::KillProcess(data.handle, content::RESULT_CODE_HUNG, false);
56 #endif 61 #endif
57 break; 62 break;
58 } 63 }
59 ++iter; 64 ++iter;
60 } 65 }
61 // Ignore the case where we didn't find the plugin, it may have terminated 66 // Ignore the case where we didn't find the plugin, it may have terminated
62 // before this function could run. 67 // before this function could run.
63 } 68 }
64 69
70 #if defined(OS_WIN)
71 class OwnedHandleVector {
72 public:
73 OwnedHandleVector() {}
74 ~OwnedHandleVector();
75
76 std::vector<HANDLE>& data() { return data_; }
77
78 private:
79 std::vector<HANDLE> data_;
80
81 DISALLOW_COPY_AND_ASSIGN(OwnedHandleVector);
82 };
83
84 OwnedHandleVector::~OwnedHandleVector() {
brettw 2012/09/14 19:44:37 I'd put this inline above. It's very short and I w
yzshen1 2012/09/14 20:07:19 Done.
85 for (std::vector<HANDLE>::const_iterator iter = data_.begin();
86 iter != data_.end(); ++iter) {
87 ::CloseHandle(*iter);
88 }
89 }
90
91 void DumpRenderersOnIOThread(OwnedHandleVector* renderer_handles) {
92 for (std::vector<HANDLE>::const_iterator iter =
93 renderer_handles->data().begin();
94 iter != renderer_handles->data().end(); ++iter) {
95 CrashDumpProcessHandlingPepper(*iter);
96 }
97 }
98 #endif
99
65 } // namespace 100 } // namespace
66 101
67 class HungPluginTabHelper::InfoBarDelegate : public ConfirmInfoBarDelegate { 102 class HungPluginTabHelper::InfoBarDelegate : public ConfirmInfoBarDelegate {
68 public: 103 public:
69 InfoBarDelegate(HungPluginTabHelper* helper, 104 InfoBarDelegate(HungPluginTabHelper* helper,
70 InfoBarTabHelper* infobar_helper, 105 InfoBarTabHelper* infobar_helper,
71 int plugin_child_id, 106 int plugin_child_id,
72 const string16& plugin_name); 107 const string16& plugin_name);
73 virtual ~InfoBarDelegate(); 108 virtual ~InfoBarDelegate();
74 109
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 i->first)); 266 i->first));
232 267
233 // Next time we do this, delay it twice as long to avoid being annoying. 268 // Next time we do this, delay it twice as long to avoid being annoying.
234 state->next_reshow_delay *= 2; 269 state->next_reshow_delay *= 2;
235 return; 270 return;
236 } 271 }
237 } 272 }
238 } 273 }
239 274
240 void HungPluginTabHelper::KillPlugin(int child_id) { 275 void HungPluginTabHelper::KillPlugin(int child_id) {
276 #if defined(OS_WIN)
277 // Dump renderers that are sending or receiving pepper messages, in order to
278 // diagnose inter-process deadlocks.
279 // Only do that on the Canary channel, for 20% of pepper plugin hangs.
280 if (base::RandInt(0, 100) < 20) {
281 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
282 if (channel == chrome::VersionInfo::CHANNEL_CANARY) {
283 scoped_ptr<OwnedHandleVector> renderer_handles(new OwnedHandleVector);
284 HANDLE current_process = ::GetCurrentProcess();
285 content::RenderProcessHost::iterator renderer_iter =
286 content::RenderProcessHost::AllHostsIterator();
287 for (; !renderer_iter.IsAtEnd(); renderer_iter.Advance()) {
288 content::RenderProcessHost* host = renderer_iter.GetCurrentValue();
289 HANDLE handle = NULL;
290 ::DuplicateHandle(current_process, host->GetHandle(), current_process,
291 &handle, 0, FALSE, DUPLICATE_SAME_ACCESS);
292 renderer_handles->data().push_back(handle);
293 }
294 // If there are a lot of renderer processes, it is likely that we will
295 // generate too many crash dumps. They might not all be uploaded/recorded
296 // due to our crash dump uploading restrictions. So we just don't generate
297 // renderer crash dumps in that case.
298 if (renderer_handles->data().size() > 0 &&
299 renderer_handles->data().size() < 8) {
300 content::BrowserThread::PostTask(
301 content::BrowserThread::IO, FROM_HERE,
302 base::Bind(&DumpRenderersOnIOThread,
303 base::Owned(renderer_handles.release())));
304 }
305 }
306 }
307 #endif
308
241 PluginStateMap::iterator found = hung_plugins_.find(child_id); 309 PluginStateMap::iterator found = hung_plugins_.find(child_id);
242 if (found == hung_plugins_.end()) { 310 if (found == hung_plugins_.end()) {
243 NOTREACHED(); 311 NOTREACHED();
244 return; 312 return;
245 } 313 }
246 314
247 content::BrowserThread::PostTask(content::BrowserThread::IO, 315 content::BrowserThread::PostTask(content::BrowserThread::IO,
248 FROM_HERE, 316 FROM_HERE,
249 base::Bind(&KillPluginOnIOThread, child_id)); 317 base::Bind(&KillPluginOnIOThread, child_id));
250 CloseBar(found->second.get()); 318 CloseBar(found->second.get());
(...skipping 30 matching lines...) Expand all
281 state->info_bar = NULL; 349 state->info_bar = NULL;
282 } 350 }
283 } 351 }
284 352
285 InfoBarTabHelper* HungPluginTabHelper::GetInfoBarHelper() { 353 InfoBarTabHelper* HungPluginTabHelper::GetInfoBarHelper() {
286 TabContents* tab_contents = TabContents::FromWebContents(web_contents()); 354 TabContents* tab_contents = TabContents::FromWebContents(web_contents());
287 if (!tab_contents) 355 if (!tab_contents)
288 return NULL; 356 return NULL;
289 return tab_contents->infobar_tab_helper(); 357 return tab_contents->infobar_tab_helper();
290 } 358 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698