Add Tizen-platform implementation of RenderProcessObserver
authorPiotr Tworek <p.tworek@samsung.com>
Fri, 23 May 2014 22:24:51 +0000 (15:24 -0700)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Change-Id: Ifbb5fc2305c4e70b15ca85a04b7611f97a983e07

tizen_src/impl/chromium-efl.gyp
tizen_src/impl/renderer/render_process_observer_efl.cc [new file with mode: 0644]
tizen_src/impl/renderer/render_process_observer_efl.h [new file with mode: 0644]

index 38894b394a3781862a649b857713a4175b2035af..1e16101732bf998210406702c81c3ee7fb37326b 100644 (file)
@@ -53,6 +53,8 @@
       'paths_efl.h',
       'renderer/content_renderer_client_efl.cc',
       'renderer/content_renderer_client_efl.h',
+      'renderer/render_process_observer_efl.cc',
+      'renderer/render_process_observer_efl.h',
       'renderer/render_view_observer_efl.cc',
       'renderer/render_view_observer_efl.h',
       'web_contents_delegate_efl.cc',
diff --git a/tizen_src/impl/renderer/render_process_observer_efl.cc b/tizen_src/impl/renderer/render_process_observer_efl.cc
new file mode 100644 (file)
index 0000000..1b9669d
--- /dev/null
@@ -0,0 +1,83 @@
+#include "renderer/render_process_observer_efl.h"
+
+#include "base/allocator/allocator_extension.h"
+#include "content/public/renderer/render_thread.h"
+#include "third_party/WebKit/public/web/WebCache.h"
+#include "third_party/WebKit/public/web/WebCrossOriginPreflightResultCache.h"
+#include "third_party/WebKit/public/web/WebFontCache.h"
+#include "third_party/sqlite/sqlite3.h"
+#include "v8/include/v8.h"
+#include "renderer/content_renderer_client_efl.h"
+
+using blink::WebCache;
+using blink::WebFontCache;
+using blink::WebCrossOriginPreflightResultCache;
+using content::RenderThread;
+
+bool RenderProcessObserverEfl::OnControlMessageReceived(const IPC::Message& message)
+{
+  bool handled = true;
+  IPC_BEGIN_MESSAGE_MAP(RenderProcessObserverEfl, message)
+    IPC_MESSAGE_HANDLER(EflViewMsg_ClearCache, OnClearCache)
+    IPC_MESSAGE_HANDLER(EflViewMsg_SetCache, OnSetCache)
+    IPC_MESSAGE_HANDLER(EwkViewMsg_PurgeMemory, OnPurgeMemory)
+    IPC_MESSAGE_HANDLER(EwkViewMsg_SetWidgetInfo, OnWidgetInfo)
+    IPC_MESSAGE_HANDLER(EwkViewMsg_SendWrtMessage, OnWrtMessage)
+    IPC_MESSAGE_UNHANDLED(handled = false)
+  IPC_END_MESSAGE_MAP()
+  return handled;
+}
+
+void RenderProcessObserverEfl::OnWidgetInfo(int widget_id,
+                                            double scale,
+                                            const std::string &theme,
+                                            const std::string &encoded_bundle)
+{
+  content_client_->SetWidgetInfo(widget_id, scale, encoded_bundle, theme);
+}
+
+void RenderProcessObserverEfl::OnWrtMessage(const Ewk_IPC_Wrt_Message_Data& data)
+{
+  content_client_->WrtMessageReceived(data);
+}
+
+void RenderProcessObserverEfl::WebKitInitialized()
+{
+  webkit_initialized_ = true;
+  OnSetCache(pending_cache_params_);
+}
+void RenderProcessObserverEfl::OnClearCache()
+{
+  WebCache::clear();
+}
+
+void RenderProcessObserverEfl::OnSetCache(const CacheParamsEfl& params)
+{
+  pending_cache_params_ = params;
+  if(!webkit_initialized_)
+    return;
+
+  WebCache::setCapacities(static_cast<size_t>(params.cache_min_dead_capacity),
+    static_cast<size_t>(params.cache_max_dead_capacity),
+    static_cast<size_t>(params.cache_total_capacity));
+}
+
+void RenderProcessObserverEfl::OnPurgeMemory()
+{
+  RenderThread::Get()->EnsureWebKitInitialized();
+  // Clear the object cache (as much as possible; some live objects cannot be
+  // freed).
+  OnClearCache();
+  // Clear the font/glyph cache.
+  WebFontCache::clear();
+  // Clear the Cross-Origin Preflight cache.
+  blink::WebCrossOriginPreflightResultCache::clear();
+  // TODO(pk): currently web process not linking sqlite. when used this should enable
+  // Release all freeable memory from the SQLite process-global page cache (a
+  // low-level object which backs the Connection-specific page caches).
+  //while (sqlite3_release_memory(std::numeric_limits<int>::max()) > 0) {
+  //}
+  v8::V8::LowMemoryNotification();
+  // Tell our allocator to release any free pages it's still holding.
+  base::allocator::ReleaseFreeMemory();
+}
diff --git a/tizen_src/impl/renderer/render_process_observer_efl.h b/tizen_src/impl/renderer/render_process_observer_efl.h
new file mode 100644 (file)
index 0000000..f65c927
--- /dev/null
@@ -0,0 +1,39 @@
+#ifndef RENDER_PROCESS_OBSERVER_EFL_H
+#define RENDER_PROCESS_OBSERVER_EFL_H
+
+#include <string>
+#include "base/compiler_specific.h"
+#include "content/public/renderer/render_process_observer.h"
+#include "common/render_messages_efl.h"
+#include "cache_params_efl.h"
+#include "public/ewk_ipc_message.h"
+
+namespace IPC {
+class Message;
+}
+
+class ContentRendererClientEfl;
+
+class RenderProcessObserverEfl : public content::RenderProcessObserver {
+public:
+  explicit RenderProcessObserverEfl(ContentRendererClientEfl* content_client)
+      : content_client_(content_client), webkit_initialized_(false) { }
+
+  virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE;
+  virtual void WebKitInitialized() OVERRIDE;
+  void OnClearCache();
+  void OnPurgeMemory();
+  
+private:
+  void OnWidgetInfo(int widget_id,
+                    double scale,
+                    const std::string &theme,
+                    const std::string &encoded_bundle);
+  void OnSetCache(const CacheParamsEfl& params);
+  void OnWrtMessage(const Ewk_IPC_Wrt_Message_Data& data);
+  ContentRendererClientEfl* content_client_;
+  bool webkit_initialized_;
+  CacheParamsEfl pending_cache_params_;
+};
+
+#endif