[M108 Migration] Remove deprecated codes in WebCacheManagerEfl 92/288192/3
authorayush.k123 <ayush.k123@samsung.com>
Mon, 13 Feb 2023 08:17:02 +0000 (13:47 +0530)
committerBot Blink <blinkbot@samsung.com>
Tue, 14 Feb 2023 10:59:09 +0000 (10:59 +0000)
Some values are deprecated in WebCacheManager as below.
- min_dead_capacity
- max_dead_capacity
- dead_decoded_data_deletion_interval
- page_cache_capacity,
- url_cache_memory_capacity
- url_cache_disk_capacity

This patch removes deprecated variables in WebCacheManagerEfl
and clean up codes.

Reference: https://review.tizen.org/gerrit/281102/

Change-Id: Iecbeb9999fc1ea51a34b101348eee272a96fb7d7
Signed-off-by: ayush.k123 <ayush.k123@samsung.com>
tizen_src/ewk/efl_integration/BUILD.gn
tizen_src/ewk/efl_integration/browser/web_cache_efl/web_cache_manager_efl.cc
tizen_src/ewk/efl_integration/browser/web_cache_efl/web_cache_manager_efl.h
tizen_src/ewk/efl_integration/common/cache_params_efl.h [deleted file]
tizen_src/ewk/efl_integration/common/render_messages_ewk.h
tizen_src/ewk/efl_integration/renderer/render_thread_observer_efl.cc
tizen_src/ewk/efl_integration/renderer/render_thread_observer_efl.h

index 4dddf77..a9c6b68 100755 (executable)
@@ -343,7 +343,6 @@ shared_library("chromium-ewk") {
     "browser/webdata/web_data_service.h",
     "browser/webdata/web_data_service_factory.cc",
     "browser/webdata/web_data_service_factory.h",
-    "common/cache_params_efl.h",
     "common/content_client_efl.cc",
     "common/content_client_efl.h",
     "common/content_switches_efl.cc",
index 8891470..af2ef87 100644 (file)
@@ -6,7 +6,6 @@
 
 #include "base/logging.h"
 #include "base/system/sys_info.h"
-#include "common/cache_params_efl.h"
 #include "common/render_messages_ewk.h"
 #include "content/public/browser/browser_context.h"
 #include "content/public/browser/notification_service.h"
 
 WebCacheManagerEfl::WebCacheManagerEfl(content::BrowserContext* browser_context)
     : browser_context_(browser_context),
-      cache_model_(EWK_CACHE_MODEL_DOCUMENT_VIEWER)
-{
+      cache_model_(EWK_CACHE_MODEL_DOCUMENT_VIEWER) {
   registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED,
                  content::NotificationService::AllBrowserContextsAndSources());
   registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
                  content::NotificationService::AllBrowserContextsAndSources());
 }
 
-WebCacheManagerEfl::~WebCacheManagerEfl() { }
+WebCacheManagerEfl::~WebCacheManagerEfl() {}
 
 void WebCacheManagerEfl::Observe(int type,
-                              const content::NotificationSource& source,
-                              const content::NotificationDetails& details)
-{
+                                 const content::NotificationSource& source,
+                                 const content::NotificationDetails& details) {
   content::RenderProcessHost* process =
-            content::Source<content::RenderProcessHost>(source).ptr();
+      content::Source<content::RenderProcessHost>(source).ptr();
   DCHECK(process);
   if (process->GetBrowserContext() != browser_context_)
     return;
@@ -53,225 +50,76 @@ void WebCacheManagerEfl::Observe(int type,
   }
 }
 
