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

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

Issue 10014013: Add a hang monitor for Pepper plugins (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/hung_plugin_tab_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_HUNG_PLUGIN_TAB_HELPER_H_
6 #define CHROME_BROWSER_UI_HUNG_PLUGIN_TAB_HELPER_H_
7
8 #include <map>
9
10 #include "base/file_path.h"
11 #include "base/memory/linked_ptr.h"
12 #include "base/string16.h"
13 #include "base/time.h"
14 #include "base/timer.h"
15
16 class FilePath;
17 class InfoBarTabHelper;
18
19 namespace content {
20 class WebContents;
21 }
22
23 // Manages per-tab state with regard to hung plugins. This only handles
24 // Pepper plugins which we know are windowless. Hung NPAPI plugins (which
25 // may have native windows) can not be handled with infobars and have a
26 // separate OS-specific hang monitoring.
27 //
28 // Our job is:
29 // - Pop up an infobar when a plugin is hung.
30 // - Terminate the plugin process if the user so chooses.
31 // - Periodically re-show the hung plugin infobar if the user closes it without
32 // terminating the plugin.
33 // - Hide the infobar if the plugin starts responding again.
34 // - Keep track of all of this for any number of plugins.
35 class HungPluginTabHelper {
36 public:
37 explicit HungPluginTabHelper(content::WebContents* contents);
38 ~HungPluginTabHelper();
39
40 void PluginCrashed(const FilePath& plugin_path);
41
42 void PluginHungStatusChanged(int plugin_child_id,
43 const FilePath& plugin_path,
44 bool is_hung);
45
46 private:
47 class InfoBarDelegate;
48 friend class InfoBarDelegate;
49
50 // Per-plugin state (since there could be more than one plugin hung). The
51 // integer key is the child process ID of the plugin process. This maintains
52 // the state for all plugins on this page that are currently hung, whether or
53 // not we're currently showing the infobar.
54 struct PluginState {
55 // Initializes the plugin state to be a hung plugin.
56 PluginState(const FilePath& p, const string16& n);
57 ~PluginState();
58
59 FilePath path;
60 string16 name;
61
62 // Possibly-null if we're not showing an infobar right now.
63 InfoBarDelegate* info_bar;
64
65 // Time to delay before re-showing the infobar for a hung plugin. This is
66 // increased each time the user cancels it.
67 base::TimeDelta next_reshow_delay;
68
69 // Handles calling the helper when the infobar should be re-shown.
70 base::Timer timer;
71
72 private:
73 // Since the scope of the timer manages our callback, this struct should
74 // not be copied.
75 DISALLOW_COPY_AND_ASSIGN(PluginState);
76 };
77 typedef std::map<int, linked_ptr<PluginState> > PluginStateMap;
78
79 // Called by an infobar when the user selects to kill the plugin.
80 void KillPlugin(int child_id);
81
82 // Called by an infobar when the user presses the close button to dismiss the
83 // bar without doing anything.
84 void BarClosed(int child_id);
85
86 // Called on a timer for a hung plugin to re-show the bar.
87 void OnReshowTimer(int child_id);
88
89 // Shows the bar for the plugin identified by the given state, updating the
90 // state accordingly. The plugin must not have an infobar already.
91 void ShowBar(int child_id, PluginState* state);
92
93 // Closes the infobar associated with the given state. Note that this can
94 // be called even if the bar is not opened, in which case it will do nothing.
95 void CloseBar(PluginState* state);
96
97 // Possibly returns null.
98 InfoBarTabHelper* GetInfoBarHelper();
99
100 content::WebContents* contents_;
101
102 // All currently hung plugins.
103 PluginStateMap hung_plugins_;
104
105 DISALLOW_COPY_AND_ASSIGN(HungPluginTabHelper);
106 };
107
108 #endif // CHROME_BROWSER_UI_HUNG_PLUGIN_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/hung_plugin_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698