summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-06 23:46:36 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-06 23:46:36 +0000
commit9a811701c538c6439d9a800fae303d46300f7db5 (patch)
tree93c484b929a10346d358d2fd4292fbcc4fcb5d5c /content
parent1f7c6197fb4346f6365dd0508e1a088ce4fa5b3b (diff)
downloadchromium_src-9a811701c538c6439d9a800fae303d46300f7db5.zip
chromium_src-9a811701c538c6439d9a800fae303d46300f7db5.tar.gz
chromium_src-9a811701c538c6439d9a800fae303d46300f7db5.tar.bz2
Merge 120098 - 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 TBR=jhawkins@chromium.org Review URL: https://chromiumcodereview.appspot.com/9349002 git-svn-id: svn://svn.chromium.org/chrome/branches/1025/src@120644 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 =