summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-01 20:50:16 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-01 20:50:16 +0000
commit7557d28044621216c85bb3f27a1de8c0bfd593b4 (patch)
tree0de2f5e02491338f53daa134ddf32c7bd81fa728 /content
parent7482542213d768c50ea506fdb56b3442cfa3c8aa (diff)
downloadchromium_src-7557d28044621216c85bb3f27a1de8c0bfd593b4.zip
chromium_src-7557d28044621216c85bb3f27a1de8c0bfd593b4.tar.gz
chromium_src-7557d28044621216c85bb3f27a1de8c0bfd593b4.tar.bz2
PluginLoaderPosix: Fix the case where the utility process crashes after all plugins have been loaded.
This was causing a crash on load on my system. BUG=111935 TEST=none R=rsesek Review URL: https://chromiumcodereview.appspot.com/9297049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/plugin_loader_posix.cc10
-rw-r--r--content/browser/plugin_loader_posix_unittest.cc45
2 files changed, 52 insertions, 3 deletions
diff --git a/content/browser/plugin_loader_posix.cc b/content/browser/plugin_loader_posix.cc
index 9701a72..5d506e6 100644
--- a/content/browser/plugin_loader_posix.cc
+++ b/content/browser/plugin_loader_posix.cc
@@ -44,8 +44,14 @@ bool PluginLoaderPosix::OnMessageReceived(const IPC::Message& message) {
}
void PluginLoaderPosix::OnProcessCrashed(int exit_code) {
- canonical_list_.erase(canonical_list_.begin(),
- canonical_list_.begin() + next_load_index_ + 1);
+ if (next_load_index_ == canonical_list_.size()) {
+ // How this case occurs is unknown. See crbug.com/111935.
+ canonical_list_.clear();
+ } else {
+ canonical_list_.erase(canonical_list_.begin(),
+ canonical_list_.begin() + next_load_index_ + 1);
+ }
+
next_load_index_ = 0;
LoadPluginsInternal();
diff --git a/content/browser/plugin_loader_posix_unittest.cc b/content/browser/plugin_loader_posix_unittest.cc
index 85e66ad..990832a 100644
--- a/content/browser/plugin_loader_posix_unittest.cc
+++ b/content/browser/plugin_loader_posix_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -170,6 +170,49 @@ TEST_F(PluginLoaderPosixTest, ThreeSuccessfulLoads) {
EXPECT_EQ(1, did_callback);
}
+TEST_F(PluginLoaderPosixTest, ThreeSuccessfulLoadsThenCrash) {
+ int did_callback = 0;
+ content::PluginService::GetPluginsCallback callback =
+ base::Bind(&VerifyCallback, base::Unretained(&did_callback));
+
+ plugin_loader()->LoadPlugins(message_loop()->message_loop_proxy(), callback);
+
+ EXPECT_CALL(*plugin_loader(), LoadPluginsInternal()).Times(2);
+ message_loop()->RunAllPending();
+
+ AddThreePlugins();
+
+ EXPECT_EQ(0u, plugin_loader()->next_load_index());
+
+ const std::vector<webkit::WebPluginInfo>& plugins(
+ plugin_loader()->loaded_plugins());
+
+ plugin_loader()->TestOnPluginLoaded(0, plugin1_);
+ EXPECT_EQ(1u, plugin_loader()->next_load_index());
+ EXPECT_EQ(1u, plugins.size());
+ EXPECT_EQ(plugin1_.name, plugins[0].name);
+
+ message_loop()->RunAllPending();
+ EXPECT_EQ(0, did_callback);
+
+ plugin_loader()->TestOnPluginLoaded(1, plugin2_);
+ EXPECT_EQ(2u, plugin_loader()->next_load_index());
+ EXPECT_EQ(2u, plugins.size());
+ EXPECT_EQ(plugin2_.name, plugins[1].name);
+
+ message_loop()->RunAllPending();
+ EXPECT_EQ(0, did_callback);
+
+ plugin_loader()->TestOnPluginLoaded(2, plugin3_);
+ EXPECT_EQ(3u, plugins.size());
+ EXPECT_EQ(plugin3_.name, plugins[2].name);
+
+ message_loop()->RunAllPending();
+ EXPECT_EQ(1, did_callback);
+
+ plugin_loader()->OnProcessCrashed(42);
+}
+
TEST_F(PluginLoaderPosixTest, TwoFailures) {
int did_callback = 0;
content::PluginService::GetPluginsCallback callback =