BlackBerryGlobal.cpp [plain text]
#include "config.h"
#include "BlackBerryGlobal.h"
#include "ApplicationCacheStorage.h"
#include "CacheClientBlackBerry.h"
#include "CookieManager.h"
#include "CrossOriginPreflightResultCache.h"
#include "FontCache.h"
#include "ImageSource.h"
#include "InitializeThreading.h"
#include "JSDOMWindow.h"
#include "JSGlobalData.h"
#include "Logging.h"
#include "MainThread.h"
#include "MemoryCache.h"
#include "NetworkStateNotifier.h"
#include "PageCache.h"
#include "PageGroup.h"
#include "TextureCacheCompositingThread.h"
#include "WebString.h"
#include "bindings/js/GCController.h"
#include "runtime/JSLock.h"
#include <BlackBerryPlatformExecutableMessage.h>
#include <BlackBerryPlatformMessageClient.h>
#include <BlackBerryPlatformSettings.h>
using namespace WebCore;
namespace BlackBerry {
namespace WebKit {
static bool gIsGlobalInitialized = false;
void globalInitialize()
{
if (gIsGlobalInitialized)
return;
gIsGlobalInitialized = true;
#if ENABLE(BLACKBERRY_DEBUG_MEMORY)
blackberryDebugInitialize();
#endif
initializeLoggingChannelsIfNecessary();
JSC::initializeThreading();
WTF::initializeMainThread();
PageGroup::setShouldTrackVisitedLinks(true);
CacheClientBlackBerry::get()->initialize();
BlackBerry::Platform::Settings* settings = BlackBerry::Platform::Settings::get();
ImageSource::setMaxPixelsPerDecodedImage(settings->maxPixelsPerDecodedImage());
}
void collectJavascriptGarbageNow()
{
if (gIsGlobalInitialized)
gcController().garbageCollectNow();
}
void clearCookieCache()
{
cookieManager().removeAllCookies(RemoveFromBackingStore);
}
#if USE(ACCELERATED_COMPOSITING)
static void clearMemoryCachesInCompositingThread()
{
textureCacheCompositingThread()->prune(0);
}
#endif
void clearMemoryCaches()
{
#if USE(ACCELERATED_COMPOSITING)
BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchMessage(BlackBerry::Platform::createFunctionCallMessage(clearMemoryCachesInCompositingThread));
#endif
{
JSC::JSLock lock(JSC::SilenceAssertionsOnly);
JSC::releaseExecutableMemory(*JSDOMWindow::commonJSGlobalData());
}
int capacity = pageCache()->capacity();
pageCache()->setCapacity(0);
pageCache()->setCapacity(capacity);
pageCache()->releaseAutoreleasedPagesNow();
CrossOriginPreflightResultCache::shared().empty();
if (!memoryCache()->disabled()) {
memoryCache()->setCapacities(0, 0, 0);
CacheClientBlackBerry::get()->updateCacheCapacity();
}
fontCache()->invalidate();
}
void clearAppCache(const WebString& pageGroupName)
{
cacheStorage().empty();
}
void clearDatabase(const WebString& pageGroupName)
{
}
void updateOnlineStatus(bool online)
{
networkStateNotifier().networkStateChange(online);
}
}
}