Bug 41617 - Make JS memory stats available via 'Performance' object (Web Timing).
Summary: Make JS memory stats available via 'Performance' object (Web Timing).
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (Deprecated) (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Mikhail Naganov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-05 08:03 PDT by Mikhail Naganov
Modified: 2011-01-22 19:51 PST (History)
7 users (show)

See Also:


Attachments
patch (2.56 KB, patch)
2010-07-05 08:06 PDT, Mikhail Naganov
abarth: review-
Details | Formatted Diff | Diff
memory stats population is now controlled by a preference, turned off by default (21.76 KB, patch)
2010-07-06 08:59 PDT, Mikhail Naganov
no flags Details | Formatted Diff | Diff
fixed windows build failure (22.09 KB, patch)
2010-07-07 02:10 PDT, Mikhail Naganov
pfeldman: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Naganov 2010-07-05 08:03:06 PDT
It seems like a more natural place than 'console'.
Comment 1 Mikhail Naganov 2010-07-05 08:06:36 PDT
Created attachment 60536 [details]
patch
Comment 2 Sam Weinig 2010-07-05 18:37:15 PDT
As I have noted elsewhere, I do not think we should have this functionality exposed to the web.
Comment 3 Adam Barth 2010-07-05 20:04:08 PDT
Comment on attachment 60536 [details]
patch

That sounds like an R- to me.
Comment 4 Pavel Feldman 2010-07-05 22:21:12 PDT
Here is the plan:
1) Move console.memory and console.profiles from console.* to window.performance
2) Do not expose this information unless explicitly allowed with the command line flag
3) Extend WebTiming (performance) spec and make sure we conform to the apis there. If not allowed, we would return 0.

We need this API to be page-facting. We are not necessarily interested in having it web-facing. It can be behind the flag. The use-case here is that web developers run their continuous builds on browsers and get the memory / profiling stats for regression testing. We have a number of large-scale web app builders interested in the feature.
Comment 5 Mikhail Naganov 2010-07-06 08:59:31 PDT
Created attachment 60635 [details]
memory stats population is now controlled by a preference, turned off by default
Comment 6 WebKit Review Bot 2010-07-06 12:47:39 PDT
Attachment 60635 [details] did not build on win:
Build output: http://webkit-commit-queue.appspot.com/results/3376343
Comment 7 Mikhail Naganov 2010-07-07 02:10:36 PDT
Created attachment 60708 [details]
fixed windows build failure
Comment 8 Mikhail Naganov 2010-07-16 03:00:48 PDT
Manually committed as http://trac.webkit.org/changeset/63537


    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):
Comment 9 WebKit Review Bot 2010-07-16 04:02:16 PDT
http://trac.webkit.org/changeset/63537 might have broken Leopard Intel Release (Tests)
Comment 10 Tony Gentilcore 2010-07-16 11:03:38 PDT
Comment on attachment 60708 [details]
fixed windows build failure

> diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
> index 7ed5e75..a528ef8 100644
> --- a/WebCore/ChangeLog
> +++ b/WebCore/ChangeLog
> @@ -1,3 +1,39 @@
> +2010-07-07  Mikhail Naganov  <mnaganov@chromium.org>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        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-06  Ilya Tikhonovsky  <loislo@chromium.org>
>  
>          Reviewed by Yury Semikhatsky.
> diff --git a/WebCore/bindings/js/JSConsoleCustom.cpp b/WebCore/bindings/js/JSConsoleCustom.cpp
> index b9b407c..3ad34a3 100644
> --- a/WebCore/bindings/js/JSConsoleCustom.cpp
> +++ b/WebCore/bindings/js/JSConsoleCustom.cpp
> @@ -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
> diff --git a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
> index 7d1cfc1..9026420 100644
> --- a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
> +++ b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
> @@ -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"
>  
> @@ -57,10 +55,4 @@ v8::Handle<v8::Value> V8Console::profilesAccessorGetter(v8::Local<v8::String> na
>      return result;
>  }
>  
> -v8::Handle<v8::Value> V8Console::memoryAccessorGetter(v8::Local<v8::String>, const v8::AccessorInfo&)
> -{
> -    INC_STATS("DOM.Console.memoryAccessorGetter");
> -    return toV8(MemoryInfo::create());
> -}
> -
>  } // namespace WebCore
> diff --git a/WebCore/page/Console.cpp b/WebCore/page/Console.cpp
> index 1d6c095..423477a 100644
> --- a/WebCore/page/Console.cpp
> +++ b/WebCore/page/Console.cpp
> @@ -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()
> diff --git a/WebCore/page/Console.h b/WebCore/page/Console.h
> index 04e743e..3e00050 100644
> --- a/WebCore/page/Console.h
> +++ b/WebCore/page/Console.h
> @@ -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
> diff --git a/WebCore/page/Console.idl b/WebCore/page/Console.idl
> index 1506210..b79ff50 100644
> --- a/WebCore/page/Console.idl
> +++ b/WebCore/page/Console.idl
> @@ -61,7 +61,7 @@ module window {
>          [CustomArgumentHandling] void groupCollapsed();
>          void groupEnd();
>  
> -        readonly attribute [CustomGetter] MemoryInfo memory;
> +        readonly attribute MemoryInfo memory;
>      };
>  
>  }
> diff --git a/WebCore/page/MemoryInfo.cpp b/WebCore/page/MemoryInfo.cpp
> index 010a19c..c2247b9 100644
> --- a/WebCore/page/MemoryInfo.cpp
> +++ b/WebCore/page/MemoryInfo.cpp
> @@ -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
> diff --git a/WebCore/page/MemoryInfo.h b/WebCore/page/MemoryInfo.h
> index e9e0fa5..615e952 100644
> --- a/WebCore/page/MemoryInfo.h
> +++ b/WebCore/page/MemoryInfo.h
> @@ -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;
> diff --git a/WebCore/page/Performance.cpp b/WebCore/page/Performance.cpp
> index c19ce8f..c4234a7 100644
> --- a/WebCore/page/Performance.cpp
> +++ b/WebCore/page/Performance.cpp
> @@ -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)
> diff --git a/WebCore/page/Performance.h b/WebCore/page/Performance.h
> index f317076..9736fe7 100644
> --- a/WebCore/page/Performance.h
> +++ b/WebCore/page/Performance.h
> @@ -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;
> diff --git a/WebCore/page/Performance.idl b/WebCore/page/Performance.idl
> index 3885e2c..ffe8b6f 100644
> --- a/WebCore/page/Performance.idl
> +++ b/WebCore/page/Performance.idl
> @@ -34,6 +34,7 @@ module window {
>      interface [Conditional=WEB_TIMING, OmitConstructor] Performance {
>          readonly attribute Navigation navigation;
>          readonly attribute Timing timing;
> +        readonly attribute MemoryInfo memory;
>      };
>  
>  }
> diff --git a/WebCore/page/Settings.cpp b/WebCore/page/Settings.cpp
> index f100688..3a942ed 100644
> --- a/WebCore/page/Settings.cpp
> +++ b/WebCore/page/Settings.cpp
> @@ -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.
> diff --git a/WebCore/page/Settings.h b/WebCore/page/Settings.h
> index 2ac5d27..b42fe02 100644
> --- a/WebCore/page/Settings.h
> +++ b/WebCore/page/Settings.h
> @@ -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;
> diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
> index 29cf8f4..548463e 100644
> --- a/WebKit/chromium/ChangeLog
> +++ b/WebKit/chromium/ChangeLog
> @@ -1,3 +1,22 @@
> +2010-07-07  Mikhail Naganov  <mnaganov@chromium.org>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        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-05  Yury Semikhatsky  <yurys@chromium.org>
>  
>          Reviewed by Pavel Feldman.
> diff --git a/WebKit/chromium/public/WebSettings.h b/WebKit/chromium/public/WebSettings.h
> index de895e1..32cefa1 100644
> --- a/WebKit/chromium/public/WebSettings.h
> +++ b/WebKit/chromium/public/WebSettings.h
> @@ -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() { }
> diff --git a/WebKit/chromium/src/WebSettingsImpl.cpp b/WebKit/chromium/src/WebSettingsImpl.cpp
> index 7e89a77..6a02ed6 100644
> --- a/WebKit/chromium/src/WebSettingsImpl.cpp
> +++ b/WebKit/chromium/src/WebSettingsImpl.cpp
> @@ -284,4 +284,9 @@ void WebSettingsImpl::setHTML5ParserEnabled(bool enabled)
>      m_settings->setHTML5ParserEnabled(enabled);
>  }
>  
> +void WebSettingsImpl::setMemoryInfoEnabled(bool enabled)
> +{
> +    m_settings->setMemoryInfoEnabled(enabled);
> +}
> +
>  } // namespace WebKit
> diff --git a/WebKit/chromium/src/WebSettingsImpl.h b/WebKit/chromium/src/WebSettingsImpl.h
> index 70bd792..fe5db51 100644
> --- a/WebKit/chromium/src/WebSettingsImpl.h
> +++ b/WebKit/chromium/src/WebSettingsImpl.h
> @@ -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;
> diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
> index c59d8b4..3f9b6f6 100644
> --- a/WebKit/mac/ChangeLog
> +++ b/WebKit/mac/ChangeLog
> @@ -1,3 +1,27 @@
> +2010-07-07  Mikhail Naganov  <mnaganov@chromium.org>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        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-06-23  Philippe Normand  <pnormand@igalia.com>
>  
>          Reviewed by Eric Carlson.
> diff --git a/WebKit/mac/WebKit.order b/WebKit/mac/WebKit.order
> index 1776616..c2b5f5d 100644
> --- a/WebKit/mac/WebKit.order
> +++ b/WebKit/mac/WebKit.order
> @@ -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:]
> diff --git a/WebKit/mac/WebView/WebPreferenceKeysPrivate.h b/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
> index a28be49..4175a5d 100644
> --- a/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
> +++ b/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
> @@ -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.
> diff --git a/WebKit/mac/WebView/WebPreferences.mm b/WebKit/mac/WebView/WebPreferences.mm
> index a376458..6f6230b 100644
> --- a/WebKit/mac/WebView/WebPreferences.mm
> +++ b/WebKit/mac/WebView/WebPreferences.mm
> @@ -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]);
> diff --git a/WebKit/mac/WebView/WebPreferencesPrivate.h b/WebKit/mac/WebView/WebPreferencesPrivate.h
> index e94943f..073b364 100644
> --- a/WebKit/mac/WebView/WebPreferencesPrivate.h
> +++ b/WebKit/mac/WebView/WebPreferencesPrivate.h
> @@ -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;
> diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
> index ada00b5..14eb511 100644
> --- a/WebKit/mac/WebView/WebView.mm
> +++ b/WebKit/mac/WebView/WebView.mm
> @@ -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)
> diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
> index d943cc6..d082867 100644
> --- a/WebKit/win/ChangeLog
> +++ b/WebKit/win/ChangeLog
> @@ -1,3 +1,28 @@
> +2010-07-07  Mikhail Naganov  <mnaganov@chromium.org>
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        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:
> +        * Interfaces/WebKit.idl: Touched to enforce .idl re-build.
> +        * WebPreferenceKeysPrivate.h:
> +        * WebPreferences.cpp:
> +        (WebPreferences::initializeDefaultSettings):
> +        (WebPreferences::memoryInfoEnabled):
> +        (WebPreferences::setMemoryInfoEnabled):
> +        * WebPreferences.h:
> +        * WebView.cpp:
> +        (WebView::notifyPreferencesChanged):
> +
>  2010-07-03  Jon Honeycutt  <jhoneycutt@apple.com>
>  
>          The missing plug-in indicator should be clickable
> diff --git a/WebKit/win/Interfaces/IWebPreferencesPrivate.idl b/WebKit/win/Interfaces/IWebPreferencesPrivate.idl
> index 119c3ff..bca8d6f 100644
> --- a/WebKit/win/Interfaces/IWebPreferencesPrivate.idl
> +++ b/WebKit/win/Interfaces/IWebPreferencesPrivate.idl
> @@ -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);
>  }
> diff --git a/WebKit/win/Interfaces/WebKit.idl b/WebKit/win/Interfaces/WebKit.idl
> index 8938501..ce2f213 100644
> --- a/WebKit/win/Interfaces/WebKit.idl
> +++ b/WebKit/win/Interfaces/WebKit.idl
> @@ -300,3 +300,4 @@ library WebKit
>          [default] interface IWebUserContentURLPattern;
>      }
>  }
> +
> diff --git a/WebKit/win/WebPreferenceKeysPrivate.h b/WebKit/win/WebPreferenceKeysPrivate.h
> index 40c86c0..f62905c 100644
> --- a/WebKit/win/WebPreferenceKeysPrivate.h
> +++ b/WebKit/win/WebPreferenceKeysPrivate.h
> @@ -145,3 +145,5 @@
>  #define WebKitCustomDragCursorsEnabledPreferenceKey "WebKitCustomDragCursorsEnabled"
>  
>  #define WebKitDNSPrefetchingEnabledPreferenceKey "WebKitDNSPrefetchingEnabled"
> +
> +#define WebKitMemoryInfoEnabledPreferenceKey "WebKitMemoryInfoEnabled"
> diff --git a/WebKit/win/WebPreferences.cpp b/WebKit/win/WebPreferences.cpp
> index 12b0a72..a1055cb 100644
> --- a/WebKit/win/WebPreferences.cpp
> +++ b/WebKit/win/WebPreferences.cpp
> @@ -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;
> diff --git a/WebKit/win/WebPreferences.h b/WebKit/win/WebPreferences.h
> index fc57241..463e1b3 100644
> --- a/WebKit/win/WebPreferences.h
> +++ b/WebKit/win/WebPreferences.h
> @@ -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.
> diff --git a/WebKit/win/WebView.cpp b/WebKit/win/WebView.cpp
> index 441f0f2..4821954 100644
> --- a/WebKit/win/WebView.cpp
> +++ b/WebKit/win/WebView.cpp
> @@ -4751,6 +4751,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
>  

WebCore/page/Performance.idl:37
 +          readonly attribute MemoryInfo memory;
Is it possible to make this EnabledAtRuntime based on whether WebKitMemoryInfoEnabled is set? It would be nice to avoid having it there with zeros when the preference is disabled.
Comment 11 Mikhail Naganov 2010-07-16 12:10:43 PDT
Tony, the current behavior is intentional, see Pavel's comment (#4). This will prevent getting exceptions about undefined properties in code that uses them.
Comment 12 Tony Gentilcore 2010-07-16 12:21:10 PDT
(In reply to comment #11)
> Tony, the current behavior is intentional, see Pavel's comment (#4). This will prevent getting exceptions about undefined properties in code that uses them.

Gotcha. I'm not sure I agree with that approach because any real code would want to check for their presence before accessing them (since it isn't a standard yet). But it isn't that big of a deal. If anything, perhaps keeping them there advertises that a feature might exist and prompts developers to search for it and find the flag.