Rolled out Maciej's code cleanup from 8/22. It turns out that keeping the "loading" flag
is a useful optimization, as it avoids many Objective-C method calls while polling resources
for their load state.
This fixes a 3-4% PLT performance regression (as measured on my MacBook Pro).
* Loader/WebFrameLoader.m:
(-[WebFrameLoader addPlugInStreamLoader:]):
(-[WebFrameLoader removePlugInStreamLoader:]):
(-[WebFrameLoader addSubresourceLoader:]):
(-[WebFrameLoader removeSubresourceLoader:]):
* WebView/WebDataSource.m:
(-[WebDataSourcePrivate dealloc]):
(-[WebDataSource _prepareForLoadStart]):
(-[WebDataSource _setLoading:]):
(-[WebDataSource _updateLoading]):
(-[WebDataSource _startLoading]):
(-[WebDataSource _stopLoading]):
(-[WebDataSource _setPrimaryLoadComplete:]):
(-[WebDataSource isLoading]):
* WebView/WebDataSourceInternal.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16271
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-09-08 Tim Omernick <timo@apple.com>
+
+ Reviewed by Brady Eidson.
+
+ Rolled out Maciej's code cleanup from 8/22. It turns out that keeping the "loading" flag
+ is a useful optimization, as it avoids many Objective-C method calls while polling resources
+ for their load state.
+
+ This fixes a 3-4% PLT performance regression (as measured on my MacBook Pro).
+
+ * Loader/WebFrameLoader.m:
+ (-[WebFrameLoader addPlugInStreamLoader:]):
+ (-[WebFrameLoader removePlugInStreamLoader:]):
+ (-[WebFrameLoader addSubresourceLoader:]):
+ (-[WebFrameLoader removeSubresourceLoader:]):
+ * WebView/WebDataSource.m:
+ (-[WebDataSourcePrivate dealloc]):
+ (-[WebDataSource _prepareForLoadStart]):
+ (-[WebDataSource _setLoading:]):
+ (-[WebDataSource _updateLoading]):
+ (-[WebDataSource _startLoading]):
+ (-[WebDataSource _stopLoading]):
+ (-[WebDataSource _setPrimaryLoadComplete:]):
+ (-[WebDataSource isLoading]):
+ * WebView/WebDataSourceInternal.h:
+
2006-09-07 Sam Weinig <sam.weinig@gmail.com>
Reviewed by Darin and Tim H.
if (!plugInStreamLoaders)
plugInStreamLoaders = [[NSMutableArray alloc] init];
[plugInStreamLoaders addObject:loader];
+ [[self activeDataSource] _setLoading:YES];
}
- (void)removePlugInStreamLoader:(WebLoader *)loader
{
[plugInStreamLoaders removeObject:loader];
+ [[self activeDataSource] _updateLoading];
}
- (void)setDefersCallbacks:(BOOL)defers
if (subresourceLoaders == nil)
subresourceLoaders = [[NSMutableArray alloc] init];
[subresourceLoaders addObject:loader];
+ [[self activeDataSource] _setLoading:YES];
}
- (void)removeSubresourceLoader:(WebLoader *)loader
{
[subresourceLoaders removeObject:loader];
+ [[self activeDataSource] _updateLoading];
}
- (NSData *)mainResourceData
// Error associated with main document.
NSError *mainDocumentError;
+ BOOL loading; // self and webView are retained while loading
+
BOOL gotFirstByte; // got first byte
BOOL committed; // This data source has been committed
BOOL representationFinishedLoading;
- (void)dealloc
{
+ ASSERT(!loading);
+
[loadState release];
[representation release];
// Mark the start loading time.
_private->loadingStartedTime = CFAbsoluteTimeGetCurrent();
+ [self _setLoading:YES];
[[self _webView] _progressStarted:[self webFrame]];
[[self _webView] _didStartProvisionalLoadForFrame:[self webFrame]];
[[[self _webView] _frameLoadDelegateForwarder] webView:[self _webView]
return [_private->unarchivingState archivedResourceForURL:URL];
}
+- (void)_setLoading:(BOOL)loading
+{
+ _private->loading = loading;
+}
+
+- (void)_updateLoading
+{
+ WebFrameLoader *frameLoader = [_private->webFrame _frameLoader];
+ ASSERT(self == [frameLoader activeDataSource]);
+
+ [self _setLoading:[frameLoader isLoading]];
+}
+
- (void)_startLoading
{
[self _prepareForLoadStart];
else
identifier = [[WebDefaultResourceLoadDelegate sharedResourceLoadDelegate] webView:[self _webView] identifierForInitialRequest:_private->originalRequest fromDataSource:self];
- [[_private->webFrame _frameLoader] startLoadingMainResourceWithRequest:_private->request identifier:identifier];
+ if (![[_private->webFrame _frameLoader] startLoadingMainResourceWithRequest:_private->request identifier:identifier])
+ [self _updateLoading];
}
- (void)_stopRecordingResponses
if (_private->committed)
[[self _bridge] stopLoading];
- if (![[_private->webFrame _frameLoader] isLoading])
+ if (!_private->loading)
return;
[self retain];
[[_private->webFrame _frameLoader] releaseMainResourceLoader];
}
+ [self _updateLoading];
+
if ([WebScriptDebugServer listenerCount])
[[WebScriptDebugServer sharedScriptDebugServer] webView:[[self webFrame] webView] didLoadMainResourceForDataSource:self];
}
// Once a frame has loaded, we no longer need to consider subresources,
// but we still need to consider subframes.
if ([[[self webFrame] _frameLoader] state] != WebFrameStateComplete) {
- if (!_private->primaryLoadComplete && [[_private->webFrame _frameLoader] isLoading])
+ if (!_private->primaryLoadComplete && _private->loading)
return YES;
if ([[_private->webFrame _frameLoader] isLoadingSubresources])
return YES;
- (void)_setupForReplaceByMIMEType:(NSString *)mimeType;
- (void)_mainReceivedError:(NSError *)error complete:(BOOL)isComplete;
- (void)_decidePolicyForMIMEType:(NSString *)MIMEType decisionListener:(WebPolicyDecisionListener *)listener;
-
-
-
+- (void)_setLoading:(BOOL)loading;
+- (void)_updateLoading;
@end