Title: [104873] trunk/Source/WebCore
Revision
104873
Author
commit-qu...@webkit.org
Date
2012-01-12 15:59:53 -0800 (Thu, 12 Jan 2012)

Log Message

Patch by Yongjun Zhang <yongjun_zh...@apple.com> on 2012-01-12
Reviewed by Benjamin Poulain.

https://bugs.webkit.org/show_bug.cgi?id=75991
Make the code in MemoryPressureHandler::respondToMemoryPressure shareable.

Move memory pressure handling code inside a new function (releaseMemory) so that
we could shared it between mac and iOS.

* Configurations/WebCore.xcconfig: add MemoryPressureHandlerMac.mm into iOS build.
* platform/MemoryPressureHandler.h:
* platform/mac/MemoryPressureHandlerMac.mm:
(WebCore::MemoryPressureHandler::respondToMemoryPressure):
(WebCore::MemoryPressureHandler::releaseMemory):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (104872 => 104873)


--- trunk/Source/WebCore/ChangeLog	2012-01-12 23:57:29 UTC (rev 104872)
+++ trunk/Source/WebCore/ChangeLog	2012-01-12 23:59:53 UTC (rev 104873)
@@ -1,3 +1,19 @@
+2012-01-12  Yongjun Zhang  <yongjun_zh...@apple.com>
+
+        Reviewed by Benjamin Poulain.
+
+        https://bugs.webkit.org/show_bug.cgi?id=75991
+        Make the code in MemoryPressureHandler::respondToMemoryPressure shareable.
+
+        Move memory pressure handling code inside a new function (releaseMemory) so that
+        we could shared it between mac and iOS.
+
+        * Configurations/WebCore.xcconfig: add MemoryPressureHandlerMac.mm into iOS build.
+        * platform/MemoryPressureHandler.h:
+        * platform/mac/MemoryPressureHandlerMac.mm:
+        (WebCore::MemoryPressureHandler::respondToMemoryPressure):
+        (WebCore::MemoryPressureHandler::releaseMemory):
+
 2012-01-12  Eric Seidel  <e...@webkit.org>
 
         Refactor DOMImplementation.hasFeature logic into helper functions.

Modified: trunk/Source/WebCore/Configurations/WebCore.xcconfig (104872 => 104873)


--- trunk/Source/WebCore/Configurations/WebCore.xcconfig	2012-01-12 23:57:29 UTC (rev 104872)
+++ trunk/Source/WebCore/Configurations/WebCore.xcconfig	2012-01-12 23:59:53 UTC (rev 104873)
@@ -81,7 +81,7 @@
 EXCLUDED_SOURCE_FILE_NAMES_SVG_DOM_OBJC_BINDINGS_ENABLE_SVG_DOM_OBJC_BINDINGS = ;
 
 EXCLUDED_SOURCE_FILE_NAMES = $(EXCLUDED_SOURCE_FILE_NAMES_$(REAL_PLATFORM_NAME)) $(EXCLUDED_SOURCE_FILE_NAMES_SVG_DOM_OBJC_BINDINGS);
-EXCLUDED_SOURCE_FILE_NAMES_iphoneos = *.tiff *Cursor.png Cursor.cpp CursorMac.mm EventHandlerMac.mm HTMLConverter.mm KillRingMac.mm MemoryPressureHandlerMac.mm PlatformEventFactoryMac.mm SSLKeyGeneratorMac.cpp SearchPopupMenuMac.mm WebVideoFullscreenController.mm WebVideoFullscreenHUDWindowController.mm WebWindowAnimation.mm localizedStrings.js;
+EXCLUDED_SOURCE_FILE_NAMES_iphoneos = *.tiff *Cursor.png Cursor.cpp CursorMac.mm EventHandlerMac.mm HTMLConverter.mm KillRingMac.mm PlatformEventFactoryMac.mm SSLKeyGeneratorMac.cpp SearchPopupMenuMac.mm WebVideoFullscreenController.mm WebVideoFullscreenHUDWindowController.mm WebWindowAnimation.mm localizedStrings.js;
 EXCLUDED_SOURCE_FILE_NAMES_iphonesimulator = $(EXCLUDED_SOURCE_FILE_NAMES_iphoneos);
 EXCLUDED_SOURCE_FILE_NAMES_macosx = *IOS.h *IOS.cpp *IOS.mm KillRingNone.cpp
 

Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (104872 => 104873)


--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp	2012-01-12 23:57:29 UTC (rev 104872)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp	2012-01-12 23:59:53 UTC (rev 104873)
@@ -42,7 +42,7 @@
 {
 }
 
-#if !PLATFORM(MAC) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
+#if !PLATFORM(MAC) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD) || PLATFORM(IOS)
 void MemoryPressureHandler::install() { }
 
 void MemoryPressureHandler::uninstall() { }

Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.h (104872 => 104873)


--- trunk/Source/WebCore/platform/MemoryPressureHandler.h	2012-01-12 23:57:29 UTC (rev 104872)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.h	2012-01-12 23:59:53 UTC (rev 104873)
@@ -45,6 +45,7 @@
     ~MemoryPressureHandler();
 
     void respondToMemoryPressure();
+    void releaseMemory(bool critical);
 
     bool m_installed;
     time_t m_lastRespondTime;

Modified: trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm (104872 => 104873)


--- trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm	2012-01-12 23:57:29 UTC (rev 104872)
+++ trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm	2012-01-12 23:59:53 UTC (rev 104873)
@@ -32,7 +32,7 @@
 #import <WebCore/PageCache.h>
 #import <wtf/FastMalloc.h>
 
-#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) && !PLATFORM(IOS)
 #import "WebCoreSystemInterface.h"
 #import <notify.h>
 #endif
@@ -41,6 +41,7 @@
 
 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
 
+#if !PLATFORM(IOS)
 static dispatch_source_t _cache_event_source = 0;
 static dispatch_source_t _timer_event_source = 0;
 static int _notifyToken;
@@ -114,19 +115,25 @@
 {
     holdOff(s_secondsBetweenMemoryCleanup);
 
+    releaseMemory(false);
+}
+#endif // !PLATFORM(IOS)
+
+void MemoryPressureHandler::releaseMemory(bool critical)
+{
     int savedPageCacheCapacity = pageCache()->capacity();
-    pageCache()->setCapacity(pageCache()->pageCount()/2);
+    pageCache()->setCapacity(critical ? 0 : pageCache()->pageCount() / 2);
     pageCache()->setCapacity(savedPageCacheCapacity);
     pageCache()->releaseAutoreleasedPagesNow();
 
     NSURLCache *nsurlCache = [NSURLCache sharedURLCache];
     NSUInteger savedNsurlCacheMemoryCapacity = [nsurlCache memoryCapacity];
-    [nsurlCache setMemoryCapacity:[nsurlCache currentMemoryUsage]/2];
+    [nsurlCache setMemoryCapacity:critical ? 0 : [nsurlCache currentMemoryUsage] / 2];
     [nsurlCache setMemoryCapacity:savedNsurlCacheMemoryCapacity];
- 
+
     fontCache()->purgeInactiveFontData();
 
-    memoryCache()->pruneToPercentage(0.5f);
+    memoryCache()->pruneToPercentage(critical ? 0 : 0.5f);
 
     gcController().garbageCollectNow();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to