Improve cache ahndling.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19293 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2004-05-12 17:17:53 +00:00
parent bd51b8caea
commit 20c509536e
2 changed files with 40 additions and 14 deletions

View file

@ -1,3 +1,10 @@
2004-05-12 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSURL.m: ([-loadResourceDataNotifyingClient:usingCache:])
used cached information if requested. Always load using a cached
handle so that results will be available to later calls.
Addresses bug #8901
2004-05-09 David Ayers <d.ayers@inode.at> 2004-05-09 David Ayers <d.ayers@inode.at>
* Headers/Additions/GNUstepBase/GSObjCRuntime.h * Headers/Additions/GNUstepBase/GSObjCRuntime.h

View file

@ -1132,8 +1132,26 @@ static unsigned urlAlign;
- (void) loadResourceDataNotifyingClient: (id)client - (void) loadResourceDataNotifyingClient: (id)client
usingCache: (BOOL)shouldUseCache usingCache: (BOOL)shouldUseCache
{ {
NSURLHandle *handle = [self URLHandleUsingCache: shouldUseCache]; NSURLHandle *handle = [self URLHandleUsingCache: YES];
NSData *d;
if (shouldUseCache == YES && (d = [handle availableResourceData]) != nil)
{
/*
* We already have cached data we should use.
*/
if ([client respondsToSelector:
@selector(URL:resourceDataDidBecomeAvailable:)])
{
[client URL: self resourceDataDidBecomeAvailable: d];
}
if ([client respondsToSelector: @selector(URLResourceDidFinishLoading:)])
{
[client URLResourceDidFinishLoading: self];
}
}
else
{
if (client != nil) if (client != nil)
{ {
[clientsLock lock]; [clientsLock lock];
@ -1151,6 +1169,7 @@ static unsigned urlAlign;
* Kick off the load process. * Kick off the load process.
*/ */
[handle loadInBackground]; [handle loadInBackground];
}
} }
/** /**
@ -1335,7 +1354,7 @@ static unsigned urlAlign;
/** /**
* Loads the resource data for the represented URL and returns the result. * Loads the resource data for the represented URL and returns the result.
* The shoulduseCache flag determines whether an existing cached NSURLHandle * The shouldUseCache flag determines whether an existing cached NSURLHandle
* can be used to provide the data. * can be used to provide the data.
*/ */
- (NSData*) resourceDataUsingCache: (BOOL)shouldUseCache - (NSData*) resourceDataUsingCache: (BOOL)shouldUseCache