Commit df0fa0d5 authored by mnaganov@chromium.org's avatar mnaganov@chromium.org

2010-07-16 Mikhail Naganov <mnaganov@chromium.org>

	Reviewed by Pavel Feldman.

	Make JS memory stats available via 'Performance' object (Web Timing).
	This statistics is populated only if 'WebKitMemoryInfoEnabled'
	preference is set.

	'console.memory' is kept until Web Timing object becomes visible by
	default (currently it is hidden under compile-time flag).  These stats
	are guarded with the same preference.

	https://bugs.webkit.org/show_bug.cgi?id=41617

	* bindings/js/JSConsoleCustom.cpp:
	* bindings/v8/custom/V8ConsoleCustom.cpp:
	* page/Console.cpp:
	(WebCore::Console::disconnectFrame):
	(WebCore::Console::memory):
	* page/Console.h:
	* page/Console.idl:
	* page/MemoryInfo.cpp:
	(WebCore::MemoryInfo::MemoryInfo):
	* page/MemoryInfo.h:
	(WebCore::MemoryInfo::create):
	* page/Performance.cpp:
	(WebCore::Performance::disconnectFrame):
	(WebCore::Performance::memory):
	* page/Performance.h:
	* page/Performance.idl:
	* page/Settings.cpp:
	(WebCore::Settings::Settings):
	* page/Settings.h:
	(WebCore::Settings::setMemoryInfoEnabled):
	(WebCore::Settings::memoryInfoEnabled):

	* public/WebSettings.h:
	* src/WebSettingsImpl.cpp:
	(WebKit::WebSettingsImpl::setMemoryInfoEnabled):
	* src/WebSettingsImpl.h:

	* WebKit.order:
	* WebView/WebPreferenceKeysPrivate.h:
	* WebView/WebPreferences.mm:
	(+[WebPreferences initialize]):
	(-[WebPreferences memoryInfoEnabled]):
	(-[WebPreferences setMemoryInfoEnabled:]):
	* WebView/WebPreferencesPrivate.h:
	* WebView/WebView.mm:
	(-[WebView _preferencesChangedNotification:]):

	* Interfaces/IWebPreferencesPrivate.idl:
	* WebPreferenceKeysPrivate.h:
	* WebPreferences.cpp:
	(WebPreferences::initializeDefaultSettings):
	(WebPreferences::memoryInfoEnabled):
	(WebPreferences::setMemoryInfoEnabled):
	* WebPreferences.h:
	* WebView.cpp:
	(WebView::notifyPreferencesChanged):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63537 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7d66fdd4
