From 0e53bace6437af7ef38605f75520099098ec01c5 Mon Sep 17 00:00:00 2001 From: "andersca@apple.com" Date: Fri, 3 Oct 2008 21:58:20 +0000 Subject: [PATCH] 2008-10-03 Anders Carlsson Reviewed by David Hyatt. Convert destroyStream over to C++. * Plugins/WebBaseNetscapePluginStream.h: * Plugins/WebBaseNetscapePluginStream.mm: (WebNetscapePluginStream::destroyStream): (-[WebBaseNetscapePluginStream _destroyStreamWithReason:]): (-[WebBaseNetscapePluginStream _deliverData]): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37260 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebKit/mac/ChangeLog | 12 +++ WebKit/mac/Plugins/WebBaseNetscapePluginStream.h | 2 + WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm | 96 +++++++++++------------ 3 files changed, 58 insertions(+), 52 deletions(-) diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog index b366ee7990c8..1d589a8064fa 100644 --- a/WebKit/mac/ChangeLog +++ b/WebKit/mac/ChangeLog @@ -1,6 +1,18 @@ 2008-10-03 Anders Carlsson Reviewed by David Hyatt. + + Convert destroyStream over to C++. + + * Plugins/WebBaseNetscapePluginStream.h: + * Plugins/WebBaseNetscapePluginStream.mm: + (WebNetscapePluginStream::destroyStream): + (-[WebBaseNetscapePluginStream _destroyStreamWithReason:]): + (-[WebBaseNetscapePluginStream _deliverData]): + +2008-10-03 Anders Carlsson + + Reviewed by David Hyatt. Use a Timer instead of -[NSObject performSelector:withObject:afterDelay]; diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginStream.h b/WebKit/mac/Plugins/WebBaseNetscapePluginStream.h index 6ff4a3781390..0b90ec70307c 100644 --- a/WebKit/mac/Plugins/WebBaseNetscapePluginStream.h +++ b/WebKit/mac/Plugins/WebBaseNetscapePluginStream.h @@ -60,6 +60,8 @@ public: // FIXME: These should all be private once WebBaseNetscapePluginStream is history... public: + void destroyStream(); + RetainPtr m_deliveryData; RetainPtr m_requestURL; RetainPtr m_responseURL; diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm b/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm index f76fdfbb2e9f..663c3d079cb0 100644 --- a/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm +++ b/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm @@ -428,83 +428,76 @@ void WebNetscapePluginStream::setPlugin(NPP plugin) return value != 0; } -- (void)_destroyStream +void WebNetscapePluginStream::destroyStream() { - if (_impl->m_isTerminated) + if (m_isTerminated) return; - [self retain]; + RetainPtr protect(m_pluginStream); - ASSERT(_impl->m_reason != WEB_REASON_NONE); - ASSERT([_impl->m_deliveryData.get() length] == 0); + ASSERT(m_reason != WEB_REASON_NONE); + ASSERT([m_deliveryData.get() length] == 0); - _impl->m_deliverDataTimer.stop(); + m_deliverDataTimer.stop(); - if (_impl->m_stream.ndata != nil) { - if (_impl->m_reason == NPRES_DONE && (_impl->m_transferMode == NP_ASFILE || _impl->m_transferMode == NP_ASFILEONLY)) { - ASSERT(_impl->m_fileDescriptor == -1); - ASSERT(_impl->m_path); - NSString *carbonPath = CarbonPathFromPOSIXPath(_impl->m_path.get()); + if (m_stream.ndata != nil) { + if (m_reason == NPRES_DONE && (m_transferMode == NP_ASFILE || m_transferMode == NP_ASFILEONLY)) { + ASSERT(m_fileDescriptor == -1); + ASSERT(m_path); + NSString *carbonPath = CarbonPathFromPOSIXPath(m_path.get()); ASSERT(carbonPath != NULL); - WebBaseNetscapePluginView *pv = _impl->m_pluginView.get(); - [pv willCallPlugInFunction]; - _impl->m_pluginFuncs->asfile(_impl->m_plugin, &_impl->m_stream, [carbonPath fileSystemRepresentation]); - [pv didCallPlugInFunction]; - LOG(Plugins, "NPP_StreamAsFile responseURL=%@ path=%s", _impl->m_responseURL.get(), carbonPath); + [m_pluginView.get() willCallPlugInFunction]; + m_pluginFuncs->asfile(m_plugin, &m_stream, [carbonPath fileSystemRepresentation]); + [m_pluginView.get() didCallPlugInFunction]; + LOG(Plugins, "NPP_StreamAsFile responseURL=%@ path=%s", m_responseURL.get(), carbonPath); } - if (_impl->m_path) { + if (m_path) { // Delete the file after calling NPP_StreamAsFile(), instead of in -dealloc/-finalize. It should be OK // to delete the file here -- NPP_StreamAsFile() is always called immediately before NPP_DestroyStream() // (the stream destruction function), so there can be no expectation that a plugin will read the stream // file asynchronously after NPP_StreamAsFile() is called. - unlink([_impl->m_path.get() fileSystemRepresentation]); - _impl->m_path = 0; + unlink([m_path.get() fileSystemRepresentation]); + m_path = 0; - if (_impl->m_isTerminated) - goto exit; + if (m_isTerminated) + return; } - if (_impl->m_fileDescriptor != -1) { + if (m_fileDescriptor != -1) { // The file may still be open if we are destroying the stream before it completed loading. - close(_impl->m_fileDescriptor); - _impl->m_fileDescriptor = -1; + close(m_fileDescriptor); + m_fileDescriptor = -1; } - if (_impl->m_newStreamSuccessful) { - NPError npErr; - WebBaseNetscapePluginView *pv = _impl->m_pluginView.get(); - [pv willCallPlugInFunction]; - npErr = _impl->m_pluginFuncs->destroystream(_impl->m_plugin, &_impl->m_stream, _impl->m_reason); - [pv didCallPlugInFunction]; - LOG(Plugins, "NPP_DestroyStream responseURL=%@ error=%d", _impl->m_responseURL.get(), npErr); + if (m_newStreamSuccessful) { + [m_pluginView.get() willCallPlugInFunction]; + NPError npErr = m_pluginFuncs->destroystream(m_plugin, &m_stream, m_reason); + [m_pluginView.get() didCallPlugInFunction]; + LOG(Plugins, "NPP_DestroyStream responseURL=%@ error=%d", m_responseURL.get(), npErr); } - free(_impl->m_headers); - _impl->m_headers = NULL; - _impl->m_stream.headers = NULL; + free(m_headers); + m_headers = NULL; + m_stream.headers = NULL; - _impl->m_stream.ndata = nil; + m_stream.ndata = nil; - if (_impl->m_isTerminated) - goto exit; + if (m_isTerminated) + return; } - if (_impl->m_sendNotification) { + if (m_sendNotification) { // NPP_URLNotify expects the request URL, not the response URL. - WebBaseNetscapePluginView *pv = _impl->m_pluginView.get(); - [pv willCallPlugInFunction]; - _impl->m_pluginFuncs->urlnotify(_impl->m_plugin, [_impl->m_requestURL.get() _web_URLCString], _impl->m_reason, _impl->m_notifyData); - [pv didCallPlugInFunction]; - LOG(Plugins, "NPP_URLNotify requestURL=%@ reason=%d", _impl->m_requestURL.get(), _impl->m_reason); + [m_pluginView.get() willCallPlugInFunction]; + m_pluginFuncs->urlnotify(m_plugin, [m_requestURL.get() _web_URLCString], m_reason, m_notifyData); + [m_pluginView.get() didCallPlugInFunction]; + LOG(Plugins, "NPP_URLNotify requestURL=%@ reason=%d", m_requestURL.get(), m_reason); } - _impl->m_isTerminated = true; + m_isTerminated = true; - _impl->setPlugin(0); - -exit: - [self release]; + setPlugin(0); } - (void)_destroyStreamWithReason:(NPReason)theReason @@ -517,7 +510,7 @@ exit: // There is more data to be streamed, don't destroy the stream now. return; } - [self _destroyStream]; + _impl->destroyStream(); ASSERT(_impl->m_stream.ndata == nil); } @@ -605,9 +598,8 @@ exit: [newDeliveryData release]; } else { [_impl->m_deliveryData.get() setLength:0]; - if (_impl->m_reason != WEB_REASON_NONE) { - [self _destroyStream]; - } + if (_impl->m_reason != WEB_REASON_NONE) + _impl->destroyStream(); } } -- 2.11.4.GIT