diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-05 21:44:31 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-05 21:44:31 +0000 |
commit | bbf4467a11440950f05432d3d68495c61e5623c6 (patch) | |
tree | 85a36cf931af16547a5022e2b9d6bfed76473726 | |
parent | aee4313f4c8d0fc0ffc64aa8175a89879c25528a (diff) | |
download | chromium_src-bbf4467a11440950f05432d3d68495c61e5623c6.zip chromium_src-bbf4467a11440950f05432d3d68495c61e5623c6.tar.gz chromium_src-bbf4467a11440950f05432d3d68495c61e5623c6.tar.bz2 |
Re-land more changes from r73427 where we set the name for each module in the constructor (checking for perf regressions).
Review URL: http://codereview.chromium.org/6312177
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73934 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/common/pepper_plugin_registry.cc | 36 | ||||
-rw-r--r-- | chrome/common/pepper_plugin_registry.h | 18 | ||||
-rw-r--r-- | chrome/renderer/pepper_plugin_delegate_impl.cc | 10 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_module.cc | 6 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_module.h | 9 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_unittest.cc | 2 |
6 files changed, 42 insertions, 39 deletions
diff --git a/chrome/common/pepper_plugin_registry.cc b/chrome/common/pepper_plugin_registry.cc index 54d54eee..8180626 100644 --- a/chrome/common/pepper_plugin_registry.cc +++ b/chrome/common/pepper_plugin_registry.cc @@ -15,19 +15,20 @@ #include "chrome/common/chrome_switches.h" #include "remoting/client/plugin/pepper_entrypoints.h" -const char* PepperPluginRegistry::kPDFPluginName = "Chrome PDF Viewer"; -const char* PepperPluginRegistry::kPDFPluginMimeType = "application/pdf"; -const char* PepperPluginRegistry::kPDFPluginExtension = "pdf"; -const char* PepperPluginRegistry::kPDFPluginDescription = - "Portable Document Format"; +namespace { + +const char* kPDFPluginMimeType = "application/pdf"; +const char* kPDFPluginExtension = "pdf"; +const char* kPDFPluginDescription = "Portable Document Format"; -const char* PepperPluginRegistry::kNaClPluginName = "Chrome NaCl"; -const char* PepperPluginRegistry::kNaClPluginMimeType = - "application/x-nacl"; -const char* PepperPluginRegistry::kNaClPluginExtension = "nexe"; -const char* PepperPluginRegistry::kNaClPluginDescription = - "Native Client Executable"; +const char* kNaClPluginName = "Chrome NaCl"; +const char* kNaClPluginMimeType = "application/x-nacl"; +const char* kNaClPluginExtension = "nexe"; +const char* kNaClPluginDescription = "Native Client Executable"; +} // namespace + +const char* PepperPluginRegistry::kPDFPluginName = "Chrome PDF Viewer"; PepperPluginInfo::PepperPluginInfo() : is_internal(false), @@ -198,7 +199,8 @@ void PepperPluginRegistry::GetInternalPluginInfo( #endif } -bool PepperPluginRegistry::RunOutOfProcessForPlugin( + +PepperPluginInfo* PepperPluginRegistry::GetInfoForPlugin( const FilePath& path) const { // TODO(brettw) don't recompute this every time. But since this Pepper // switch is only for development, it's OK for now. @@ -206,9 +208,9 @@ bool PepperPluginRegistry::RunOutOfProcessForPlugin( GetList(&plugins); for (size_t i = 0; i < plugins.size(); ++i) { if (path == plugins[i].path) - return plugins[i].is_out_of_process; + return new PepperPluginInfo(plugins[i]); } - return false; + return NULL; } webkit::ppapi::PluginModule* PepperPluginRegistry::GetModule( @@ -259,12 +261,11 @@ PepperPluginRegistry::PepperPluginRegistry() { ++it) { const FilePath& path = it->path; scoped_refptr<webkit::ppapi::PluginModule> module( - new webkit::ppapi::PluginModule(this)); + new webkit::ppapi::PluginModule(it->name, this)); if (!module->InitAsInternalPlugin(it->internal_entry_points)) { DLOG(ERROR) << "Failed to load pepper module: " << path.value(); continue; } - module->set_name(it->name); preloaded_modules_[path] = module; AddLiveModule(path, module); } @@ -280,7 +281,7 @@ PepperPluginRegistry::PepperPluginRegistry() { const FilePath& path = plugins[i].path; scoped_refptr<webkit::ppapi::PluginModule> module( - new webkit::ppapi::PluginModule(this)); + new webkit::ppapi::PluginModule(plugins[i].name, this)); // Must call this before bailing out later since the PluginModule's // destructor will call the corresponding Remove in the "continue" case. AddLiveModule(path, module); @@ -288,7 +289,6 @@ PepperPluginRegistry::PepperPluginRegistry() { DLOG(ERROR) << "Failed to load pepper module: " << path.value(); continue; } - module->set_name(plugins[i].name); preloaded_modules_[path] = module; } } diff --git a/chrome/common/pepper_plugin_registry.h b/chrome/common/pepper_plugin_registry.h index e16bcf4..5958d8f 100644 --- a/chrome/common/pepper_plugin_registry.h +++ b/chrome/common/pepper_plugin_registry.h @@ -50,14 +50,6 @@ class PepperPluginRegistry ~PepperPluginRegistry(); static const char* kPDFPluginName; - static const char* kPDFPluginMimeType; - static const char* kPDFPluginExtension; - static const char* kPDFPluginDescription; - - static const char* kNaClPluginName; - static const char* kNaClPluginMimeType; - static const char* kNaClPluginExtension; - static const char* kNaClPluginDescription; static PepperPluginRegistry* GetInstance(); @@ -71,9 +63,13 @@ class PepperPluginRegistry // access to the plugins before entering the sandbox. static void PreloadModules(); - // Returns true if the given plugin is a pepper plugin that should be run - // out of process. - bool RunOutOfProcessForPlugin(const FilePath& path) const; + // Retrieves the information associated with the given plugin path. The + // return value will be NULL if there is no such plugin. + // + // The caller owns the returned pointer. + // TODO(brettw) put the ownership semantics back to where they were in + // r73916, the current state is a hack to re-land that patch in pieces. + PepperPluginInfo* GetInfoForPlugin(const FilePath& path) const; // Returns an existing loaded module for the given path. It will search for // both preloaded in-process or currently active out-of-process plugins diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc index 8dfbac9..b7ee85b 100644 --- a/chrome/renderer/pepper_plugin_delegate_impl.cc +++ b/chrome/renderer/pepper_plugin_delegate_impl.cc @@ -395,8 +395,11 @@ PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) { return module; // In-process plugins will have always been created up-front to avoid the - // sandbox restrictions. - if (!PepperPluginRegistry::GetInstance()->RunOutOfProcessForPlugin(path)) + // sandbox restrictions. So getting here implies that it either doesn't exist + // or should be run out of process. + scoped_ptr<PepperPluginInfo> info( + PepperPluginRegistry::GetInstance()->GetInfoForPlugin(path)); + if (!info.get() || !info->is_out_of_process) return module; // Return the NULL module. // Out of process: have the browser start the plugin process for us. @@ -412,7 +415,8 @@ PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) { // Create a new HostDispatcher for the proxying, and hook it to a new // PluginModule. Note that AddLiveModule must be called before any early // returns since the module's destructor will remove itself. - module = new webkit::ppapi::PluginModule(PepperPluginRegistry::GetInstance()); + module = new webkit::ppapi::PluginModule(info->name, + PepperPluginRegistry::GetInstance()); PepperPluginRegistry::GetInstance()->AddLiveModule(path, module); scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper); if (!dispatcher->Init( diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc index 332770ff..a8d804a 100644 --- a/webkit/plugins/ppapi/plugin_module.cc +++ b/webkit/plugins/ppapi/plugin_module.cc @@ -360,10 +360,12 @@ PluginModule::EntryPoints::EntryPoints() // PluginModule ---------------------------------------------------------------- -PluginModule::PluginModule(PluginDelegate::ModuleLifetime* lifetime_delegate) +PluginModule::PluginModule(const std::string& name, + PluginDelegate::ModuleLifetime* lifetime_delegate) : lifetime_delegate_(lifetime_delegate), callback_tracker_(new CallbackTracker), - library_(NULL) { + library_(NULL), + name_(name) { pp_module_ = ResourceTracker::Get()->AddModule(this); GetMainThreadMessageLoop(); // Initialize the main thread message loop. GetLivePluginSet()->insert(this); diff --git a/webkit/plugins/ppapi/plugin_module.h b/webkit/plugins/ppapi/plugin_module.h index cfdfb6af..4f3e9c3 100644 --- a/webkit/plugins/ppapi/plugin_module.h +++ b/webkit/plugins/ppapi/plugin_module.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -7,6 +7,7 @@ #include <map> #include <set> +#include <string> #include "base/basictypes.h" #include "base/native_library.h" @@ -71,7 +72,8 @@ class PluginModule : public base::RefCounted<PluginModule>, // The module lifetime delegate is a non-owning pointer that must outlive // all plugin modules. In practice it will be a global singleton that // tracks which modules are alive. - PluginModule(PluginDelegate::ModuleLifetime* lifetime_delegate); + PluginModule(const std::string& name, + PluginDelegate::ModuleLifetime* lifetime_delegate); ~PluginModule(); @@ -98,7 +100,6 @@ class PluginModule : public base::RefCounted<PluginModule>, // proxy needs this information to set itself up properly). PP_Module pp_module() const { return pp_module_; } - void set_name(const std::string& name) { name_ = name; } const std::string& name() const { return name_; } PluginInstance* CreateInstance(PluginDelegate* delegate); @@ -152,7 +153,7 @@ class PluginModule : public base::RefCounted<PluginModule>, EntryPoints entry_points_; // The name of the module. - std::string name_; + const std::string name_; // Non-owning pointers to all instances associated with this module. When // there are no more instances, this object should be deleted. diff --git a/webkit/plugins/ppapi/ppapi_unittest.cc b/webkit/plugins/ppapi/ppapi_unittest.cc index 7ad58c3..a9a3637 100644 --- a/webkit/plugins/ppapi/ppapi_unittest.cc +++ b/webkit/plugins/ppapi/ppapi_unittest.cc @@ -87,7 +87,7 @@ void PpapiUnittest::SetUp() { delegate_.reset(new MockPluginDelegate); // Initialize the mock module. - module_ = new PluginModule(this); + module_ = new PluginModule("Mock plugin", this); PluginModule::EntryPoints entry_points; entry_points.get_interface = &MockGetInterface; entry_points.initialize_module = &MockInitializeModule; |