summaryrefslogtreecommitdiffstats
path: root/content/browser/plugin_service_impl.cc
diff options
context:
space:
mode:
authorcevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-29 06:28:48 +0000
committercevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-29 06:28:48 +0000
commit47214d887231579c4dc8f1911539a385b7aed0fe (patch)
treedf90714bb59ea64ef357f82e8d62997a535a3fe4 /content/browser/plugin_service_impl.cc
parentc224933cbc7e2c12a65481d951dff15b2bfccf31 (diff)
downloadchromium_src-47214d887231579c4dc8f1911539a385b7aed0fe.zip
chromium_src-47214d887231579c4dc8f1911539a385b7aed0fe.tar.gz
chromium_src-47214d887231579c4dc8f1911539a385b7aed0fe.tar.bz2
Apply a rate limit on a per-plug-in basis to plug-in crashes.
BUG=115758 Review URL: https://chromiumcodereview.appspot.com/9460038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/plugin_service_impl.cc')
-rw-r--r--content/browser/plugin_service_impl.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc
index f11603d6..7b2f2c6 100644
--- a/content/browser/plugin_service_impl.cc
+++ b/content/browser/plugin_service_impl.cc
@@ -626,6 +626,41 @@ void PluginServiceImpl::ForcePluginShutdown(const FilePath& plugin_path) {
plugin->ForceShutdown();
}
+static const unsigned int kMaxCrashesPerInterval = 3;
+static const unsigned int kCrashesInterval = 120;
+
+void PluginServiceImpl::RegisterPluginCrash(const FilePath& path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ std::map<FilePath, std::vector<base::Time> >::iterator i =
+ crash_times_.find(path);
+ if (i == crash_times_.end()) {
+ crash_times_[path] = std::vector<base::Time>();
+ i = crash_times_.find(path);
+ }
+ if (i->second.size() == kMaxCrashesPerInterval) {
+ i->second.erase(i->second.begin());
+ }
+ base::Time time = base::Time::Now();
+ i->second.push_back(time);
+}
+
+bool PluginServiceImpl::IsPluginUnstable(const FilePath& path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ std::map<FilePath, std::vector<base::Time> >::const_iterator i =
+ crash_times_.find(path);
+ if (i == crash_times_.end()) {
+ return false;
+ }
+ if (i->second.size() != kMaxCrashesPerInterval) {
+ return false;
+ }
+ base::TimeDelta delta = base::Time::Now() - i->second[0];
+ if (delta.InSeconds() <= kCrashesInterval) {
+ return true;
+ }
+ return false;
+}
+
void PluginServiceImpl::RefreshPlugins() {
plugin_list_->RefreshPlugins();
}