1 #include "renderer/render_process_observer_efl.h"
3 #include "base/allocator/allocator_extension.h"
4 #include "content/public/renderer/render_thread.h"
5 #include "third_party/WebKit/public/web/WebCache.h"
6 #include "third_party/sqlite/sqlite3.h"
7 #include "v8/include/v8.h"
8 #include "renderer/content_renderer_client_efl.h"
10 // XXX: config.h needs to be included before internal blink headers.
11 // XXX2: It'd be great if we did not include internal blibk headers.
12 #include "third_party/WebKit/Source/config.h"
13 #include "third_party/WebKit/Source/platform/fonts/FontCache.h"
16 using blink::WebCache;
17 using content::RenderThread;
19 bool RenderProcessObserverEfl::OnControlMessageReceived(const IPC::Message& message)
22 IPC_BEGIN_MESSAGE_MAP(RenderProcessObserverEfl, message)
23 IPC_MESSAGE_HANDLER(EflViewMsg_ClearCache, OnClearCache)
24 IPC_MESSAGE_HANDLER(EflViewMsg_SetCache, OnSetCache)
25 IPC_MESSAGE_HANDLER(EwkViewMsg_PurgeMemory, OnPurgeMemory)
26 IPC_MESSAGE_HANDLER(EwkViewMsg_SetWidgetInfo, OnWidgetInfo)
27 IPC_MESSAGE_HANDLER(EwkViewMsg_SendWrtMessage, OnWrtMessage)
28 IPC_MESSAGE_UNHANDLED(handled = false)
33 void RenderProcessObserverEfl::OnWidgetInfo(int widget_id,
35 const std::string &theme,
36 const std::string &encoded_bundle)
38 content_client_->SetWidgetInfo(widget_id, scale, encoded_bundle, theme);
41 void RenderProcessObserverEfl::OnWrtMessage(const tizen_webview::WrtIpcMessageData& data)
43 content_client_->WrtMessageReceived(data);
46 void RenderProcessObserverEfl::WebKitInitialized()
48 webkit_initialized_ = true;
49 OnSetCache(pending_cache_params_);
51 void RenderProcessObserverEfl::OnClearCache()
56 void RenderProcessObserverEfl::OnSetCache(const CacheParamsEfl& params)
58 pending_cache_params_ = params;
59 if(!webkit_initialized_)
62 WebCache::setCapacities(static_cast<size_t>(params.cache_min_dead_capacity),
63 static_cast<size_t>(params.cache_max_dead_capacity),
64 static_cast<size_t>(params.cache_total_capacity));
67 void RenderProcessObserverEfl::OnPurgeMemory()
69 RenderThread::Get()->EnsureWebKitInitialized();
70 // Clear the object cache (as much as possible; some live objects cannot be
73 // Clear the font/glyph cache.
74 blink::FontCache::fontCache()->invalidate();
75 // TODO(pk): currently web process not linking sqlite. when used this should enable
76 // Release all freeable memory from the SQLite process-global page cache (a
77 // low-level object which backs the Connection-specific page caches).
78 //while (sqlite3_release_memory(std::numeric_limits<int>::max()) > 0) {
80 v8::Isolate::GetCurrent()->LowMemoryNotification();
81 // Tell our allocator to release any free pages it's still holding.
82 base::allocator::ReleaseFreeMemory();