Changeset 64663 in webkit
- Timestamp:
- Aug 4, 2010 12:09:39 PM (14 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 1 added
- 5 edited
- 3 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r64662 r64663 1 2010-08-04 Adam Roben <aroben@apple.com> 2 3 Move bundle-loading code from NetscapePluginModule to a new Module 4 class 5 6 This allows more NetscapePluginModule code to be cross-platform. 7 8 Fixes <http://webkit.org/b/43497> NetscapePluginModule::try/unload 9 should be cross-platform 10 11 Reviewed by Anders Carlsson. 12 13 * Platform/Module.cpp: Added. 14 (WebKit::Module::Module): Store our path. 15 (WebKit::Module::~Module): Unload our native module. 16 17 * Platform/Module.h: Added. 18 (WebKit::Module::leakBundle): Does what it says. 19 (WebKit::Module::functionPointer): Returns a pointer to the named 20 function, with the right type. 21 22 * Platform/mac/ModuleMac.mm: Added. 23 (WebKit::Module::load): Code was moved here from 24 NetscapePluginModule::tryLoad. 25 (WebKit::Module::unload): Just clears our bundle. 26 (WebKit::Module::platformFunctionPointer): Code was moved here from 27 NetscapePluginModuleMac.cpp. 28 29 * Platform/qt/ModuleQt.cpp: Added. 30 (WebKit::Module::load): 31 (WebKit::Module::unload): 32 (WebKit::Module::platformFunctionPointer): 33 * Platform/win/ModuleWin.cpp: Added. 34 (WebKit::Module::load): 35 (WebKit::Module::unload): 36 (WebKit::Module::platformFunctionPointer): 37 Just stubbed out these functions. 38 39 * WebKit2.xcodeproj/project.pbxproj: Added Module. 40 41 * WebProcess/Plugins/Netscape/NetscapePluginModule.cpp: 42 (WebKit::NetscapePluginModule::tryLoad): 43 (WebKit::NetscapePluginModule::unload): 44 Moved here from NetscapePluginModuleMac.cpp. Now uses the 45 cross-platform m_module member. 46 47 * WebProcess/Plugins/Netscape/NetscapePluginModule.h: Replaced 48 m_bundle with m_module. 49 50 * WebProcess/Plugins/Netscape/mac/NetscapePluginModuleMac.cpp: Removed. 51 52 * win/WebKit2.vcproj: Added Module. 53 1 54 2010-08-04 Brady Eidson <beidson@apple.com> 2 55 -
trunk/WebKit2/Platform/Module.h
r64662 r64663 24 24 */ 25 25 26 #ifndef NetscapePluginModule_h27 #define NetscapePluginModule_h26 #ifndef Module_h 27 #define Module_h 28 28 29 #include <WebCore/npfunctions.h>30 29 #include <WebCore/PlatformString.h> 31 #include <wtf/ RefCounted.h>30 #include <wtf/Noncopyable.h> 32 31 33 32 #if PLATFORM(MAC) … … 37 36 namespace WebKit { 38 37 39 class NetscapePluginModule : public RefCounted<NetscapePluginModule>{38 class Module : public Noncopyable { 40 39 public: 41 static PassRefPtr<NetscapePluginModule> getOrCreate(const WebCore::String& pluginPath);42 ~ NetscapePluginModule();40 Module(const WebCore::String& path); 41 ~Module(); 43 42 44 const NPPluginFuncs& pluginFuncs() const { return m_pluginFuncs; } 43 bool load(); 44 // Note: On Mac this leaks the CFBundle to avoid crashes when a bundle is unloaded and there are 45 // live Objective-C objects whose methods come from that bundle. 46 void unload(); 45 47 46 void pluginCreated(); 47 void pluginDestroyed(); 48 template<typename FunctionType> FunctionType functionPointer(const char* functionName) const; 48 49 49 50 private: 50 explicit NetscapePluginModule(const WebCore::String& pluginPath);51 void* platformFunctionPointer(const char* functionName) const; 51 52 52 bool tryLoad(); 53 bool load(); 54 void unload(); 55 56 void shutdown(); 57 58 WebCore::String m_pluginPath; 59 bool m_isInitialized; 60 unsigned m_pluginCount; 61 62 NPP_ShutdownProcPtr m_shutdownProcPtr; 63 NPPluginFuncs m_pluginFuncs; 64 53 WebCore::String m_path; 65 54 #if PLATFORM(MAC) 66 55 RetainPtr<CFBundleRef> m_bundle; 67 56 #endif 68 57 }; 69 70 } // namespace WebKit71 58 72 #endif // NetscapePluginModule_h 59 template<typename FunctionType> FunctionType Module::functionPointer(const char* functionName) const 60 { 61 return reinterpret_cast<FunctionType>(platformFunctionPointer(functionName)); 62 } 63 64 } 65 66 #endif -
trunk/WebKit2/Platform/mac/ModuleMac.mm
r64662 r64663 24 24 */ 25 25 26 #include "NetscapePluginModule.h" 27 #include "NetscapeBrowserFuncs.h" 26 #include "Module.h" 28 27 29 28 namespace WebKit { 30 29 31 void NetscapePluginModule::unload()30 bool Module::load() 32 31 { 33 if (m_bundle) { 34 // We explicitly leak the bundle here, to avoid crashes when a bundle is unloaded and there are live Objective-C objects 35 // whose methods come from that bundle. 36 m_bundle.releaseRef(); 37 } 38 } 39 40 template<typename FuncType> 41 static inline FuncType pointerToFunction(CFBundleRef bundle, const char* functionName) 42 { 43 RetainPtr<CFStringRef> functionNameString(AdoptCF, CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, functionName, kCFStringEncodingASCII, kCFAllocatorNull)); 44 return reinterpret_cast<FuncType>(CFBundleGetFunctionPointerForName(bundle, functionNameString.get())); 45 } 46 47 bool NetscapePluginModule::tryLoad() 48 { 49 RetainPtr<CFStringRef> bundlePath(AdoptCF, m_pluginPath.createCFString()); 50 RetainPtr<CFURLRef> bundleURL(AdoptCF, CFURLCreateWithFileSystemPath(0, bundlePath.get(), kCFURLPOSIXPathStyle, FALSE)); 32 RetainPtr<CFStringRef> bundlePath(AdoptCF, m_path.createCFString()); 33 RetainPtr<CFURLRef> bundleURL(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, bundlePath.get(), kCFURLPOSIXPathStyle, FALSE)); 51 34 if (!bundleURL) 52 35 return false; 53 36 54 m_bundle.adoptCF(CFBundleCreate(kCFAllocatorDefault, bundleURL.get())); 55 if (!m_bundle) 56 return false; 57 58 if (!CFBundleLoadExecutable(m_bundle.get())) 37 RetainPtr<CFBundleRef> bundle(AdoptCF, CFBundleCreate(kCFAllocatorDefault, bundleURL.get())); 38 if (!bundle) 59 39 return false; 60 40 61 NP_InitializeFuncPtr initializeFuncPtr = pointerToFunction<NP_InitializeFuncPtr>(m_bundle.get(), "NP_Initialize"); 62 if (!initializeFuncPtr) 41 if (!CFBundleLoadExecutable(bundle.get())) 63 42 return false; 64 43 65 NP_GetEntryPointsFuncPtr getEntryPointsFuncPtr = pointerToFunction<NP_GetEntryPointsFuncPtr>(m_bundle.get(), "NP_GetEntryPoints"); 66 if (!getEntryPointsFuncPtr) 67 return false; 68 69 m_shutdownProcPtr = pointerToFunction<NPP_ShutdownProcPtr>(m_bundle.get(), "NP_Shutdown"); 70 if (!m_shutdownProcPtr) 71 return false; 72 73 if (initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR) 74 return false; 75 76 m_pluginFuncs.size = sizeof(NPPluginFuncs); 77 m_pluginFuncs.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; 78 if (getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR) 79 return false; 80 44 m_bundle.adoptCF(bundle.releaseRef()); 81 45 return true; 82 46 } 83 47 84 } // namespace WebKit 48 void Module::unload() 49 { 50 // See the comment in Module.h for why we leak the bundle here. 51 m_bundle.releaseRef(); 52 } 53 54 void* Module::platformFunctionPointer(const char* functionName) const 55 { 56 if (!m_bundle) 57 return 0; 58 RetainPtr<CFStringRef> functionNameString(AdoptCF, CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, functionName, kCFStringEncodingASCII, kCFAllocatorNull)); 59 return CFBundleGetFunctionPointerForName(m_bundle.get(), functionNameString.get()); 60 } 61 62 } -
trunk/WebKit2/Platform/qt/ModuleQt.cpp
r64662 r64663 24 24 */ 25 25 26 #ifndef NetscapePluginModule_h 27 #define NetscapePluginModule_h 26 #include "Module.h" 28 27 29 #include <WebCore/npfunctions.h> 30 #include <WebCore/PlatformString.h> 31 #include <wtf/RefCounted.h> 32 33 #if PLATFORM(MAC) 34 #include <wtf/RetainPtr.h> 35 #endif 28 #include "NotImplemented.h" 36 29 37 30 namespace WebKit { 38 31 39 class NetscapePluginModule : public RefCounted<NetscapePluginModule> { 40 public: 41 static PassRefPtr<NetscapePluginModule> getOrCreate(const WebCore::String& pluginPath); 42 ~NetscapePluginModule(); 32 bool Module::load() 33 { 34 notImplemented(); 35 return false; 36 } 43 37 44 const NPPluginFuncs& pluginFuncs() const { return m_pluginFuncs; } 38 void Module::unload() 39 { 40 notImplemented(); 41 } 45 42 46 void pluginCreated(); 47 void pluginDestroyed(); 43 void* Module::platformFunctionPointer(const char* functionName) const 44 { 45 notImplemented(); 46 return 0; 47 } 48 48 49 private: 50 explicit NetscapePluginModule(const WebCore::String& pluginPath); 51 52 bool tryLoad(); 53 bool load(); 54 void unload(); 55 56 void shutdown(); 57 58 WebCore::String m_pluginPath; 59 bool m_isInitialized; 60 unsigned m_pluginCount; 61 62 NPP_ShutdownProcPtr m_shutdownProcPtr; 63 NPPluginFuncs m_pluginFuncs; 64 65 #if PLATFORM(MAC) 66 RetainPtr<CFBundleRef> m_bundle; 67 #endif 68 }; 69 70 } // namespace WebKit 71 72 #endif // NetscapePluginModule_h 49 } -
trunk/WebKit2/Platform/win/ModuleWin.cpp
r64662 r64663 24 24 */ 25 25 26 #ifndef NetscapePluginModule_h 27 #define NetscapePluginModule_h 26 #include "Module.h" 28 27 29 #include <WebCore/npfunctions.h> 30 #include <WebCore/PlatformString.h> 31 #include <wtf/RefCounted.h> 32 33 #if PLATFORM(MAC) 34 #include <wtf/RetainPtr.h> 35 #endif 28 #include "NotImplemented.h" 36 29 37 30 namespace WebKit { 38 31 39 class NetscapePluginModule : public RefCounted<NetscapePluginModule> { 40 public: 41 static PassRefPtr<NetscapePluginModule> getOrCreate(const WebCore::String& pluginPath); 42 ~NetscapePluginModule(); 32 bool Module::load() 33 { 34 notImplemented(); 35 return false; 36 } 43 37 44 const NPPluginFuncs& pluginFuncs() const { return m_pluginFuncs; } 38 void Module::unload() 39 { 40 notImplemented(); 41 } 45 42 46 void pluginCreated(); 47 void pluginDestroyed(); 43 void* Module::platformFunctionPointer(const char* functionName) const 44 { 45 notImplemented(); 46 return 0; 47 } 48 48 49 private: 50 explicit NetscapePluginModule(const WebCore::String& pluginPath); 51 52 bool tryLoad(); 53 bool load(); 54 void unload(); 55 56 void shutdown(); 57 58 WebCore::String m_pluginPath; 59 bool m_isInitialized; 60 unsigned m_pluginCount; 61 62 NPP_ShutdownProcPtr m_shutdownProcPtr; 63 NPPluginFuncs m_pluginFuncs; 64 65 #if PLATFORM(MAC) 66 RetainPtr<CFBundleRef> m_bundle; 67 #endif 68 }; 69 70 } // namespace WebKit 71 72 #endif // NetscapePluginModule_h 49 } -
trunk/WebKit2/WebKit2.xcodeproj/project.pbxproj
r64662 r64663 62 62 1A6FB90B11E66FBC00DB1371 /* NetscapePluginModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6FB90911E66FBC00DB1371 /* NetscapePluginModule.h */; }; 63 63 1A6FB90C11E66FBC00DB1371 /* NetscapePluginModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FB90A11E66FBC00DB1371 /* NetscapePluginModule.cpp */; }; 64 1A6FBA0311E6813E00DB1371 /* NetscapePluginModuleMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FBA0211E6813E00DB1371 /* NetscapePluginModuleMac.cpp */; };65 64 1A6FBA2A11E6862700DB1371 /* NetscapeBrowserFuncs.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6FBA2811E6862700DB1371 /* NetscapeBrowserFuncs.h */; }; 66 65 1A6FBA2B11E6862700DB1371 /* NetscapeBrowserFuncs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FBA2911E6862700DB1371 /* NetscapeBrowserFuncs.cpp */; }; … … 272 271 BCF69FA91176D1CB00471A52 /* WKNavigationData.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF69FA71176D1CB00471A52 /* WKNavigationData.h */; settings = {ATTRIBUTES = (Public, ); }; }; 273 272 BCF69FAA1176D1CB00471A52 /* WKNavigationData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCF69FA81176D1CB00471A52 /* WKNavigationData.cpp */; }; 273 C0E3AA7A1209E83000A49D01 /* ModuleMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0E3AA481209E45000A49D01 /* ModuleMac.mm */; }; 274 C0E3AA7B1209E83500A49D01 /* Module.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0E3AA451209E2BA00A49D01 /* Module.cpp */; }; 275 C0E3AA7C1209E83C00A49D01 /* Module.h in Headers */ = {isa = PBXBuildFile; fileRef = C0E3AA441209E2BA00A49D01 /* Module.h */; }; 274 276 D3B9484611FF4B6500032B39 /* WebPopupMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3B9484211FF4B6500032B39 /* WebPopupMenu.cpp */; }; 275 277 D3B9484711FF4B6500032B39 /* WebPopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = D3B9484311FF4B6500032B39 /* WebPopupMenu.h */; }; … … 365 367 1A6FB90911E66FBC00DB1371 /* NetscapePluginModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetscapePluginModule.h; sourceTree = "<group>"; }; 366 368 1A6FB90A11E66FBC00DB1371 /* NetscapePluginModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePluginModule.cpp; sourceTree = "<group>"; }; 367 1A6FBA0211E6813E00DB1371 /* NetscapePluginModuleMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePluginModuleMac.cpp; sourceTree = "<group>"; };368 369 1A6FBA2811E6862700DB1371 /* NetscapeBrowserFuncs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetscapeBrowserFuncs.h; sourceTree = "<group>"; }; 369 370 1A6FBA2911E6862700DB1371 /* NetscapeBrowserFuncs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapeBrowserFuncs.cpp; sourceTree = "<group>"; }; … … 581 582 BCF69FA71176D1CB00471A52 /* WKNavigationData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKNavigationData.h; sourceTree = "<group>"; }; 582 583 BCF69FA81176D1CB00471A52 /* WKNavigationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKNavigationData.cpp; sourceTree = "<group>"; }; 584 C0E3AA441209E2BA00A49D01 /* Module.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Module.h; sourceTree = "<group>"; }; 585 C0E3AA451209E2BA00A49D01 /* Module.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Module.cpp; sourceTree = "<group>"; }; 586 C0E3AA481209E45000A49D01 /* ModuleMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModuleMac.mm; sourceTree = "<group>"; }; 583 587 D3B9484211FF4B6500032B39 /* WebPopupMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPopupMenu.cpp; sourceTree = "<group>"; }; 584 588 D3B9484311FF4B6500032B39 /* WebPopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPopupMenu.h; sourceTree = "<group>"; }; … … 755 759 children = ( 756 760 1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.mm */, 757 1A6FBA0211E6813E00DB1371 /* NetscapePluginModuleMac.cpp */,758 761 ); 759 762 path = mac; … … 765 768 1A24B5F011F531E800C38269 /* MachUtilities.cpp */, 766 769 1A24B5F111F531E800C38269 /* MachUtilities.h */, 770 C0E3AA481209E45000A49D01 /* ModuleMac.mm */, 767 771 BC0092F5115837A300E0AE2A /* RunLoopMac.mm */, 768 772 BC0092F6115837A300E0AE2A /* WorkQueueMac.cpp */, … … 1154 1158 1AB5A1BA10E021D30040F6CF /* CoreIPC */, 1155 1159 1A7E814E1152D2240003695B /* mac */, 1160 C0E3AA451209E2BA00A49D01 /* Module.cpp */, 1161 C0E3AA441209E2BA00A49D01 /* Module.h */, 1156 1162 BC8780FB1161C2B800CC2768 /* PlatformProcessIdentifier.h */, 1157 1163 BC2E6E771141970C00A63B1E /* RunLoop.cpp */, … … 1358 1364 51578B831209ECEF00A37C4A /* WebData.h in Headers */, 1359 1365 514AF6C91209EE7300A26C97 /* WKData.h in Headers */, 1366 C0E3AA7C1209E83C00A49D01 /* Module.h in Headers */, 1360 1367 ); 1361 1368 runOnlyForDeploymentPostprocessing = 0; … … 1478 1485 1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.mm in Sources */, 1479 1486 1A6FB90C11E66FBC00DB1371 /* NetscapePluginModule.cpp in Sources */, 1480 1A6FBA0311E6813E00DB1371 /* NetscapePluginModuleMac.cpp in Sources */,1481 1487 1AA5889311EE70400061B882 /* NetscapePluginStream.cpp in Sources */, 1482 1488 BC111B51112F619200337BAB /* PageClientImpl.mm in Sources */, … … 1563 1569 0FB659A61208B9EE0044816C /* DrawingAreaBase.cpp in Sources */, 1564 1570 514AF6C81209EE7300A26C97 /* WKData.cpp in Sources */, 1571 C0E3AA7A1209E83000A49D01 /* ModuleMac.mm in Sources */, 1572 C0E3AA7B1209E83500A49D01 /* Module.cpp in Sources */, 1565 1573 ); 1566 1574 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginModule.cpp
r63047 r64663 25 25 26 26 #include "NetscapePluginModule.h" 27 28 #include "Module.h" 29 #include "NetscapeBrowserFuncs.h" 30 #include <wtf/PassOwnPtr.h> 27 31 28 32 using namespace WebCore; … … 110 114 } 111 115 116 bool NetscapePluginModule::tryLoad() 117 { 118 m_module = adoptPtr(new Module(m_pluginPath)); 119 if (!m_module->load()) 120 return false; 121 122 NP_InitializeFuncPtr initializeFuncPtr = m_module->functionPointer<NP_InitializeFuncPtr>("NP_Initialize"); 123 if (!initializeFuncPtr) 124 return false; 125 126 NP_GetEntryPointsFuncPtr getEntryPointsFuncPtr = m_module->functionPointer<NP_GetEntryPointsFuncPtr>("NP_GetEntryPoints"); 127 if (!getEntryPointsFuncPtr) 128 return false; 129 130 m_shutdownProcPtr = m_module->functionPointer<NPP_ShutdownProcPtr>("NP_Shutdown"); 131 if (!m_shutdownProcPtr) 132 return false; 133 134 if (initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR) 135 return false; 136 137 m_pluginFuncs.size = sizeof(NPPluginFuncs); 138 m_pluginFuncs.version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; 139 if (getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR) 140 return false; 141 142 return true; 143 } 144 145 void NetscapePluginModule::unload() 146 { 147 m_module = 0; 148 } 149 112 150 } // namespace WebKit 113 151 -
trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginModule.h
r63047 r64663 27 27 #define NetscapePluginModule_h 28 28 29 #include "Module.h" 30 #include <WebCore/PlatformString.h> 29 31 #include <WebCore/npfunctions.h> 30 #include <WebCore/PlatformString.h>31 32 #include <wtf/RefCounted.h> 32 33 #if PLATFORM(MAC)34 #include <wtf/RetainPtr.h>35 #endif36 33 37 34 namespace WebKit { … … 63 60 NPPluginFuncs m_pluginFuncs; 64 61 65 #if PLATFORM(MAC) 66 RetainPtr<CFBundleRef> m_bundle; 67 #endif 62 OwnPtr<Module> m_module; 68 63 }; 69 64 -
trunk/WebKit2/win/WebKit2.vcproj
r64662 r64663 1330 1330 </File> 1331 1331 <File 1332 RelativePath="..\Platform\Module.cpp" 1333 > 1334 </File> 1335 <File 1336 RelativePath="..\Platform\Module.h" 1337 > 1338 </File> 1339 <File 1332 1340 RelativePath="..\Platform\RunLoop.cpp" 1333 1341 > … … 1352 1360 Name="win" 1353 1361 > 1362 <File 1363 RelativePath="..\Platform\win\ModuleWin.cpp" 1364 > 1365 </File> 1354 1366 <File 1355 1367 RelativePath="..\Platform\win\RunLoopWin.cpp"
Note: See TracChangeset
for help on using the changeset viewer.