Fix a bug that would cause the plugin_loader to stall.
If there's an error launching the plugin_loader's process_host, then the
plugin_loader will stall forever. This happened because the return value of
process_host_->Send() was being ignored, and because PluginLoaderPosix was not
overriding OnProcessLaunchFailed().
This CL also includes a minor refactor:
- Removed the LOCAL_HISTOGRAM_TIMES "PluginLoaderPosix.LoadDone", because it
was measuring the time between MaybeRunPendingCallbacks(), rather than the
amount of time it takes to load the plugins. I'm guessing that this metric is
out of date, and was never removed.
- Separated MaybeRunPendingCallbacks() into two methods,
IsFinishedLoadingPlugins() and FinishedLoadingPlugins().
- Removed the method MaybeAddInternalPlugin(), as its name was confusing, and
added FindInternalPlugin() in its place. This also simplified the logic
slightly.
BUG=429388
Review URL: https://codereview.chromium.org/718523002
Cr-Commit-Position: refs/heads/master@{#303581}
diff --git a/content/browser/plugin_loader_posix.h b/content/browser/plugin_loader_posix.h
index 5b1580c..3a50bcd 100644
--- a/content/browser/plugin_loader_posix.h
+++ b/content/browser/plugin_loader_posix.h
@@ -56,6 +56,7 @@
// UtilityProcessHostClient:
void OnProcessCrashed(int exit_code) override;
+ void OnProcessLaunchFailed() override;
bool OnMessageReceived(const IPC::Message& message) override;
// IPC::Sender:
@@ -80,15 +81,27 @@
void OnPluginLoaded(uint32 index, const WebPluginInfo& plugin);
void OnPluginLoadFailed(uint32 index, const base::FilePath& plugin_path);
- // Checks if the plugin path is an internal plugin, and, if it is, adds it to
- // |loaded_plugins_|.
- bool MaybeAddInternalPlugin(const base::FilePath& plugin_path);
+ // Returns an iterator to the plugin in |internal_plugins_| whose path
+ // matches |plugin_path|.
+ std::vector<WebPluginInfo>::iterator FindInternalPlugin(
+ const base::FilePath& plugin_path);
// Runs all the registered callbacks on each's target loop if the condition
// for ending the load process is done (i.e. the |next_load_index_| is outside
// the range of the |canonical_list_|).
bool MaybeRunPendingCallbacks();
+ // Returns true if there are no plugins left to load.
+ bool IsFinishedLoadingPlugins();
+
+ // This method should be called when the plugins are finished loading.
+ // It updates the PluginList's list of plugins, and runs the queued callbacks.
+ void FinishedLoadingPlugins();
+
+ // Launches the utility process that loads the plugins.
+ // Virtual for testing.
+ virtual bool LaunchUtilityProcess();
+
// The process host for which this is a client.
base::WeakPtr<UtilityProcessHost> process_host_;
@@ -110,8 +123,8 @@
// plugin loading process has been completed.
std::vector<PluginService::GetPluginsCallback> callbacks_;
- // The time at which plugin loading started.
- base::TimeTicks load_start_time_;
+ // True if there is (or is about to be) a utility process that loads plugins.
+ bool loading_plugins_;
friend class MockPluginLoaderPosix;
DISALLOW_COPY_AND_ASSIGN(PluginLoaderPosix);