Changeset 104873 in webkit


Ignore:
Timestamp:
Jan 12, 2012 3:59:53 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Patch by Yongjun Zhang <yongjun_zhang@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):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r104872 r104873  
     12012-01-12  Yongjun Zhang  <yongjun_zhang@apple.com>
     2
     3        Reviewed by Benjamin Poulain.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=75991
     6        Make the code in MemoryPressureHandler::respondToMemoryPressure shareable.
     7
     8        Move memory pressure handling code inside a new function (releaseMemory) so that
     9        we could shared it between mac and iOS.
     10
     11        * Configurations/WebCore.xcconfig: add MemoryPressureHandlerMac.mm into iOS build.
     12        * platform/MemoryPressureHandler.h:
     13        * platform/mac/MemoryPressureHandlerMac.mm:
     14        (WebCore::MemoryPressureHandler::respondToMemoryPressure):
     15        (WebCore::MemoryPressureHandler::releaseMemory):
     16
    1172012-01-12  Eric Seidel  <eric@webkit.org>
    218
  • trunk/Source/WebCore/Configurations/WebCore.xcconfig

    r103997 r104873  
    8282
    8383EXCLUDED_SOURCE_FILE_NAMES = $(EXCLUDED_SOURCE_FILE_NAMES_$(REAL_PLATFORM_NAME)) $(EXCLUDED_SOURCE_FILE_NAMES_SVG_DOM_OBJC_BINDINGS);
    84 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;
     84EXCLUDED_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;
    8585EXCLUDED_SOURCE_FILE_NAMES_iphonesimulator = $(EXCLUDED_SOURCE_FILE_NAMES_iphoneos);
    8686EXCLUDED_SOURCE_FILE_NAMES_macosx = *IOS.h *IOS.cpp *IOS.mm KillRingNone.cpp
  • trunk/Source/WebCore/platform/MemoryPressureHandler.cpp

    r97433 r104873  
    4343}
    4444
    45 #if !PLATFORM(MAC) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
     45#if !PLATFORM(MAC) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD) || PLATFORM(IOS)
    4646void MemoryPressureHandler::install() { }
    4747
  • trunk/Source/WebCore/platform/MemoryPressureHandler.h

    r97443 r104873  
    4646
    4747    void respondToMemoryPressure();
     48    void releaseMemory(bool critical);
    4849
    4950    bool m_installed;
  • trunk/Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm

    r100681 r104873  
    3333#import <wtf/FastMalloc.h>
    3434
    35 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
     35#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) && !PLATFORM(IOS)
    3636#import "WebCoreSystemInterface.h"
    3737#import <notify.h>
     
    4242#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
    4343
     44#if !PLATFORM(IOS)
    4445static dispatch_source_t _cache_event_source = 0;
    4546static dispatch_source_t _timer_event_source = 0;
     
    115116    holdOff(s_secondsBetweenMemoryCleanup);
    116117
     118    releaseMemory(false);
     119}
     120#endif // !PLATFORM(IOS)
     121
     122void MemoryPressureHandler::releaseMemory(bool critical)
     123{
    117124    int savedPageCacheCapacity = pageCache()->capacity();
    118     pageCache()->setCapacity(pageCache()->pageCount()/2);
     125    pageCache()->setCapacity(critical ? 0 : pageCache()->pageCount() / 2);
    119126    pageCache()->setCapacity(savedPageCacheCapacity);
    120127    pageCache()->releaseAutoreleasedPagesNow();
     
    122129    NSURLCache *nsurlCache = [NSURLCache sharedURLCache];
    123130    NSUInteger savedNsurlCacheMemoryCapacity = [nsurlCache memoryCapacity];
    124     [nsurlCache setMemoryCapacity:[nsurlCache currentMemoryUsage]/2];
     131    [nsurlCache setMemoryCapacity:critical ? 0 : [nsurlCache currentMemoryUsage] / 2];
    125132    [nsurlCache setMemoryCapacity:savedNsurlCacheMemoryCapacity];
    126  
     133
    127134    fontCache()->purgeInactiveFontData();
    128135
    129     memoryCache()->pruneToPercentage(0.5f);
     136    memoryCache()->pruneToPercentage(critical ? 0 : 0.5f);
    130137
    131138    gcController().garbageCollectNow();
Note: See TracChangeset for help on using the changeset viewer.