2010-07-16 Mikhail Naganov <mnaganov@chromium.org>
Reviewed by Pavel Feldman.
Make JS memory stats available via 'Performance' object (Web Timing).
This statistics is populated only if 'WebKitMemoryInfoEnabled'
preference is set.
'console.memory' is kept until Web Timing object becomes visible by
default (currently it is hidden under compile-time flag). These stats
are guarded with the same preference.
https://bugs.webkit.org/show_bug.cgi?id=41617
* bindings/js/JSConsoleCustom.cpp:
* bindings/v8/custom/V8ConsoleCustom.cpp:
* page/Console.cpp:
(WebCore::Console::disconnectFrame):
(WebCore::Console::memory):
* page/Console.h:
* page/Console.idl:
* page/MemoryInfo.cpp:
(WebCore::MemoryInfo::MemoryInfo):
* page/MemoryInfo.h:
(WebCore::MemoryInfo::create):
* page/Performance.cpp:
(WebCore::Performance::disconnectFrame):
(WebCore::Performance::memory):
* page/Performance.h:
* page/Performance.idl:
* page/Settings.cpp:
(WebCore::Settings::Settings):
* page/Settings.h:
(WebCore::Settings::setMemoryInfoEnabled):
(WebCore::Settings::memoryInfoEnabled):
2010-07-16 Nikolas Zimmermann <nzimmermann@rim.com>
Reviewed by Dirk Schulze.
......@@ -28,9 +28,7 @@
#include "JSConsole.h"
#include "Console.h"
#include "JSMemoryInfo.h"
#include "JSScriptProfile.h"
#include "MemoryInfo.h"
#include "ScriptCallStack.h"
#include "ScriptProfile.h"
#include <runtime/JSArray.h>
......@@ -57,9 +55,4 @@ JSValue JSConsole::profiles(ExecState* exec) const
#endif
JSValue JSConsole::memory(ExecState* exec) const
{
return toJS(exec, MemoryInfo::create());
}
} // namespace WebCore
......@@ -33,10 +33,8 @@
#include "V8Console.h"
#include "Console.h"
#include "MemoryInfo.h"
#include "ScriptProfile.h"
#include "V8Binding.h"
#include "V8MemoryInfo.h"
#include "V8Proxy.h"
#include "V8ScriptProfile.h"
......@@ -59,10 +57,4 @@ v8::Handle<v8::Value> V8Console::profilesAccessorGetter(v8::Local<v8::String> na
}
#endif
v8::Handle<v8::Value> V8Console::memoryAccessorGetter(v8::Local<v8::String>, const v8::AccessorInfo&)
{
INC_STATS("DOM.Console.memoryAccessorGetter");
return toV8(MemoryInfo::create());
}
} // namespace WebCore
......@@ -36,6 +36,7 @@
#include "FrameLoader.h"
#include "FrameTree.h"
#include "InspectorController.h"
#include "MemoryInfo.h"
#include "Page.h"
#include "PageGroup.h"
#include "PlatformString.h"
......@@ -61,6 +62,8 @@ Frame* Console::frame() const
void Console::disconnectFrame()
{
if (m_memory)
m_memory = 0;
m_frame = 0;
}
......@@ -456,6 +459,12 @@ void Console::warn(ScriptCallStack* callStack)
addMessage(LogMessageType, WarningMessageLevel, callStack);
}
MemoryInfo* Console::memory() const
{
m_memory = MemoryInfo::create(m_frame);
return m_memory.get();
}
static bool printExceptions = false;
bool Console::shouldPrintExceptions()
......
......@@ -29,8 +29,8 @@
#ifndef Console_h
#define Console_h
#include "MemoryInfo.h"
#include "PlatformString.h"
#include "ScriptProfile.h"
#include <wtf/PassRefPtr.h>
......@@ -43,7 +43,6 @@ typedef Vector<RefPtr<ScriptProfile> > ProfilesArray;
#endif
class Frame;
class MemoryInfo;
class Page;
class String;
class ScriptCallStack;
......@@ -116,6 +115,8 @@ public:
const ProfilesArray& profiles() const { return m_profiles; }
#endif
MemoryInfo* memory() const;
private:
inline Page* page() const;
void addMessage(MessageType, MessageLevel, ScriptCallStack*, bool acceptNoArguments = false);
......@@ -126,6 +127,7 @@ private:
#if ENABLE(JAVASCRIPT_DEBUGGER)
ProfilesArray m_profiles;
#endif
mutable RefPtr<MemoryInfo> m_memory;
};
} // namespace WebCore
......
......@@ -61,7 +61,7 @@ module window {
[CustomArgumentHandling] void groupCollapsed();
void groupEnd();
readonly attribute [CustomGetter] MemoryInfo memory;
readonly attribute MemoryInfo memory;
};
}
......@@ -31,17 +31,21 @@
#include "config.h"
#include "MemoryInfo.h"
#include "Frame.h"
#include "ScriptGCEvent.h"
#include "Settings.h"
namespace WebCore {
MemoryInfo::MemoryInfo()
MemoryInfo::MemoryInfo(Frame* frame)
: m_totalJSHeapSize(0),
m_usedJSHeapSize(0)
{
if (frame && frame->settings() && frame->settings()->memoryInfoEnabled()) {
#if ENABLE(INSPECTOR)
ScriptGCEvent::getHeapSize(m_usedJSHeapSize, m_totalJSHeapSize);
ScriptGCEvent::getHeapSize(m_usedJSHeapSize, m_totalJSHeapSize);
#endif
}
}
} // namespace WebCore
......@@ -36,15 +36,17 @@
namespace WebCore {
class Frame;
class MemoryInfo : public RefCounted<MemoryInfo> {
public:
static PassRefPtr<MemoryInfo> create() { return adoptRef(new MemoryInfo()); }
static PassRefPtr<MemoryInfo> create(Frame* frame) { return adoptRef(new MemoryInfo(frame)); }
size_t totalJSHeapSize() const { return m_totalJSHeapSize; }
size_t usedJSHeapSize() const { return m_usedJSHeapSize; }
private:
MemoryInfo();
MemoryInfo(Frame*);
size_t m_totalJSHeapSize;
size_t m_usedJSHeapSize;
......
......@@ -31,6 +31,7 @@
#include "config.h"
#include "Performance.h"
#include "MemoryInfo.h"
#include "Navigation.h"
#include "Timing.h"
......@@ -52,6 +53,8 @@ Frame* Performance::frame() const
void Performance::disconnectFrame()
{
if (m_memory)
m_memory = 0;
if (m_navigation) {
m_navigation->disconnectFrame();
m_navigation = 0;
......@@ -63,6 +66,12 @@ void Performance::disconnectFrame()
m_frame = 0;
}
MemoryInfo* Performance::memory() const
{
m_memory = MemoryInfo::create(m_frame);
return m_memory.get();
}
Navigation* Performance::navigation() const
{
if (!m_navigation)
......
......@@ -33,6 +33,7 @@
#if ENABLE(WEB_TIMING)
#include "MemoryInfo.h"
#include "Navigation.h"
#include "Timing.h"
#include <wtf/PassRefPtr.h>
......@@ -48,12 +49,14 @@ public:
Frame* frame() const;
void disconnectFrame();
MemoryInfo* memory() const;
Navigation* navigation() const;
Timing* timing() const;
private:
Performance(Frame*);
mutable RefPtr<MemoryInfo> m_memory;
mutable RefPtr<Navigation> m_navigation;
mutable RefPtr<Timing> m_timing;
Frame* m_frame;
......
......@@ -34,6 +34,7 @@ module window {
interface [Conditional=WEB_TIMING, OmitConstructor] Performance {
readonly attribute Navigation navigation;
readonly attribute Timing timing;
readonly attribute MemoryInfo memory;
};
}
......@@ -136,6 +136,7 @@ Settings::Settings(Page* page)
, m_html5TreeBuilderEnabled(false) // Will be deleted soon, do not use.
, m_paginateDuringLayoutEnabled(false)
, m_dnsPrefetchingEnabled(true)
, m_memoryInfoEnabled(false)
{
// A Frame may not have been created yet, so we initialize the AtomicString
// hash before trying to use it.
......
......@@ -310,6 +310,9 @@ namespace WebCore {
void setPaginateDuringLayoutEnabled(bool flag) { m_paginateDuringLayoutEnabled = flag; }
bool paginateDuringLayoutEnabled() const { return m_paginateDuringLayoutEnabled; }
void setMemoryInfoEnabled(bool flag) { m_memoryInfoEnabled = flag; }
bool memoryInfoEnabled() const { return m_memoryInfoEnabled; }
private:
Page* m_page;
......@@ -393,6 +396,7 @@ namespace WebCore {
bool m_html5TreeBuilderEnabled: 1; // Will be deleted soon, do not use.
bool m_paginateDuringLayoutEnabled : 1;
bool m_dnsPrefetchingEnabled : 1;
bool m_memoryInfoEnabled: 1;
#if USE(SAFARI_THEME)
static bool gShouldPaintNativeControls;
......
2010-07-16 Mikhail Naganov <mnaganov@chromium.org>
Reviewed by Pavel Feldman.
Make JS memory stats available via 'Performance' object (Web Timing).
This statistics is populated only if 'WebKitMemoryInfoEnabled'
preference is set.
'console.memory' is kept until Web Timing object becomes visible by
default (currently it is hidden under compile-time flag). These stats
are guarded with the same preference.
https://bugs.webkit.org/show_bug.cgi?id=41617
* public/WebSettings.h:
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::setMemoryInfoEnabled):
* src/WebSettingsImpl.h:
2010-07-15 Victor Wang <victorw@chromium.org>
Reviewed by David Levin.
......
......@@ -92,6 +92,7 @@ public:
virtual void setEditingBehavior(EditingBehavior) = 0;
virtual void setAcceleratedCompositingEnabled(bool) = 0;
virtual void setHTML5ParserEnabled(bool) = 0;
virtual void setMemoryInfoEnabled(bool) = 0;
protected:
~WebSettings() { }
......
......@@ -284,4 +284,9 @@ void WebSettingsImpl::setHTML5ParserEnabled(bool enabled)
m_settings->setHTML5ParserEnabled(enabled);
}
void WebSettingsImpl::setMemoryInfoEnabled(bool enabled)
{
m_settings->setMemoryInfoEnabled(enabled);
}
} // namespace WebKit
......@@ -88,6 +88,7 @@ public:
virtual void setEditingBehavior(EditingBehavior);
virtual void setAcceleratedCompositingEnabled(bool);
virtual void setHTML5ParserEnabled(bool);
virtual void setMemoryInfoEnabled(bool);
private:
WebCore::Settings* m_settings;
......
2010-07-16 Mikhail Naganov <mnaganov@chromium.org>
Reviewed by Pavel Feldman.
Make JS memory stats available via 'Performance' object (Web Timing).
This statistics is populated only if 'WebKitMemoryInfoEnabled'
preference is set.
'console.memory' is kept until Web Timing object becomes visible by
default (currently it is hidden under compile-time flag). These stats
are guarded with the same preference.
https://bugs.webkit.org/show_bug.cgi?id=41617
* WebKit.order:
* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences memoryInfoEnabled]):
(-[WebPreferences setMemoryInfoEnabled:]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChangedNotification:]):
2010-07-15 Shinichiro Hamaji <hamaji@chromium.org>
Reviewed by Darin Adler.
......
......@@ -283,6 +283,7 @@ _WKAppVersionCheckLessThan
-[WebPreferences(WebPrivate) showRepaintCounter]
-[WebPreferences(WebPrivate) pluginAllowedRunTime]
-[WebPreferences(WebPrivate) webGLEnabled]
-[WebPreferences(WebPrivate) memoryInfoEnabled]
-[WebPreferences(WebPrivate) isFrameFlatteningEnabled]
-[WebView setMaintainsBackForwardList:]
-[WebView setUIDelegate:]
......@@ -1883,6 +1884,7 @@ __ZN24WebDatabaseTrackerClient25dispatchDidModifyDatabaseEPN7WebCore14SecurityOr
-[WebPreferences setUsesPageCache:]
-[WebPreferences(WebPrivate) setAcceleratedCompositingEnabled:]
-[WebPreferences(WebPrivate) setWebGLEnabled:]
-[WebPreferences(WebPrivate) setMemoryInfoEnabled:]
+[WebPluginDatabase setAdditionalWebPlugInPaths:]
-[WebDefaultUIDelegate webView:didDrawRect:]
-[WebView(WebPrivate) _setPostsAcceleratedCompositingNotifications:]
......
......@@ -97,6 +97,7 @@
#define WebKitHTML5TreeBuilderEnabledPreferenceKey @"WebKitHTML5TreeBuilderEnabled" // Temporary, do not use.
#define WebKitPaginateDuringLayoutEnabledPreferenceKey @"WebKitPaginateDuringLayoutEnabled"
#define WebKitDNSPrefetchingEnabledPreferenceKey @"WebKitDNSPrefetchingEnabled"
#define WebKitMemoryInfoEnabledPreferenceKey @"WebKitMemoryInfoEnabled"
// These are private both because callers should be using the cover methods and because the
// cover methods themselves are private.
......
......@@ -363,6 +363,7 @@ static WebCacheModel cacheModelForMainBundle(void)
[NSNumber numberWithBool:YES], WebKitHTML5ParserEnabledPreferenceKey,
[NSNumber numberWithBool:NO], WebKitHTML5TreeBuilderEnabledPreferenceKey,
[NSNumber numberWithBool:YES], WebKitDNSPrefetchingEnabledPreferenceKey,
[NSNumber numberWithBool:NO], WebKitMemoryInfoEnabledPreferenceKey,
nil];
// This value shouldn't ever change, which is assumed in the initialization of WebKitPDFDisplayModePreferenceKey above
......@@ -1281,6 +1282,16 @@ static NSString *classIBCreatorID = nil;
[self _setBoolValue:flag forKey:WebKitPaginateDuringLayoutEnabledPreferenceKey];
}
- (BOOL)memoryInfoEnabled
{
return [self _boolValueForKey:WebKitMemoryInfoEnabledPreferenceKey];
}
- (void)setMemoryInfoEnabled:(BOOL)flag
{
[self _setBoolValue:flag forKey:WebKitMemoryInfoEnabledPreferenceKey];
}
- (WebKitEditingBehavior)editingBehavior
{
return static_cast<WebKitEditingBehavior>([self _integerValueForKey:WebKitEditingBehaviorPreferenceKey]);
......
......@@ -191,6 +191,9 @@ extern NSString *WebPreferencesRemovedNotification;
- (BOOL)usesProxiedOpenPanel;
- (void)setUsesProxiedOpenPanel:(BOOL)enabled;
- (BOOL)memoryInfoEnabled;
- (void)setMemoryInfoEnabled:(BOOL)enabled;
// Other private methods
- (void)_postPreferencesChangesNotification;
+ (WebPreferences *)_getInstanceForIdentifier:(NSString *)identifier;
......
......@@ -1433,6 +1433,7 @@ static bool fastDocumentTeardownEnabled()
settings->setHTML5ParserEnabled([preferences html5ParserEnabled]);
settings->setHTML5TreeBuilderEnabled_DO_NOT_USE([preferences html5TreeBuilderEnabled]);
settings->setPaginateDuringLayoutEnabled([preferences paginateDuringLayoutEnabled]);
settings->setMemoryInfoEnabled([preferences memoryInfoEnabled]);
}
static inline IMP getMethod(id o, SEL s)
......
2010-07-16 Mikhail Naganov <mnaganov@chromium.org>
Reviewed by Pavel Feldman.
Make JS memory stats available via 'Performance' object (Web Timing).
This statistics is populated only if 'WebKitMemoryInfoEnabled'
preference is set.
'console.memory' is kept until Web Timing object becomes visible by
default (currently it is hidden under compile-time flag). These stats
are guarded with the same preference.
https://bugs.webkit.org/show_bug.cgi?id=41617
* Interfaces/IWebPreferencesPrivate.idl:
* WebPreferenceKeysPrivate.h:
* WebPreferences.cpp:
(WebPreferences::initializeDefaultSettings):
(WebPreferences::memoryInfoEnabled):
(WebPreferences::setMemoryInfoEnabled):
* WebPreferences.h:
* WebView.cpp:
(WebView::notifyPreferencesChanged):
2010-07-14 Brent Fulgham <bfulgham@webkit.org>
Reviewed by Steve Falkenburg.
......
......@@ -115,4 +115,7 @@ interface IWebPreferencesPrivate : IUnknown
HRESULT isDNSPrefetchingEnabled([out, retval] BOOL *enabled);
HRESULT setDNSPrefetchingEnabled([in] BOOL enabled);
HRESULT memoryInfoEnabled([out, retval] BOOL *enabled);
HRESULT setMemoryInfoEnabled([in] BOOL enabled);
}
......@@ -145,3 +145,5 @@
#define WebKitCustomDragCursorsEnabledPreferenceKey "WebKitCustomDragCursorsEnabled"
#define WebKitDNSPrefetchingEnabledPreferenceKey "WebKitDNSPrefetchingEnabled"
#define WebKitMemoryInfoEnabledPreferenceKey "WebKitMemoryInfoEnabled"
......@@ -263,6 +263,8 @@ void WebPreferences::initializeDefaultSettings()
CFDictionaryAddValue(defaults, CFSTR(WebKitDNSPrefetchingEnabledPreferenceKey), kCFBooleanTrue);
CFDictionaryAddValue(defaults, CFSTR(WebKitMemoryInfoEnabledPreferenceKey), kCFBooleanFalse);
defaultSettings = defaults;
}
......@@ -1485,6 +1487,18 @@ HRESULT WebPreferences::isDNSPrefetchingEnabled(BOOL* enabled)
return S_OK;
}
HRESULT WebPreferences::memoryInfoEnabled(BOOL* enabled)
{
*enabled = boolValueForKey(CFSTR(WebKitMemoryInfoEnabledPreferenceKey));
return S_OK;
}
HRESULT WebPreferences::setMemoryInfoEnabled(BOOL enabled)
{
setBoolValue(CFSTR(WebKitMemoryInfoEnabledPreferenceKey), enabled);
return S_OK;
}
void WebPreferences::willAddToWebView()
{
++m_numWebViews;
......
......@@ -423,6 +423,9 @@ public:
virtual HRESULT STDMETHODCALLTYPE setDNSPrefetchingEnabled(BOOL);
virtual HRESULT STDMETHODCALLTYPE isDNSPrefetchingEnabled(BOOL*);
virtual HRESULT STDMETHODCALLTYPE setMemoryInfoEnabled(BOOL);
virtual HRESULT STDMETHODCALLTYPE memoryInfoEnabled(BOOL*);
// WebPreferences
// This method accesses a different preference key than developerExtrasEnabled.
......
......@@ -4745,6 +4745,11 @@ HRESULT WebView::notifyPreferencesChanged(IWebNotification* notification)
return hr;
settings->setDNSPrefetchingEnabled(enabled);
hr = prefsPrivate->memoryInfoEnabled(&enabled);
if (FAILED(hr))
return hr;
settings->setMemoryInfoEnabled(enabled);
if (!m_closeWindowTimer)
m_mainFrame->invalidate(); // FIXME
......
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