From a3c0d386a972af3e0f82a8c48c33c6ebc5afd1a8 Mon Sep 17 00:00:00 2001 From: "andersca@apple.com" Date: Mon, 6 Oct 2008 21:28:52 +0000 Subject: [PATCH] 2008-10-06 Anders Carlsson Reviewed by Sam Weinig. More conversion and cleanup. * Plugins/WebBaseNetscapePluginStream.h: * Plugins/WebBaseNetscapePluginStream.mm: (WebNetscapePluginStream::startStream): (-[WebBaseNetscapePluginStream startStreamWithResponse:]): * Plugins/WebBaseNetscapePluginView.mm: (-[WebBaseNetscapePluginView evaluateJavaScriptPluginRequest:]): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37345 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebKit/mac/ChangeLog | 13 ++++ WebKit/mac/Plugins/WebBaseNetscapePluginStream.h | 9 +-- WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm | 81 +++++++++-------------- WebKit/mac/Plugins/WebBaseNetscapePluginView.mm | 14 ++-- 4 files changed, 56 insertions(+), 61 deletions(-) diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog index b03984731bbe..7bd5c754fbce 100644 --- a/WebKit/mac/ChangeLog +++ b/WebKit/mac/ChangeLog @@ -2,6 +2,19 @@ Reviewed by Sam Weinig. + More conversion and cleanup. + + * Plugins/WebBaseNetscapePluginStream.h: + * Plugins/WebBaseNetscapePluginStream.mm: + (WebNetscapePluginStream::startStream): + (-[WebBaseNetscapePluginStream startStreamWithResponse:]): + * Plugins/WebBaseNetscapePluginView.mm: + (-[WebBaseNetscapePluginView evaluateJavaScriptPluginRequest:]): + +2008-10-06 Anders Carlsson + + Reviewed by Sam Weinig. + Fold initWithRequestURL into initWithRequest. * Plugins/WebBaseNetscapePluginStream.h: diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginStream.h b/WebKit/mac/Plugins/WebBaseNetscapePluginStream.h index 6471999760c8..fd47e1a6ef4f 100644 --- a/WebKit/mac/Plugins/WebBaseNetscapePluginStream.h +++ b/WebKit/mac/Plugins/WebBaseNetscapePluginStream.h @@ -74,6 +74,8 @@ public: void deliverDataToFile(NSData *data); void deliverData(); + void startStream(NSURL *, long long expectedContentLength, NSDate *lastModifiedDate, NSString *mimeType, NSData *headers); + NSError *pluginCancelledConnectionError() const; RetainPtr m_deliveryData; @@ -151,16 +153,9 @@ private: - (NPP)plugin; -- (void)startStreamResponseURL:(NSURL *)theResponseURL - expectedContentLength:(long long)expectedContentLength - lastModifiedDate:(NSDate *)lastModifiedDate - MIMEType:(NSString *)MIMEType - headers:(NSData *)theHeaders; - - (void)cancelLoadWithError:(NSError *)error; - (void)start; -- (void)stop; @end #endif diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm b/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm index dfa0f6f280c0..57c6fdfae7ed 100644 --- a/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm +++ b/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm @@ -245,57 +245,52 @@ void WebNetscapePluginStream::setPlugin(NPP plugin) } } -- (void)startStreamResponseURL:(NSURL *)URL - expectedContentLength:(long long)expectedContentLength - lastModifiedDate:(NSDate *)lastModifiedDate - MIMEType:(NSString *)theMIMEType - headers:(NSData *)theHeaders +void WebNetscapePluginStream::startStream(NSURL *url, long long expectedContentLength, NSDate *lastModifiedDate, NSString *mimeType, NSData *headers) { - ASSERT(!_impl->m_isTerminated); + ASSERT(!m_isTerminated); - _impl->m_responseURL = URL; - _impl->m_mimeType = theMIMEType; + m_responseURL = url; + m_mimeType = mimeType; - free((void *)_impl->m_stream.url); - _impl->m_stream.url = strdup([_impl->m_responseURL.get() _web_URLCString]); - - _impl->m_stream.ndata = self; - _impl->m_stream.end = expectedContentLength > 0 ? (uint32)expectedContentLength : 0; - _impl->m_stream.lastmodified = (uint32)[lastModifiedDate timeIntervalSince1970]; - _impl->m_stream.notifyData = _impl->m_notifyData; - - if (theHeaders) { - unsigned len = [theHeaders length]; - _impl->m_headers = (char*) malloc(len + 1); - [theHeaders getBytes:_impl->m_headers]; - _impl->m_headers[len] = 0; - _impl->m_stream.headers = _impl->m_headers; + free((void *)m_stream.url); + m_stream.url = strdup([m_responseURL.get() _web_URLCString]); + + m_stream.ndata = m_pluginStream; + m_stream.end = expectedContentLength > 0 ? (uint32)expectedContentLength : 0; + m_stream.lastmodified = (uint32)[lastModifiedDate timeIntervalSince1970]; + m_stream.notifyData = m_notifyData; + + if (headers) { + unsigned len = [headers length]; + m_headers = (char*) malloc(len + 1); + [headers getBytes:m_headers]; + m_headers[len] = 0; + m_stream.headers = m_headers; } - _impl->m_transferMode = NP_NORMAL; - _impl->m_offset = 0; - _impl->m_reason = WEB_REASON_NONE; + m_transferMode = NP_NORMAL; + m_offset = 0; + m_reason = WEB_REASON_NONE; // FIXME: If WebNetscapePluginStream called our initializer we wouldn't have to do this here. - _impl->m_fileDescriptor = -1; + m_fileDescriptor = -1; // FIXME: Need a way to check if stream is seekable - WebBaseNetscapePluginView *pv = _impl->m_pluginView.get(); - [pv willCallPlugInFunction]; - NPError npErr = _impl->m_pluginFuncs->newstream(_impl->m_plugin, (char *)[_impl->m_mimeType.get() UTF8String], &_impl->m_stream, NO, &_impl->m_transferMode); - [pv didCallPlugInFunction]; - LOG(Plugins, "NPP_NewStream URL=%@ MIME=%@ error=%d", _impl->m_responseURL.get(), _impl->m_mimeType.get(), npErr); + [m_pluginView.get() willCallPlugInFunction]; + NPError npErr = m_pluginFuncs->newstream(m_plugin, (char *)[m_mimeType.get() UTF8String], &m_stream, NO, &m_transferMode); + [m_pluginView.get() didCallPlugInFunction]; + LOG(Plugins, "NPP_NewStream URL=%@ MIME=%@ error=%d", m_responseURL.get(), m_mimeType.get(), npErr); if (npErr != NPERR_NO_ERROR) { - LOG_ERROR("NPP_NewStream failed with error: %d responseURL: %@", npErr, _impl->m_responseURL.get()); + LOG_ERROR("NPP_NewStream failed with error: %d responseURL: %@", npErr, m_responseURL.get()); // Calling cancelLoadWithError: cancels the load, but doesn't call NPP_DestroyStream. - _impl->cancelLoadWithError(_impl->pluginCancelledConnectionError()); + cancelLoadWithError(pluginCancelledConnectionError()); return; } - _impl->m_newStreamSuccessful = true; + m_newStreamSuccessful = true; - switch (_impl->m_transferMode) { + switch (m_transferMode) { case NP_NORMAL: LOG(Plugins, "Stream type: NP_NORMAL"); break; @@ -307,7 +302,7 @@ void WebNetscapePluginStream::setPlugin(NPP plugin) break; case NP_SEEK: LOG_ERROR("Stream type: NP_SEEK not yet supported"); - _impl->cancelLoadAndDestroyStreamWithError(_impl->pluginCancelledConnectionError()); + cancelLoadAndDestroyStreamWithError(pluginCancelledConnectionError()); break; default: LOG_ERROR("unknown stream type"); @@ -323,14 +318,6 @@ void WebNetscapePluginStream::setPlugin(NPP plugin) _impl->m_loader->load(_impl->m_request); } -- (void)stop -{ - ASSERT(!_impl->m_frameLoader); - - if (!_impl->m_loader->isDone()) - [self cancelLoadAndDestroyStreamWithError:_impl->m_loader->cancelledError()]; -} - - (void)startStreamWithResponse:(NSURLResponse *)r { NSMutableData *theHeaders = nil; @@ -382,11 +369,7 @@ void WebNetscapePluginStream::setPlugin(NPP plugin) // startStreamResponseURL:... will null-terminate. } - [self startStreamResponseURL:[r URL] - expectedContentLength:expectedContentLength - lastModifiedDate:WKGetNSURLResponseLastModifiedDate(r) - MIMEType:[r MIMEType] - headers:theHeaders]; + _impl->startStream([r URL], expectedContentLength, WKGetNSURLResponseLastModifiedDate(r), [r MIMEType], theHeaders); } - (BOOL)wantsAllStreams diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm b/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm index 7e5530568933..652f19c7a979 100644 --- a/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm +++ b/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm @@ -2022,11 +2022,15 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr) plugin:plugin notifyData:[JSPluginRequest notifyData] sendNotification:[JSPluginRequest sendNotification]]; - [stream startStreamResponseURL:URL - expectedContentLength:[JSData length] - lastModifiedDate:nil - MIMEType:@"text/plain" - headers:nil]; + + NSURLResponse *response = [[NSURLResponse alloc] initWithURL:URL + MIMEType:@"text/plain" + expectedContentLength:[JSData length] + textEncodingName:nil]; + + [stream startStreamWithResponse:response]; + [response release]; + [stream receivedData:JSData]; [stream finishedLoading]; [stream release]; -- 2.11.4.GIT