Commit b1498730 authored by kocienda's avatar kocienda
Browse files

WebFoundation:

	Modified API and behavior so that WebResourceHandle objects no longer
	buffer data as it is loaded. The responsibility to buffer data is now
	passed to WebResourceClient objects, and I modified the code to
	perform that buffering where necessary.

	There was also an API change to the WebResourceClient protoccol.

	- (void)handleDidFinishLoading:(WebResourceHandle *)handle data:(NSData *)data;

	has become

	- (void)handleDidFinishLoading:(WebResourceHandle *)handle;

	This reflects the fact that WebResourceHandle no longer has the data to pass
	in this callback (and may not be able to ask other objects in the framework to
	provide the data so that it may be presented in the callback).

	I also added a new WebResourceResponse class, although it is not wired up
	to anything yet.

        * CacheLoader.subproj/IFURLHandleC.h:
        * CacheLoader.subproj/IFURLHandleC.m:
        * CacheLoader.subproj/WebResourceCallbackClient.m:
        (-[WebResourceCallbackClient handleDidFinishLoading:])
        * CacheLoader.subproj/WebResourceClient.h:
        * CacheLoader.subproj/WebResourceHandle.h:
        * CacheLoader.subproj/WebResourceHandle.m:
        (-[WebResourceHandle loadInForeground:])
        (-[WebResourceHandle contentLengthReceived])
        * CacheLoader.subproj/WebResourceHandleInternal.h:
        * CacheLoader.subproj/WebResourceHandleInternal.m:
        (-[WebResourceHandleInstanceVariables initWithHandle:])
        (-[WebResourceHandleInstanceVariables dealloc])
        (-[WebResourceHandle _notifyClientDataDidBecomeAvailable])
        (-[WebResourceHandle _notifyClientDidFinishLoading])
        * CacheLoader.subproj/WebResourceHandlePrivate.m:
        (-[WebResourceHandle _didLoadData:])
        * CacheLoader.subproj/WebResourceResponse.h: Added.
        * CacheLoader.subproj/WebResourceResponse.m: Added.
        * CacheLoader.subproj/WebResourceResponsePrivate.h: Added.
        * CacheLoader.subproj/WebResourceSynchronousClient.h:
        * CacheLoader.subproj/WebResourceSynchronousClient.m:
        (-[WebResourceSynchronousClient initWithMonitor:realClient:])
        (-[WebResourceSynchronousClient dealloc])
        (-[WebResourceSynchronousClient resourceData])
        (-[WebResourceSynchronousClient handleDidFinishLoading:])
        (-[WebResourceSynchronousClient handleDidReceiveData:data:])
        * WebFoundation.exp:
        * WebFoundation.pbproj/project.pbxproj:

