Commit ec77e33a authored by timothy@apple.com's avatar timothy@apple.com

Add a way for WebView and its dependancies to be selectively included

in WebKitStatistics leak tracking. By default WebView is not included and
you need to subclass WebView and implement +isIncludedInWebKitStatistics
to be included.

rdar://problem/7567677&7572900
https://webkit.org/b/35045

Reviewed by Adam Roben.

* WebView/WebDataSource.mm:
(-[WebDataSource _initWithDocumentLoader:]): Increment WebDataSourceCount if the WebFrame is included in statistics.
(-[WebDataSource dealloc]): Only --WebDataSourceCount if _private->includedInWebKitStatistics is YES.
(-[WebDataSource finalize]): Ditto.
* WebView/WebFrame.mm:
(-[WebFrame _isIncludedInWebKitStatistics]): Return _private->includedInWebKitStatistics.
(-[WebFrame _initWithWebFrameView:webView:]): Increment WebFrameCount if the WebView's class is included in statistics.
(-[WebFrame dealloc]): Only --WebFrameCount if _private->includedInWebKitStatistics is YES.
(-[WebFrame finalize]): Ditto.
* WebView/WebFrameInternal.h:
* WebView/WebFrameView.mm:
(-[WebFrameView _setWebFrame:]): Increment WebFrameViewCount if the WebFrame is included in statistics.
(-[WebFrameView initWithFrame:]): Move ++WebFrameViewCount from here since we don't
know what WebFrame we belong to yet.
(-[WebFrameView dealloc]): Only --WebFrameViewCount if _private->includedInWebKitStatistics is YES.
(-[WebFrameView finalize]): Ditto.
* WebView/WebHTMLRepresentation.mm:
(-[WebHTMLRepresentation init]): Move ++WebHTMLRepresentationCount from here since we don't
know what WebFrame we belong to yet.
(-[WebHTMLRepresentation dealloc]): Only --WebHTMLRepresentationCount if _private->includedInWebKitStatistics is YES.
(-[WebHTMLRepresentation finalize]): Ditto.
(-[WebHTMLRepresentation setDataSource:]): Increment WebHTMLRepresentationCount if the WebFrame of the dataSource is
included in statistics.
* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:usesDocumentViews:]):
(-[WebView dealloc]):
(+[WebView shouldIncludeInWebKitStatistics]): Return NO, so any WebView wont be included.
Subclasses that care can return YES to be included.
* WebView/WebViewInternal.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f5eaf118
2010-02-17 Timothy Hatcher <timothy@apple.com>
Add a way for WebView and its dependancies to be selectively included
in WebKitStatistics leak tracking. By default WebView is not included and
you need to subclass WebView and implement +isIncludedInWebKitStatistics
to be included.
rdar://problem/7567677&7572900
https://webkit.org/b/35045
Reviewed by Adam Roben.
* WebView/WebDataSource.mm:
(-[WebDataSource _initWithDocumentLoader:]): Increment WebDataSourceCount if the WebFrame is included in statistics.
(-[WebDataSource dealloc]): Only --WebDataSourceCount if _private->includedInWebKitStatistics is YES.
(-[WebDataSource finalize]): Ditto.
* WebView/WebFrame.mm:
(-[WebFrame _isIncludedInWebKitStatistics]): Return _private->includedInWebKitStatistics.
(-[WebFrame _initWithWebFrameView:webView:]): Increment WebFrameCount if the WebView's class is included in statistics.
(-[WebFrame dealloc]): Only --WebFrameCount if _private->includedInWebKitStatistics is YES.
(-[WebFrame finalize]): Ditto.
* WebView/WebFrameInternal.h:
* WebView/WebFrameView.mm:
(-[WebFrameView _setWebFrame:]): Increment WebFrameViewCount if the WebFrame is included in statistics.
(-[WebFrameView initWithFrame:]): Move ++WebFrameViewCount from here since we don't
know what WebFrame we belong to yet.
(-[WebFrameView dealloc]): Only --WebFrameViewCount if _private->includedInWebKitStatistics is YES.
(-[WebFrameView finalize]): Ditto.
* WebView/WebHTMLRepresentation.mm:
(-[WebHTMLRepresentation init]): Move ++WebHTMLRepresentationCount from here since we don't
know what WebFrame we belong to yet.
(-[WebHTMLRepresentation dealloc]): Only --WebHTMLRepresentationCount if _private->includedInWebKitStatistics is YES.
(-[WebHTMLRepresentation finalize]): Ditto.
(-[WebHTMLRepresentation setDataSource:]): Increment WebHTMLRepresentationCount if the WebFrame of the dataSource is
included in statistics.
* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:usesDocumentViews:]):
(-[WebView dealloc]):
(+[WebView shouldIncludeInWebKitStatistics]): Return NO, so any WebView wont be included.
Subclasses that care can return YES to be included.
* WebView/WebViewInternal.h:
2010-02-16 Darin Adler <darin@apple.com>
Reviewed by Sam Weinig.
......
......@@ -28,6 +28,9 @@
#import <Foundation/Foundation.h>
// These values are only incremented and decremented if the WebView is subclassed and
// +[WebView shouldIncludeInWebKitStatistics] returns YES. By default WebView returns NO.
@interface WebKitStatistics : NSObject
+ (int)webViewCount;
......
......@@ -70,6 +70,7 @@ using namespace WebCore;
id <WebDocumentRepresentation> representation;
BOOL representationFinishedLoading;
BOOL includedInWebKitStatistics;
}
@end
......@@ -372,10 +373,11 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
_private->loader = loader.releaseRef();
LOG(Loading, "creating datasource for %@", static_cast<NSURL *>(_private->loader->request().url()));
++WebDataSourceCount;
return self;
if ((_private->includedInWebKitStatistics = [[self webFrame] _isIncludedInWebKitStatistics]))
++WebDataSourceCount;
return self;
}
@end
......@@ -389,16 +391,18 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
- (void)dealloc
{
--WebDataSourceCount;
if (_private && _private->includedInWebKitStatistics)
--WebDataSourceCount;
[_private release];
[super dealloc];
}
- (void)finalize
{
--WebDataSourceCount;
if (_private && _private->includedInWebKitStatistics)
--WebDataSourceCount;
[super finalize];
}
......
......@@ -269,6 +269,11 @@ WebView *getWebView(WebFrame *webFrame)
return [self _createFrameWithPage:ownerElement->document()->frame()->page() frameName:name frameView:frameView ownerElement:ownerElement];
}
- (BOOL)_isIncludedInWebKitStatistics
{
return _private && _private->includedInWebKitStatistics;
}
- (void)_attachScriptDebugger
{
ScriptController* scriptController = _private->coreFrame->script();
......@@ -308,6 +313,11 @@ WebView *getWebView(WebFrame *webFrame)
_private = [[WebFramePrivate alloc] init];
// Set includedInWebKitStatistics before calling WebFrameView _setWebFrame, since
// it calls WebFrame _isIncludedInWebKitStatistics.
if ((_private->includedInWebKitStatistics = [[v class] shouldIncludeInWebKitStatistics]))
++WebFrameCount;
if (fv) {
[_private setWebFrameView:fv];
[fv _setWebFrame:self];
......@@ -315,8 +325,6 @@ WebView *getWebView(WebFrame *webFrame)
_private->shouldCreateRenderers = YES;
++WebFrameCount;
return self;
}
......@@ -1276,14 +1284,19 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
- (void)dealloc
{
if (_private && _private->includedInWebKitStatistics)
--WebFrameCount;
[_private release];
--WebFrameCount;
[super dealloc];
}
- (void)finalize
{
--WebFrameCount;
if (_private && _private->includedInWebKitStatistics)
--WebFrameCount;
[super finalize];
}
......
......@@ -81,6 +81,7 @@ WebView *getWebView(WebFrame *webFrame);
WebScriptDebugger* scriptDebugger;
id internalLoadDelegate;
BOOL shouldCreateRenderers;
BOOL includedInWebKitStatistics;
}
@end
......@@ -96,6 +97,8 @@ WebView *getWebView(WebFrame *webFrame);
- (void)_clearCoreFrame;
- (BOOL)_isIncludedInWebKitStatistics;
- (void)_updateBackgroundAndUpdatesWhileOffscreen;
- (void)_setInternalLoadDelegate:(id)internalLoadDelegate;
- (id)_internalLoadDelegate;
......
......@@ -92,6 +92,7 @@ enum {
@public
WebFrame *webFrame;
WebDynamicScrollBarsView *frameScrollView;
BOOL includedInWebKitStatistics;
}
@end
......@@ -187,6 +188,11 @@ enum {
// Not retained because the WebView owns the WebFrame, which owns the WebFrameView.
_private->webFrame = webFrame;
if (!_private->includedInWebKitStatistics && [webFrame _isIncludedInWebKitStatistics]) {
_private->includedInWebKitStatistics = YES;
++WebFrameViewCount;
}
}
- (WebDynamicScrollBarsView *)_scrollView
......@@ -286,15 +292,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
@implementation WebFrameView
- initWithCoder:(NSCoder *)decoder
{
// Older nibs containing WebViews will also contain WebFrameViews. We need to keep track of
// their count also to match the decrement in -dealloc.
++WebFrameViewCount;
return [super initWithCoder:decoder];
}
- initWithFrame:(NSRect)frame
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (!self)
......@@ -350,14 +348,13 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
// This works together with our becomeFirstResponder and setNextKeyView overrides.
[super setNextKeyView:scrollView];
++WebFrameViewCount;
return self;
}
- (void)dealloc
{
--WebFrameViewCount;
if (_private && _private->includedInWebKitStatistics)
--WebFrameViewCount;
[_private release];
_private = nil;
......@@ -367,7 +364,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
- (void)finalize
{
--WebFrameViewCount;
if (_private && _private->includedInWebKitStatistics)
--WebFrameViewCount;
[super finalize];
}
......
......@@ -66,6 +66,8 @@ using namespace HTMLNames;
WebDataSource *dataSource;
BOOL hasSentResponseToPlugin;
BOOL includedInWebKitStatistics;
id <WebPluginManualLoader> manualLoader;
NSView *pluginView;
}
......@@ -117,16 +119,15 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
return nil;
_private = [[WebHTMLRepresentationPrivate alloc] init];
++WebHTMLRepresentationCount;
return self;
}
- (void)dealloc
{
--WebHTMLRepresentationCount;
if (_private && _private->includedInWebKitStatistics)
--WebHTMLRepresentationCount;
[_private release];
[super dealloc];
......@@ -134,7 +135,8 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
- (void)finalize
{
--WebHTMLRepresentationCount;
if (_private && _private->includedInWebKitStatistics)
--WebHTMLRepresentationCount;
[super finalize];
}
......@@ -148,6 +150,11 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
- (void)setDataSource:(WebDataSource *)dataSource
{
_private->dataSource = dataSource;
if (!_private->includedInWebKitStatistics && [[dataSource webFrame] _isIncludedInWebKitStatistics]) {
_private->includedInWebKitStatistics = YES;
++WebHTMLRepresentationCount;
}
}
- (BOOL)_isDisplayingWebArchive
......
......@@ -658,7 +658,8 @@ static bool shouldEnableLoadDeferring()
[frameView setNextKeyView:nextKeyView];
[super setNextKeyView:frameView];
++WebViewCount;
if ([[self class] shouldIncludeInWebKitStatistics])
++WebViewCount;
[self _registerDraggedTypes];
......@@ -2745,8 +2746,9 @@ static bool needsWebViewInitThreadWorkaround()
// this maintains our old behavior for existing applications
[self close];
--WebViewCount;
if ([[self class] shouldIncludeInWebKitStatistics])
--WebViewCount;
if ([self _needsFrameLoadDelegateRetainQuirk])
[_private->frameLoadDelegate release];
......@@ -5341,6 +5343,11 @@ static WebFrameView *containingFrameView(NSView *view)
@implementation WebView (WebViewInternal)
+ (BOOL)shouldIncludeInWebKitStatistics
{
return NO;
}
- (BOOL)_becomingFirstResponderFromOutside
{
return _private->becomingFirstResponderFromOutside;
......
......@@ -64,6 +64,8 @@ namespace WebCore {
@interface WebView (WebViewInternal)
+ (BOOL)shouldIncludeInWebKitStatistics;
- (WebCore::Frame*)_mainCoreFrame;
- (WebFrame *)_selectedOrMainFrame;
......
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