Changeset 31465 in webkit
- Timestamp:
- Mar 31, 2008 9:55:48 AM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r31464 r31465 1 2008-03-29 Adam Roben <aroben@apple.com> 2 3 Separate filesystem crawling from PluginPackage instantiation 4 5 Part of Bug 18208: Acid3 test 65 takes >33ms due to plugin refreshing 6 on Windows 7 <http://bugs.webkit.org/show_bug.cgi?id=18208> 8 9 refresh() is now the only place where PluginPackages are instantiated. 10 refresh() now asks for a set of plugins that no longer exist on disk, 11 and the set of all plugin files in our plugin directories. Using these 12 two sets we can update our instantiated plugins without copying any 13 HashSets. The code in refresh() and in the platform-specific methods 14 to crawl the filesystem is now quite a bit simpler. 15 16 PluginDatabase now stores both a PluginSet and a HashMap that maps 17 plugin paths to PluginPackages. This allows us to quickly determine 18 whether we already have a PluginPackage instantiated for a particular 19 path. The new add/remove methods handle the modification of these two 20 collections. 21 22 A nice side effect of all this is that refresh() no longer copies any 23 HashSets. 24 25 Reviewed by Mitz Pettel. 26 27 * plugins/PluginDatabase.cpp: 28 (WebCore::PluginDatabase::refresh): Unload any plugins that have been 29 deleted from disk, and add any plugins that either weren't installed 30 last time, or have changed since last time. 31 (WebCore::PluginDatabase::getDeletedPlugins): Added. 32 (WebCore::PluginDatabase::add): Added. Returns whether or not the 33 PluginPackage was actually added to the database (duplicates won't be 34 added). 35 (WebCore::PluginDatabase::remove): Added. 36 * plugins/PluginDatabase.h: 37 * plugins/PluginPackage.h: 38 (WebCore::PluginPackage::path): Added. 39 (WebCore::PluginPackage::lastModified): Added. 40 * plugins/gtk/PluginDatabaseGtk.cpp: 41 (WebCore::PluginDatabase::getPluginPathsInDirectories): Renamed from 42 getPluginsInDirectories. Now fills a HashSet of Strings instead of 43 instantiated PluginPackages. 44 * plugins/win/PluginDatabaseWin.cpp: 45 (WebCore::addPluginPathsFromRegistry): Ditto. 46 (WebCore::PluginDatabase::getPluginPathsInDirectories): Ditto. 47 1 48 2008-03-29 Adam Roben <aroben@apple.com> 2 49 -
trunk/WebCore/plugins/PluginDatabase.cpp
r31464 r31465 66 66 bool PluginDatabase::refresh() 67 67 { 68 PluginSet newPlugins;69 70 68 bool pluginSetChanged = false; 71 72 // Create a new set of plugins73 getPluginsInDirectories(newPlugins);74 69 75 70 if (!m_plugins.isEmpty()) { 76 71 m_registeredMIMETypes.clear(); 77 72 78 PluginSet pluginsToUnload = m_plugins; 79 80 PluginSet::const_iterator end = newPlugins.end(); 81 for (PluginSet::const_iterator it = newPlugins.begin(); it != end; ++it) 82 pluginsToUnload.remove(*it); 83 84 end = m_plugins.end(); 85 for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) 86 newPlugins.remove(*it); 73 PluginSet pluginsToUnload; 74 getDeletedPlugins(pluginsToUnload); 87 75 88 76 // Unload plugins 89 end = pluginsToUnload.end();77 PluginSet::const_iterator end = pluginsToUnload.end(); 90 78 for (PluginSet::const_iterator it = pluginsToUnload.begin(); it != end; ++it) 91 m_plugins.remove(*it); 92 93 // Add new plugins 94 end = newPlugins.end(); 95 for (PluginSet::const_iterator it = newPlugins.begin(); it != end; ++it) 96 m_plugins.add(*it); 97 98 pluginSetChanged = !pluginsToUnload.isEmpty() || !newPlugins.isEmpty(); 99 } else { 100 m_plugins = newPlugins; 101 PluginSet::const_iterator end = newPlugins.end(); 102 for (PluginSet::const_iterator it = newPlugins.begin(); it != end; ++it) 103 m_plugins.add(*it); 104 105 pluginSetChanged = !newPlugins.isEmpty(); 79 remove(it->get()); 80 81 pluginSetChanged = !pluginsToUnload.isEmpty(); 82 } 83 84 HashSet<String> paths; 85 getPluginPathsInDirectories(paths); 86 87 HashSet<String>::const_iterator pathsEnd = paths.end(); 88 for (HashSet<String>::const_iterator it = paths.begin(); it != pathsEnd; ++it) { 89 time_t lastModified; 90 if (!getFileModificationTime(*it, lastModified)) 91 continue; 92 93 if (RefPtr<PluginPackage> oldPackage = m_pluginsByPath.get(*it)) { 94 if (oldPackage->lastModified() == lastModified) 95 continue; 96 remove(oldPackage.get()); 97 } 98 99 if (add(PluginPackage::createPackage(*it, lastModified))) 100 pluginSetChanged = true; 106 101 } 107 102 … … 223 218 } 224 219 225 } 220 void PluginDatabase::getDeletedPlugins(PluginSet& plugins) const 221 { 222 PluginSet::const_iterator end = m_plugins.end(); 223 for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) { 224 if (!fileExists((*it)->path())) 225 plugins.add(*it); 226 } 227 } 228 229 bool PluginDatabase::add(PassRefPtr<PluginPackage> prpPackage) 230 { 231 RefPtr<PluginPackage> package = prpPackage; 232 233 if (!m_plugins.add(package).second) 234 return false; 235 236 m_pluginsByPath.add(package->path(), package); 237 return true; 238 } 239 240 void PluginDatabase::remove(PluginPackage* package) 241 { 242 m_plugins.remove(package); 243 m_pluginsByPath.remove(package->path()); 244 } 245 246 } -
trunk/WebCore/plugins/PluginDatabase.h
r31464 r31465 60 60 private: 61 61 void setPluginDirectories(const Vector<String>& directories) { m_pluginDirectories = directories; } 62 void getPluginsInDirectories(PluginSet&) const; 62 63 void getPluginPathsInDirectories(HashSet<String>&) const; 64 void getDeletedPlugins(PluginSet&) const; 65 66 // Returns whether the plugin was actually added or not (it won't be added if it's a duplicate of an existing plugin). 67 bool add(PassRefPtr<PluginPackage>); 68 void remove(PluginPackage*); 63 69 64 70 PluginPackage* pluginForMIMEType(const String& mimeType); … … 70 76 HashSet<String> m_registeredMIMETypes; 71 77 PluginSet m_plugins; 78 HashMap<String, RefPtr<PluginPackage> > m_pluginsByPath; 72 79 }; 73 80 -
trunk/WebCore/plugins/PluginPackage.h
r31463 r31465 48 48 const String& name() const { return m_name; } 49 49 const String& description() const { return m_description; } 50 const String& path() const { return m_path; } 50 51 const String& fileName() const { return m_fileName; } 51 52 const String& parentDirectory() const { return m_parentDirectory; } 53 time_t lastModified() const { return m_lastModified; } 52 54 53 55 const MIMEToDescriptionsMap& mimeToDescriptions() const { return m_mimeToDescriptions; } -
trunk/WebCore/plugins/gtk/PluginDatabaseGtk.cpp
r31464 r31465 33 33 namespace WebCore { 34 34 35 void PluginDatabase::getPlugin sInDirectories(PluginSet& plugins) const35 void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const 36 36 { 37 37 // FIXME: This should be a case insensitive set. … … 49 49 50 50 gchar* filename = g_build_filename((it->utf8()).data(), name, 0); 51 RefPtr<PluginPackage> pluginPackage = PluginPackage::createPackage(filename, time(0)); 52 if (pluginPackage) 53 plugins.add(pluginPackage); 51 paths.add(filename); 54 52 g_free(filename); 55 53 } -
trunk/WebCore/plugins/win/PluginDatabaseWin.cpp
r31464 r31465 36 36 namespace WebCore { 37 37 38 static inline void addPlugin sFromRegistry(HKEY rootKey, PluginSet& plugins)38 static inline void addPluginPathsFromRegistry(HKEY rootKey, HashSet<String>& paths) 39 39 { 40 40 HKEY key; … … 63 63 continue; 64 64 65 String path(pathStr, pathStrSize / sizeof(WCHAR) - 1); 66 67 time_t modifiedTime; 68 if (!getFileModificationTime(path, modifiedTime)) 69 continue; 70 71 RefPtr<PluginPackage> package = PluginPackage::createPackage(path, modifiedTime); 72 73 if (package) 74 plugins.add(package); 65 paths.add(String(pathStr, pathStrSize / sizeof(WCHAR) - 1)); 75 66 } 76 67 … … 78 69 } 79 70 80 void PluginDatabase::getPlugin sInDirectories(PluginSet& plugins) const71 void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const 81 72 { 82 73 // FIXME: This should be a case insensitive set. … … 86 77 WIN32_FIND_DATAW findFileData; 87 78 88 RefPtr<PluginPackage> oldWMPPlugin;89 RefPtr<PluginPackage> newWMPPlugin;79 String oldWMPPluginPath; 80 String newWMPPluginPath; 90 81 91 82 Vector<String>::const_iterator end = m_pluginDirectories.end(); … … 111 102 continue; 112 103 113 time_t modifiedTime; 114 if (!getFileModificationTime(fullPath, modifiedTime)) 115 continue; 116 117 RefPtr<PluginPackage> pluginPackage = PluginPackage::createPackage(fullPath, modifiedTime); 118 119 if (pluginPackage) { 120 plugins.add(pluginPackage); 121 122 if (equalIgnoringCase(filename, "npdsplay.dll")) 123 oldWMPPlugin = pluginPackage; 124 else if (equalIgnoringCase(filename, "np-mswmp.dll")) 125 newWMPPlugin = pluginPackage; 126 } 104 paths.add(fullPath); 105 106 if (equalIgnoringCase(filename, "npdsplay.dll")) 107 oldWMPPluginPath = fullPath; 108 else if (equalIgnoringCase(filename, "np-mswmp.dll")) 109 newWMPPluginPath = fullPath; 127 110 128 111 } while (FindNextFileW(hFind, &findFileData) != 0); … … 131 114 } 132 115 133 addPlugin sFromRegistry(HKEY_LOCAL_MACHINE, plugins);134 addPlugin sFromRegistry(HKEY_CURRENT_USER, plugins);116 addPluginPathsFromRegistry(HKEY_LOCAL_MACHINE, paths); 117 addPluginPathsFromRegistry(HKEY_CURRENT_USER, paths); 135 118 136 119 // If both the old and new WMP plugin are present in the plugins set, 137 120 // we remove the old one so we don't end up choosing the old one. 138 if ( oldWMPPlugin && newWMPPlugin)139 p lugins.remove(oldWMPPlugin);121 if (!oldWMPPluginPath.isEmpty() && !newWMPPluginPath.isEmpty()) 122 paths.remove(oldWMPPluginPath); 140 123 } 141 124
Note: See TracChangeset
for help on using the changeset viewer.