WebKit:

	Made more adjustments for API and behavior change that occurred in WebFoundation,
	now that WebResourceHandle objects no buffer resource data as it is loaded. Where
	necessary, the WebKit objects now do their own buffering, however, in many cases,
	buffering is not necessary to maintain correct behavior.

        * Misc.subproj/WebIconLoader.m:
        (-[WebIconLoaderPrivate dealloc]): Release new buffered resource data object.
        (-[WebIconLoader initWithURL:]): Allocate new buffered resource data object.
        (-[WebIconLoader handleDidFinishLoading:]): Modify API to remove data parameter.
        (-[WebIconLoader handleDidReceiveData:data:]): Buffer data as it is received.
        * Plugins.subproj/WebPluginStream.h: Added new buffered resource data object.
        * Plugins.subproj/WebPluginStream.m:
        (-[WebNetscapePluginStream initWithURL:pluginPointer:notifyData:attributes:]): Allocate new buffered resource data object.
        (-[WebNetscapePluginStream dealloc]): Release new buffered resource data object.
        (-[WebNetscapePluginStream receivedData:]): Buffer data as it is received (when necessary maintain correct behavior).
        (-[WebNetscapePluginStream handleDidFinishLoading:]): Modify API to remove data parameter.
        * WebCoreSupport.subproj/WebSubresourceClient.m:
        (-[WebSubresourceClient handleDidFinishLoading:]): Modify API to remove data parameter.
        * WebView.subproj/WebMainResourceClient.m:
        (-[WebMainResourceClient handleDidFinishLoading:]): Modify API to remove data parameter.
        (-[WebMainResourceClient handleDidReceiveData:data:]): Buffer data as it is received (when necessary maintain correct behavior).


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 45fa1a35
2002-09-04 Ken Kocienda <kocienda@apple.com>
Made more adjustments for API and behavior change that occurred in WebFoundation,
now that WebResourceHandle objects no buffer resource data as it is loaded. Where
necessary, the WebKit objects now do their own buffering, however, in many cases,
buffering is not necessary to maintain correct behavior.
* Misc.subproj/WebIconLoader.m:
(-[WebIconLoaderPrivate dealloc]): Release new buffered resource data object.
(-[WebIconLoader initWithURL:]): Allocate new buffered resource data object.
(-[WebIconLoader handleDidFinishLoading:]): Modify API to remove data parameter.
(-[WebIconLoader handleDidReceiveData:data:]): Buffer data as it is received.
* Plugins.subproj/WebPluginStream.h: Added new buffered resource data object.
* Plugins.subproj/WebPluginStream.m:
(-[WebNetscapePluginStream initWithURL:pluginPointer:notifyData:attributes:]): Allocate new buffered resource data object.
(-[WebNetscapePluginStream dealloc]): Release new buffered resource data object.
(-[WebNetscapePluginStream receivedData:]): Buffer data as it is received (when necessary maintain correct behavior).
(-[WebNetscapePluginStream handleDidFinishLoading:]): Modify API to remove data parameter.
* WebCoreSupport.subproj/WebSubresourceClient.m:
(-[WebSubresourceClient handleDidFinishLoading:]): Modify API to remove data parameter.
* WebView.subproj/WebMainResourceClient.m:
(-[WebMainResourceClient handleDidFinishLoading:]): Modify API to remove data parameter.
(-[WebMainResourceClient handleDidReceiveData:data:]): Buffer data as it is received (when necessary maintain correct behavior).
2002-09-04 Chris Blumenberg <cblu@apple.com>
Fixed: 3043024 - Built-in icons should match on *whatever.com or *whatever.whatever
......
2002-09-04 Ken Kocienda <kocienda@apple.com>
Made more adjustments for API and behavior change that occurred in WebFoundation,
now that WebResourceHandle objects no buffer resource data as it is loaded. Where
necessary, the WebKit objects now do their own buffering, however, in many cases,
buffering is not necessary to maintain correct behavior.
* Misc.subproj/WebIconLoader.m:
(-[WebIconLoaderPrivate dealloc]): Release new buffered resource data object.
(-[WebIconLoader initWithURL:]): Allocate new buffered resource data object.
(-[WebIconLoader handleDidFinishLoading:]): Modify API to remove data parameter.
(-[WebIconLoader handleDidReceiveData:data:]): Buffer data as it is received.
* Plugins.subproj/WebPluginStream.h: Added new buffered resource data object.
* Plugins.subproj/WebPluginStream.m:
(-[WebNetscapePluginStream initWithURL:pluginPointer:notifyData:attributes:]): Allocate new buffered resource data object.
(-[WebNetscapePluginStream dealloc]): Release new buffered resource data object.
(-[WebNetscapePluginStream receivedData:]): Buffer data as it is received (when necessary maintain correct behavior).
(-[WebNetscapePluginStream handleDidFinishLoading:]): Modify API to remove data parameter.
* WebCoreSupport.subproj/WebSubresourceClient.m:
(-[WebSubresourceClient handleDidFinishLoading:]): Modify API to remove data parameter.
* WebView.subproj/WebMainResourceClient.m:
(-[WebMainResourceClient handleDidFinishLoading:]): Modify API to remove data parameter.
(-[WebMainResourceClient handleDidReceiveData:data:]): Buffer data as it is received (when necessary maintain correct behavior).
2002-09-04 Chris Blumenberg <cblu@apple.com>
Fixed: 3043024 - Built-in icons should match on *whatever.com or *whatever.whatever
......
......@@ -23,6 +23,7 @@ @interface WebIconLoaderPrivate : NSObject
WebResourceHandle *handle;
id delegate;
NSURL *URL;
NSMutableData *resourceData;
}
@end;
......@@ -33,6 +34,7 @@ - (void)dealloc
{
[URL release];
[handle release];
[resourceData release];
[super dealloc];
}
......@@ -50,6 +52,7 @@ @implementation WebIconLoader
[super init];
_private = [[WebIconLoaderPrivate alloc] init];
_private->URL = [URL retain];
_private->resourceData = [[NSMutableData alloc] init];
return self;
}
......@@ -114,9 +117,9 @@ - (void)handleDidCancelLoading:(WebResourceHandle *)sender
{
}
- (void)handleDidFinishLoading:(WebResourceHandle *)sender data:(NSData *)data
- (void)handleDidFinishLoading:(WebResourceHandle *)sender
{
NSImage *icon = [[NSImage alloc] initWithData:data];
NSImage *icon = [[NSImage alloc] initWithData:_private->resourceData];
if (icon) {
[[WebIconDatabase sharedIconDatabase] _setIcon:icon forIconURL:_private->URL];
[_private->delegate iconLoader:self receivedPageIcon:icon];
......@@ -126,6 +129,7 @@ - (void)handleDidFinishLoading:(WebResourceHandle *)sender data:(NSData *)data
- (void)handleDidReceiveData:(WebResourceHandle *)sender data:(NSData *)data
{
[_private->resourceData appendData:data];
}
- (void)handleDidFailLoading:(WebResourceHandle *)sender withError:(WebError *)result
......
......@@ -29,6 +29,7 @@
BOOL isFirstChunk;
WebResourceHandle *resource;
NSMutableData *resourceData;
NPP_NewStreamProcPtr NPP_NewStream;
NPP_DestroyStreamProcPtr NPP_DestroyStream;
......
......@@ -71,6 +71,7 @@ - (void) getFunctionPointersFromPluginView:(WebNetscapePluginView *)pluginView
attributes = [theAttributes retain];
instance = thePluginPointer;
notifyData = theNotifyData;
resourceData = [[NSMutableData alloc] init];
[self getFunctionPointersFromPluginView:view];
......@@ -91,6 +92,7 @@ - (void) dealloc
free((void *)npStream.URL);
[URL release];
[attributes release];
[resourceData release];
[super dealloc];
}
......@@ -158,6 +160,11 @@ - (void)receivedData:(NSData *)data
}
}
if(transferMode == NP_ASFILE || transferMode == NP_ASFILEONLY) {
// only need to buffer data in this case
[resourceData appendData:data];
}
if(transferMode != NP_ASFILEONLY){
numBytes = NPP_WriteReady(instance, &npStream);
WEBKITDEBUGLEVEL(WEBKIT_LOG_PLUGINS, "NPP_WriteReady bytes=%lu\n", numBytes);
......@@ -271,14 +278,14 @@ - (void)handleDidReceiveData:(WebResourceHandle *)handle data:(NSData *)data
forResourceHandle: handle fromDataSource: [view webDataSource] complete: NO];
}
- (void)handleDidFinishLoading:(WebResourceHandle *)handle data: (NSData *)data
- (void)handleDidFinishLoading:(WebResourceHandle *)handle
{
WebController *webController = [view webController];
[webController _receivedProgress:[WebLoadProgress progressWithResourceHandle:handle]
forResourceHandle: handle fromDataSource: [view webDataSource] complete: YES];
[self finishedLoadingWithData:data];
[self finishedLoadingWithData:resourceData];
[webController _didStopLoading:URL];
}
......
......@@ -130,11 +130,10 @@ - (void)handleDidCancelLoading:(WebResourceHandle *)handle
[self didStopLoading];
}
- (void)handleDidFinishLoading:(WebResourceHandle *)handle data:(NSData *)data
- (void)handleDidFinishLoading:(WebResourceHandle *)handle
{
WEBKIT_ASSERT([currentURL isEqual:[handle URL]]);
WEBKIT_ASSERT([handle statusCode] == WebResourceHandleStatusLoadComplete);
WEBKIT_ASSERT((int)[data length] == [handle contentLengthReceived]);
[loader finish];
......
......@@ -130,11 +130,10 @@ - (void)handleDidCancelLoading:(WebResourceHandle *)handle
[self didStopLoading];
}
- (void)handleDidFinishLoading:(WebResourceHandle *)handle data:(NSData *)data
- (void)handleDidFinishLoading:(WebResourceHandle *)handle
{
WEBKIT_ASSERT([currentURL isEqual:[handle URL]]);
WEBKIT_ASSERT([handle statusCode] == WebResourceHandleStatusLoadComplete);
WEBKIT_ASSERT((int)[data length] == [handle contentLengthReceived]);
[loader finish];
......
......@@ -139,19 +139,18 @@ - (void)handleDidCancelLoading:(WebResourceHandle *)handle
[self didStopLoading];
}
- (void)handleDidFinishLoading:(WebResourceHandle *)handle data: (NSData *)data
- (void)handleDidFinishLoading:(WebResourceHandle *)handle
{
WEBKITDEBUGLEVEL(WEBKIT_LOG_LOADING, "URL = %s\n", DEBUG_OBJECT([handle URL]));
WEBKIT_ASSERT([currentURL isEqual:[handle URL]]);
WEBKIT_ASSERT([handle statusCode] == WebResourceHandleStatusLoadComplete);
WEBKIT_ASSERT((int)[data length] == [handle contentLengthReceived]);
WebContentAction contentAction = [[dataSource contentPolicy] policyAction];
// Don't retain data for downloaded files
if(contentAction != WebContentPolicySave && contentAction != WebContentPolicySaveAndOpenExternally){
[dataSource _setResourceData:data];
[dataSource _setResourceData:resourceData];
}
if(contentAction == WebContentPolicyShow){
......@@ -210,10 +209,10 @@ - (void)handleDidReceiveData:(WebResourceHandle *)handle data:(NSData *)data
WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
}
[resourceData appendData:data];
switch (policyAction) {
case WebContentPolicyShow:
// only need to buffer data in this case
[resourceData appendData:data];
[dataSource _receivedData:data];
break;
case WebContentPolicySave:
......
......@@ -139,19 +139,18 @@ - (void)handleDidCancelLoading:(WebResourceHandle *)handle
[self didStopLoading];
}
- (void)handleDidFinishLoading:(WebResourceHandle *)handle data: (NSData *)data
- (void)handleDidFinishLoading:(WebResourceHandle *)handle
{
WEBKITDEBUGLEVEL(WEBKIT_LOG_LOADING, "URL = %s\n", DEBUG_OBJECT([handle URL]));
WEBKIT_ASSERT([currentURL isEqual:[handle URL]]);
WEBKIT_ASSERT([handle statusCode] == WebResourceHandleStatusLoadComplete);
WEBKIT_ASSERT((int)[data length] == [handle contentLengthReceived]);
WebContentAction contentAction = [[dataSource contentPolicy] policyAction];
// Don't retain data for downloaded files
if(contentAction != WebContentPolicySave && contentAction != WebContentPolicySaveAndOpenExternally){
[dataSource _setResourceData:data];
[dataSource _setResourceData:resourceData];
}
if(contentAction == WebContentPolicyShow){
......@@ -210,10 +209,10 @@ - (void)handleDidReceiveData:(WebResourceHandle *)handle data:(NSData *)data
WEBKITDEBUGLEVEL(WEBKIT_LOG_DOWNLOAD, "main content type: %s", DEBUG_OBJECT(contentType));
}
[resourceData appendData:data];
switch (policyAction) {
case WebContentPolicyShow:
// only need to buffer data in this case
[resourceData appendData:data];
[dataSource _receivedData:data];
break;
case WebContentPolicySave:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment