CacheClientBlackBerry.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "config.h"
  19. #include "CacheClientBlackBerry.h"
  20. #include "MemoryCache.h"
  21. #include <BlackBerryPlatformMisc.h>
  22. #include <BlackBerryPlatformSettings.h>
  23. namespace WebCore {
  24. CacheClientBlackBerry* CacheClientBlackBerry::get()
  25. {
  26. static CacheClientBlackBerry s_cacheClient;
  27. return &s_cacheClient;
  28. }
  29. CacheClientBlackBerry::CacheClientBlackBerry()
  30. {
  31. }
  32. void CacheClientBlackBerry::initialize()
  33. {
  34. #if ENABLE(BLACKBERRY_DEBUG_MEMORY)
  35. bool isDisabled = true;
  36. #else
  37. bool isDisabled = false;
  38. #endif
  39. memoryCache()->setDisabled(isDisabled);
  40. if (!isDisabled) {
  41. // We have to set a non-zero interval to schedule cache pruning after a CachedImage becoming dead.
  42. memoryCache()->setDeadDecodedDataDeletionInterval(0.01);
  43. updateCacheCapacity();
  44. }
  45. }
  46. void CacheClientBlackBerry::updateCacheCapacity()
  47. {
  48. #if ENABLE(BLACKBERRY_DEBUG_MEMORY)
  49. // We're debugging memory usage. So keep it disabled.
  50. #else
  51. unsigned cacheTotalCapacity = 64 * 1024 * 1024;
  52. unsigned cacheMinDeadCapacity = cacheTotalCapacity / 4;
  53. unsigned cacheMaxDeadCapacity = cacheTotalCapacity / 2;
  54. memoryCache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
  55. #endif
  56. }
  57. } // WebCore