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

Unified Diff: content/browser/plugin_service.cc

Issue 8071013: Finish moving plugin probing out of process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/plugin_service.cc
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
index f6d61d6e189a7e71ec26fac3760bfdf100dba488..74a5209bd7a8ce14cb828715cbb12278c7875a87 100644
--- a/content/browser/plugin_service.cc
+++ b/content/browser/plugin_service.cc
@@ -67,12 +67,19 @@ static void GetPluginsForGroupsCallback(
void WillLoadPluginsCallback() {
// TODO(rsesek): Change these to CHECKs.
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX))
- LOG_IF(ERROR, !BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
#else
- LOG(ERROR) << "Plugin loading should happen out-of-process.";
+ CHECK(false) << "Plugin loading should happen out-of-process.";
#endif
}
+struct ForwardOpenChannelParams {
+ int render_process_id;
+ int render_view_id;
+ PluginProcessHost::Client* client;
+ const content::ResourceContext* resource_context;
+};
+
#if defined(OS_POSIX)
// Utility child process client that manages the IPC for loading plugins out of
// process.
@@ -324,8 +331,7 @@ PluginProcessHost* PluginService::FindOrStartNpapiPluginProcess(
return plugin_host;
webkit::WebPluginInfo info;
- if (!webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath(
- plugin_path, &info)) {
+ if (!GetPluginInfoByPath(plugin_path, &info)) {
return NULL;
}
@@ -387,14 +393,17 @@ void PluginService::OpenChannelToNpapiPlugin(
PluginProcessHost::Client* client) {
DCHECK(!ContainsKey(pending_plugin_clients_, client));
pending_plugin_clients_.insert(client);
- // The PluginList::GetPluginInfo may need to load the plugins. Don't do it on
- // the IO thread.
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(
- this, &PluginService::GetAllowedPluginForOpenChannelToPlugin,
- render_process_id, render_view_id, url, page_url, mime_type,
- client, &client->GetResourceContext()));
+
+ // Make sure plugins are loaded if necessary.
+ ForwardOpenChannelParams params = {
+ render_process_id,
+ render_view_id,
+ client,
+ &client->GetResourceContext()
+ };
+ GetPlugins(
+ base::Bind(&PluginService::ForwardGetAllowedPluginForOpenChannelToPlugin,
+ base::Unretained(this), params, url, page_url, mime_type));
}
void PluginService::OpenChannelToPpapiPlugin(
@@ -425,6 +434,17 @@ void PluginService::CancelOpenChannelToNpapiPlugin(
pending_plugin_clients_.erase(client);
}
+void PluginService::ForwardGetAllowedPluginForOpenChannelToPlugin(
+ const ForwardOpenChannelParams& params,
+ const GURL& url,
+ const GURL& page_url,
+ const std::string& mime_type,
+ const std::vector<webkit::WebPluginInfo>&) {
+ GetAllowedPluginForOpenChannelToPlugin(params.render_process_id,
+ params.render_view_id, url, page_url, mime_type, params.client,
+ params.resource_context);
+}
+
void PluginService::GetAllowedPluginForOpenChannelToPlugin(
int render_process_id,
int render_view_id,
@@ -433,8 +453,6 @@ void PluginService::GetAllowedPluginForOpenChannelToPlugin(
const std::string& mime_type,
PluginProcessHost::Client* client,
const content::ResourceContext* resource_context) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- DCHECK(resource_context);
webkit::WebPluginInfo info;
bool allow_wildcard = true;
bool found = GetPluginInfo(
@@ -446,11 +464,9 @@ void PluginService::GetAllowedPluginForOpenChannelToPlugin(
plugin_path = info.path;
// Now we jump back to the IO thread to finish opening the channel.
- BrowserThread::PostTask(
- BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(
- this, &PluginService::FinishOpenChannelToPlugin,
- plugin_path, client));
+ BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+ base::Bind(&PluginService::FinishOpenChannelToPlugin,
+ base::Unretained(this), plugin_path, client));
}
void PluginService::FinishOpenChannelToPlugin(
@@ -472,6 +488,18 @@ void PluginService::FinishOpenChannelToPlugin(
}
}
+bool PluginService::GetPluginInfoArray(
+ const GURL& url,
+ const std::string& mime_type,
+ bool allow_wildcard,
+ std::vector<webkit::WebPluginInfo>* plugins,
+ std::vector<std::string>* actual_mime_types) {
+ bool use_stale = false;
+ webkit::npapi::PluginList::Singleton()->GetPluginInfoArray(
+ url, mime_type, allow_wildcard, &use_stale, plugins, actual_mime_types);
+ return use_stale;
+}
+
bool PluginService::GetPluginInfo(int render_process_id,
int render_view_id,
const content::ResourceContext& context,
@@ -479,18 +507,15 @@ bool PluginService::GetPluginInfo(int render_process_id,
const GURL& page_url,
const std::string& mime_type,
bool allow_wildcard,
- bool* use_stale,
+ bool* is_stale,
webkit::WebPluginInfo* info,
std::string* actual_mime_type) {
- webkit::npapi::PluginList* plugin_list =
- webkit::npapi::PluginList::Singleton();
- // GetPluginInfoArray may need to load the plugins, so we need to be
- // on the FILE thread.
- DCHECK(use_stale || BrowserThread::CurrentlyOn(BrowserThread::FILE));
std::vector<webkit::WebPluginInfo> plugins;
std::vector<std::string> mime_types;
- plugin_list->GetPluginInfoArray(
- url, mime_type, allow_wildcard, use_stale, &plugins, &mime_types);
+ bool stale = GetPluginInfoArray(
+ url, mime_type, allow_wildcard, &plugins, &mime_types);
+ if (is_stale)
+ *is_stale = stale;
if (plugins.size() > 1 &&
plugins.back().path ==
FilePath(webkit::npapi::kDefaultPluginLibraryName)) {
@@ -515,6 +540,24 @@ bool PluginService::GetPluginInfo(int render_process_id,
return false;
}
+bool PluginService::GetPluginInfoByPath(const FilePath& plugin_path,
+ webkit::WebPluginInfo* info) {
+ std::vector<webkit::WebPluginInfo> plugins;
+ webkit::npapi::PluginList::Singleton()->GetPluginsIfNoRefreshNeeded(
+ &plugins);
+
+ for (std::vector<webkit::WebPluginInfo>::iterator it = plugins.begin();
+ it != plugins.end();
+ ++it) {
+ if (it->path == plugin_path) {
+ *info = *it;
+ return true;
+ }
+ }
+
+ return false;
+}
+
void PluginService::RefreshPluginList() {
webkit::npapi::PluginList::Singleton()->RefreshPlugins();
}
@@ -622,8 +665,7 @@ PepperPluginInfo* PluginService::GetRegisteredPpapiPluginInfo(
// construct it and add it to the list. This same deal needs to be done
// in the renderer side in PepperPluginRegistry.
webkit::WebPluginInfo webplugin_info;
- if (!webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath(
- plugin_path, &webplugin_info))
+ if (!GetPluginInfoByPath(plugin_path, &webplugin_info))
return NULL;
PepperPluginInfo new_pepper_info;
if (!MakePepperPluginInfo(webplugin_info, &new_pepper_info))

Powered by Google App Engine
This is Rietveld 408576698