-void WebCacheManagerEfl::ClearCache()
-{
-  for (std::set<int>::const_iterator iter = renderers_.begin();
-      iter != renderers_.end(); ++iter) {
-    content::RenderProcessHost* host = content::RenderProcessHost::FromID(*iter);
+void WebCacheManagerEfl::ClearCache() {
+  for (int id : renderers_) {
+    content::RenderProcessHost* host = content::RenderProcessHost::FromID(id);
     if (host)
       host->Send(new EflViewMsg_ClearCache());
   }
 }
 
-void WebCacheManagerEfl::SetRenderProcessCacheModel(Ewk_Cache_Model model, int render_process_id)
-{
+void WebCacheManagerEfl::SetRenderProcessCacheModel(Ewk_Cache_Model model,
+                                                    int render_process_id) {
   DCHECK(render_process_id);
   DCHECK(renderers_.find(render_process_id) != renderers_.end());
-  content::RenderProcessHost* host = content::RenderProcessHost::FromID(render_process_id);
+  content::RenderProcessHost* host =
+      content::RenderProcessHost::FromID(render_process_id);
   if (host)
-    host->Send(new EflViewMsg_SetCache(GetCacheParamsFromModel(model)));
+    host->Send(new EflViewMsg_SetCache(GetCacheTotalCapacity(model)));
 }
 
-void WebCacheManagerEfl::SetCacheModel(Ewk_Cache_Model model)
-{
+void WebCacheManagerEfl::SetCacheModel(Ewk_Cache_Model model) {
   cache_model_ = model;
-  CacheParamsEfl cache_params = GetCacheParamsFromModel(model);
-  for (std::set<int>::const_iterator iter = renderers_.begin();
-          iter != renderers_.end(); ++iter) {
-    content::RenderProcessHost* host = content::RenderProcessHost::FromID(*iter);
+  int64_t cache_total_capacity = GetCacheTotalCapacity(model);
+  for (int id : renderers_) {
+    content::RenderProcessHost* host = content::RenderProcessHost::FromID(id);
     if (host)
-      host->Send(new EflViewMsg_SetCache(cache_params));
+      host->Send(new EflViewMsg_SetCache(cache_total_capacity));
   }
 }
 
-CacheParamsEfl WebCacheManagerEfl::GetCacheParamsFromModel(Ewk_Cache_Model cache_model)
-{
-  int64_t mem_size = base::SysInfo::AmountOfPhysicalMemory();
-  // in chromium the limiting parameter is max file size of network cache
-  // which is set at the time of creation of backend.
-  // backend could be completely in-memory as well.
-  // in WK2/Tizen, it is free space on disk
-  // So, we are using free space available on browser_context path
-  // we dont set it on renderer side anyway.
-  int64_t disk_free_size = base::SysInfo::AmountOfFreeDiskSpace(browser_context_->GetPath());
-  int64_t cache_min_dead_capacity = 0;
-  int64_t cache_max_dead_capacity = 0;
-  int64_t cache_total_capacity = 0;
-  double dead_decoded_data_deletion_interval = 0;
-  int64_t page_cache_capacity = 0;
+int64_t WebCacheManagerEfl::GetCacheTotalCapacity(Ewk_Cache_Model cache_model) {
+  int64_t memory_size = base::SysInfo::AmountOfPhysicalMemory();
 
-  int64_t url_cache_memory_capacity = 0;
-  int64_t url_cache_disk_capacity = 0;
-
-  // We have taken this calculation from WK2.
-  // Except that, we are using pointers instead of reference for output.
-  // We don't use page_cache_capacity. NavigationControllerImpl has
-  // kMaxSessionHistoryEntries = 50 for back/forward list.
-  // url_cache_memory_capacity, url_cache_disk_capacity seem to be parts of
-  // network layer. disk_cache::CreateCacheBackend gets size while creation.
-  // Could not find anything to modify it on-the-fly.
-  // m_deadDecodedDataDeletionInterval is unused variable in MemoryCache.cpp in
-  // WK2 CachedResource uses this to start timer.
-  // So, We are using only cache_total_capacity, cache_min_dead_capacity, and
-  // cache_max_dead_capacity. This is same as Chromium cache manager implementation
-  // But we are using following calculation instead of dynamic strategy used in Chromium.
-  CalculateCacheSizes(cache_model, mem_size, disk_free_size,
-                      &cache_total_capacity, &cache_min_dead_capacity, &cache_max_dead_capacity,
-                      &dead_decoded_data_deletion_interval, &page_cache_capacity,
-                      &url_cache_memory_capacity, &url_cache_disk_capacity);
-  CacheParamsEfl cache_params;
-  cache_params.cache_max_dead_capacity = cache_max_dead_capacity;
-  cache_params.cache_min_dead_capacity = cache_min_dead_capacity;
-  cache_params.cache_total_capacity = cache_total_capacity;
-  return cache_params;
-}
-
-// taken from WK2/Tizen
-// static
-void WebCacheManagerEfl::CalculateCacheSizes(Ewk_Cache_Model cache_model, int64_t memory_size, int64_t disk_free_size,
-    int64_t* cache_total_capacity, int64_t* cache_min_dead_capacity,
-    int64_t* cache_max_dead_capacity, double* dead_decoded_data_deletion_interval,
-    int64_t* page_cache_capacity, int64_t* url_cache_memory_capacity,
-    int64_t* url_cache_disk_capacity)
-{
   switch (cache_model) {
-  case EWK_CACHE_MODEL_DOCUMENT_VIEWER: {
-      // Object cache capacities (in bytes)
-      if (memory_size >= 2048)
-        *cache_total_capacity = 96 * 1024 * 1024;
-      else if (memory_size >= 1536)
-        *cache_total_capacity = 64 * 1024 * 1024;
-      else if (memory_size >= 1024)
-        *cache_total_capacity = 32 * 1024 * 1024;
-      else if (memory_size >= 512)
-        *cache_total_capacity = 16 * 1024 * 1024;
-
-      *cache_min_dead_capacity = 0;
-      *cache_max_dead_capacity = 0;
-
-      // Foundation memory cache capacity (in bytes)
-      *url_cache_memory_capacity = 0;
-
-      // Foundation disk cache capacity (in bytes)
-      *url_cache_disk_capacity = 0;
-
-    break;
-  }
-  case EWK_CACHE_MODEL_DOCUMENT_BROWSER: {
-    // Page cache capacity (in pages)
-    if (memory_size >= 1024)
-      *page_cache_capacity = 3;
-    else if (memory_size >= 512)
-      *page_cache_capacity = 2;
-    else if (memory_size >= 256)
-      *page_cache_capacity = 1;
-    else
-      *page_cache_capacity = 0;
-
+    case EWK_CACHE_MODEL_DOCUMENT_VIEWER:
+    case EWK_CACHE_MODEL_DOCUMENT_BROWSER:
       // Object cache capacities (in bytes)
       if (memory_size >= 2048)
-        *cache_total_capacity = 96 * 1024 * 1024;
+        return 96 * 1024 * 1024;
       else if (memory_size >= 1536)
-        *cache_total_capacity = 64 * 1024 * 1024;
+        return 64 * 1024 * 1024;
       else if (memory_size >= 1024)
-        *cache_total_capacity = 32 * 1024 * 1024;
+        return 32 * 1024 * 1024;
       else if (memory_size >= 512)
-        *cache_total_capacity = 16 * 1024 * 1024;
-
-      *cache_min_dead_capacity = *cache_total_capacity / 8;
-      *cache_max_dead_capacity = *cache_total_capacity / 4;
-
-      // Foundation memory cache capacity (in bytes)
-      if (memory_size >= 2048)
-        *url_cache_memory_capacity = 4 * 1024 * 1024;
-      else if (memory_size >= 1024)
-        *url_cache_memory_capacity = 2 * 1024 * 1024;
-      else if (memory_size >= 512)
-        *url_cache_memory_capacity = 1 * 1024 * 1024;
-      else
-        *url_cache_memory_capacity =      512 * 1024;
-
-      // Foundation disk cache capacity (in bytes)
-      if (disk_free_size >= 16384)
-        *url_cache_disk_capacity = 50 * 1024 * 1024;
-      else if (disk_free_size >= 8192)
-        *url_cache_disk_capacity = 40 * 1024 * 1024;
-      else if (disk_free_size >= 4096)
-        *url_cache_disk_capacity = 30 * 1024 * 1024;
-      else
-        *url_cache_disk_capacity = 20 * 1024 * 1024;
-    break;
-  }// CacheModelDocumentBrowser
-
-  case EWK_CACHE_MODEL_PRIMARY_WEBBROWSER: {
-    // Page cache capacity (in pages)
-    // (Research indicates that value / page drops substantially after 3 pages.)
-    if (memory_size >= 2048)
-      *page_cache_capacity = 5;
-    else if (memory_size >= 1024)
-      *page_cache_capacity = 4;
-    else if (memory_size >= 512)
-      *page_cache_capacity = 3;
-    else if (memory_size >= 256)
-      *page_cache_capacity = 2;
-    else
-      *page_cache_capacity = 1;
+        return 16 * 1024 * 1024;
+      break;
 
+    case EWK_CACHE_MODEL_PRIMARY_WEBBROWSER:
       // Object cache capacities (in bytes)
       // (Testing indicates that value / MB depends heavily on content and
       // browsing pattern. Even growth above 128MB can have substantial
       // value / MB for some content / browsing patterns.)
       if (memory_size >= 2048)
-        *cache_total_capacity = 128 * 1024 * 1024;
+        return 128 * 1024 * 1024;
+      /* LCOV_EXCL_START */
       else if (memory_size >= 1536)
-        *cache_total_capacity = 96 * 1024 * 1024;
+        return 96 * 1024 * 1024;
       else if (memory_size >= 1024)
-        *cache_total_capacity = 64 * 1024 * 1024;
+        return 64 * 1024 * 1024;
       else if (memory_size >= 512)
-        *cache_total_capacity = 32 * 1024 * 1024;
-
-      *cache_min_dead_capacity = *cache_total_capacity / 4;
-      *cache_max_dead_capacity = *cache_total_capacity / 2;
-
-      // This code is here to avoid a PLT regression. We can remove it if we
-      // can prove that the overall system gain would justify the regression.
-      *cache_max_dead_capacity = std::max(static_cast<int64_t>(24), *cache_max_dead_capacity);
-
-      *dead_decoded_data_deletion_interval = 60;
-
-      // Foundation memory cache capacity (in bytes)
-      // (These values are small because WebCore does most caching itself.)
-      if (memory_size >= 1024)
-        *url_cache_memory_capacity = 4 * 1024 * 1024;
-      else if (memory_size >= 512)
-        *url_cache_memory_capacity = 2 * 1024 * 1024;
-      else if (memory_size >= 256)
-        *url_cache_memory_capacity = 1 * 1024 * 1024;
-      else
-        *url_cache_memory_capacity =      512 * 1024;
-
-      // Foundation disk cache capacity (in bytes)
-      if (disk_free_size >= 16384)
-        *url_cache_disk_capacity = 175 * 1024 * 1024;
-      else if (disk_free_size >= 8192)
-        *url_cache_disk_capacity = 150 * 1024 * 1024;
-      else if (disk_free_size >= 4096)
-        *url_cache_disk_capacity = 125 * 1024 * 1024;
-      else if (disk_free_size >= 2048)
-        *url_cache_disk_capacity = 100 * 1024 * 1024;
-      else if (disk_free_size >= 1024)
-        *url_cache_disk_capacity = 75 * 1024 * 1024;
-      else
-        *url_cache_disk_capacity = 50 * 1024 * 1024;
-
+        return 32 * 1024 * 1024;
+      /* LCOV_EXCL_STOP */
       break;
-    }
     default:
        NOTREACHED();
        break;
   };
+  return 0;
 }
-void WebCacheManagerEfl::SetBrowserContext(content::BrowserContext* browser_context) {
+
+void WebCacheManagerEfl::SetBrowserContext(
+    content::BrowserContext* browser_context) {
   DCHECK(!browser_context_);
   browser_context_ = browser_context;
 }
index 9a6c3b8..23ca48b 100644 (file)
@@ -16,7 +16,6 @@
 namespace content {
 class BrowserContext;
 }
-struct CacheParamsEfl;
 
 class WebCacheManagerEfl : public content::NotificationObserver {
  public:
@@ -36,13 +35,7 @@ class WebCacheManagerEfl : public content::NotificationObserver {
   void SetBrowserContext(content::BrowserContext* browser_context);
 
  private:
-  static void CalculateCacheSizes(Ewk_Cache_Model cache_model, int64_t memory_size, int64_t disk_free_size,
-      int64_t* cache_total_capacity, int64_t* cache_min_dead_capacity,
-      int64_t* cache_max_dead_capacity, double* dead_decoded_data_deletion_interval,
-      int64_t* page_cache_capacity, int64_t* url_cache_memory_capacity,
-      int64_t* url_cache_disk_capacity);
-
-  CacheParamsEfl GetCacheParamsFromModel(Ewk_Cache_Model);
+  int64_t GetCacheTotalCapacity(Ewk_Cache_Model);
   void SetRenderProcessCacheModel(Ewk_Cache_Model model, int render_process_id);
 
   content::NotificationRegistrar registrar_;
diff --git a/tizen_src/ewk/efl_integration/common/cache_params_efl.h b/tizen_src/ewk/efl_integration/common/cache_params_efl.h
deleted file mode 100644 (file)
index 67ed66d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2014 Samsung Electronics. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CACHE_PARAMS_EFL_H_
-#define CACHE_PARAMS_EFL_H_
-
-struct CacheParamsEfl {
-  int64_t cache_total_capacity;
-  int64_t cache_min_dead_capacity;
-  int64_t cache_max_dead_capacity;
-#if 0
-  double dead_decoded_data_deletion_interval;
-  int64 page_cache_capacity;
-  int64 url_cache_memory_capacity;
-  int64 url_cache_disk_capacity;
-#endif
-};
-
-#endif /* CACHE_PARAMS_EFL_H_ */
index ffd731a..b6e2c36 100644 (file)
@@ -5,7 +5,6 @@
 // Multiply-included file, no traditional include guard.
 
 #include "base/values.h"
-#include "common/cache_params_efl.h"
 #include "common/hit_test_params.h"
 #include "common/navigation_policy_params.h"
 #include "common/print_pages_params.h"
@@ -75,12 +74,6 @@ IPC_STRUCT_TRAITS_BEGIN(DidPrintPagesParams)
   IPC_STRUCT_TRAITS_MEMBER(filename)
 IPC_STRUCT_TRAITS_END()
 
-IPC_STRUCT_TRAITS_BEGIN(CacheParamsEfl)
-  IPC_STRUCT_TRAITS_MEMBER(cache_total_capacity)
-  IPC_STRUCT_TRAITS_MEMBER(cache_min_dead_capacity)
-  IPC_STRUCT_TRAITS_MEMBER(cache_max_dead_capacity)
-IPC_STRUCT_TRAITS_END()
-
 IPC_ENUM_TRAITS(blink::WebNavigationPolicy)
 IPC_ENUM_TRAITS(blink::WebNavigationType)
 
@@ -133,9 +126,7 @@ IPC_MESSAGE_ROUTED1(EwkHostMsg_DidPrintPagesToPdf,
                     DidPrintPagesParams /* pdf document parameters */)
 
 IPC_MESSAGE_CONTROL0(EflViewMsg_ClearCache)
-IPC_MESSAGE_CONTROL1(EflViewMsg_SetCache,
-                     CacheParamsEfl)
-
+IPC_MESSAGE_CONTROL1(EflViewMsg_SetCache, int64_t /* cache_total_capacity */)
 IPC_MESSAGE_ROUTED3(EwkViewMsg_PrintToPdf,
                     int, /* width */
                     int, /* height */
index 5b789ea..db31c3f 100644 (file)
@@ -55,14 +55,8 @@ void RenderThreadObserverEfl::OnClearCache()
   WebCache::Clear();
 }
 
-void RenderThreadObserverEfl::OnSetCache(const CacheParamsEfl& params)
-{
-#if !defined(EWK_BRINGUP)  // FIXME: m67 bringup
-  // FIXME: ‘setCapacities’ is not a member of ‘blink::WebCache’
-  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));
-#endif
+void RenderThreadObserverEfl::OnSetCache(int64_t cache_total_capacity) {
+  WebCache::SetCapacity(static_cast<size_t>(cache_total_capacity));
 }
 
 void RenderThreadObserverEfl::OnSetExtensibleAPI(const std::string& api_name,
index eb7ead7..8f95e3a 100644 (file)
@@ -9,7 +9,6 @@
 #include <string>
 
 #include "base/compiler_specific.h"
-#include "common/cache_params_efl.h"
 #include "content/public/renderer/render_thread_observer.h"
 
 namespace IPC {
@@ -25,7 +24,7 @@ public:
   void OnClearCache();
 
 private:
-  void OnSetCache(const CacheParamsEfl& params);
+  void OnSetCache(int64_t cache_total_capacity);
   ContentRendererClientEfl* content_client_;
   void OnSetExtensibleAPI(const std::string& api_name, bool enable);
   void OnUpdateTizenExtensible(const std::map<std::string, bool>& params);