Revert "[VD] TV customization of Simple Disk Cache" 64/320464/2
authorDan Zhao <danys.zhao@samsung.com>
Fri, 15 Nov 2024 11:27:59 +0000 (11:27 +0000)
committerBot Blink <blinkbot@samsung.com>
Fri, 15 Nov 2024 12:30:32 +0000 (12:30 +0000)
This reverts commit 16fab15c909948482d241cd69c684e42b16257d3.

Change-Id: I2a1b6a6ee5e67b419be966c0c30017955df984d4

net/disk_cache/cache_util.h
net/disk_cache/cache_util_posix.cc
net/disk_cache/simple/simple_backend_impl.cc
net/disk_cache/simple/simple_backend_impl.h
net/disk_cache/simple/simple_entry_impl.cc
net/disk_cache/simple/simple_index_file.h

index c03fdc6beac8c57b2f60a33ebaebb2ee719f8b2e..69bf2f52808f061ee2bb27f1534c6a92193cf3ba 100644 (file)
@@ -66,9 +66,6 @@ int CalculateWebAppCacheSize(const base::FilePath& path, net::CacheType type);
 // Web apps disk cache path prefix.
 const char kTizenAppCache[] = "WebAppsCache";
 const char kIndexName[] = "index";
-const char kCacheDataDirectoryName[] = "Cache_Data";
-const char kIndexDir[] = "index-dir";
-const char kSimpleIndexName[] = "the-real-index";
 #endif
 
 // The default cache size should not ideally be exposed, but the blockfile
index 962c61bcb15ba93987a5271d04824e366b988583..024c7a1fe42021f5994228ff760fd1f471a27fdd 100644 (file)
@@ -12,7 +12,6 @@
 
 #if BUILDFLAG(IS_TIZEN_TV)
 #include "net/disk_cache/blockfile/disk_format.h"
-#include "net/disk_cache/simple/simple_index_file.h"
 #endif
 
 namespace disk_cache {
@@ -100,18 +99,16 @@ int CalculateWebAppCacheSize(const base::FilePath& path, net::CacheType type) {
     return -1;
 
   int total = 0;
-  base::FileEnumerator iter(path.DirName().DirName(), false,
+  base::FileEnumerator iter(path.DirName(), false,
                             base::FileEnumerator::DIRECTORIES);
   for (base::FilePath app_name = iter.Next(); !app_name.value().empty();
        app_name = iter.Next()) {
-    base::FilePath cache_path = app_name.Append(kCacheDataDirectoryName);
-    base::FilePath index_dir_path = cache_path.Append(kIndexDir);
-    base::FilePath index_path = index_dir_path.Append(kSimpleIndexName);
-    disk_cache::SimpleIndexHeader header;
+    base::FilePath index_path = app_name.Append(kIndexName);
+    disk_cache::IndexHeader header;
     if (!ReadHeader(index_path, reinterpret_cast<char*>(&header),
                     sizeof(header)))
       continue;
-    total += (header.cache_size >> 32);
+    total += header.num_bytes;
   }
 
   return total;
index b0000c84234ae33323675b64c94175393d3e402d..41dddb9f4a2e8f4adecacb0fed58c5652bc5505c 100644 (file)
@@ -247,14 +247,6 @@ void SimpleBackendImpl::SetTaskRunnerForTesting(
 }
 
 void SimpleBackendImpl::Init(CompletionOnceCallback completion_callback) {
-#if BUILDFLAG(IS_TIZEN_TV)
-  int life_time = disk_cache::GetMemoryLifeTime();
-  if (life_time <= 0 || life_time > 5) {
-    LOG(ERROR) << "MemoryLifeTime was dangerous for using cache, life_time : "
-               << life_time;
-    return;
-  }
-#endif
   auto index_task_runner = base::ThreadPool::CreateSequencedTaskRunner(
       {base::MayBlock(), base::WithBaseSyncPrimitives(),
        base::TaskPriority::USER_BLOCKING,
@@ -890,25 +882,4 @@ uint32_t SimpleBackendImpl::GetNewEntryPriority(
          entry_count_++;
 }
 
-#if BUILDFLAG(IS_TIZEN_TV)
-void SimpleBackendImpl::UpdateMaxCacheSize() {
-  int used_size = CalculateWebAppCacheSize(path_, GetCacheType());
-  if (used_size == -1)
-    return;
-  uint64_t cur_app_cache_size = index()->GetCacheSize();
-  if (used_size < orig_max_size_) {
-    orig_max_size_ = orig_max_size_ - used_size + cur_app_cache_size;
-  } else if (cur_app_cache_size * 2 >= orig_max_size_) {
-    orig_max_size_ =
-        (cur_app_cache_size > orig_max_size_ ? orig_max_size_
-                                             : cur_app_cache_size) /
-        2;
-  } else {
-    orig_max_size_ = cur_app_cache_size;
-  }
-  already_update_ = true;
-  index_->SetMaxSize(orig_max_size_);
-}
-#endif
-
 }  // namespace disk_cache
index 8bb1b39989af3e1ac7edc61b5f8dc187ca2f8db6..cde0eeebd8225413cdbf12a2a61bc519fc95646b 100644 (file)
@@ -150,11 +150,6 @@ class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend,
   }
 #endif
 
-#if BUILDFLAG(IS_TIZEN_TV)
-  void UpdateMaxCacheSize();
-  bool AlreadyUpdate() { return already_update_; }
-#endif
-
  private:
   class SimpleIterator;
   friend class SimpleIterator;
@@ -287,9 +282,6 @@ class NET_EXPORT_PRIVATE SimpleBackendImpl : public Backend,
 #if BUILDFLAG(IS_ANDROID)
   ApplicationStatusListenerGetter app_status_listener_getter_;
 #endif
-#if BUILDFLAG(IS_TIZEN_TV)
-  bool already_update_ = false;
-#endif
 };
 
 }  // namespace disk_cache
index 3b25e332247818df3ce3542d95e69eea79c5b550..6aaeabbffc55926a09a420db2516d967d404cbcc 100644 (file)
@@ -1647,11 +1647,6 @@ void SimpleEntryImpl::UpdateDataFromEntryStat(
   sparse_data_size_ = entry_stat.sparse_data_size();
 
   SimpleBackendImpl* backend_ptr = backend_.get();
-#if BUILDFLAG(IS_TIZEN_TV)
-  if (backend_ptr->index()->initialized() && !backend_ptr->AlreadyUpdate()) {
-    backend_ptr->UpdateMaxCacheSize();
-  }
-#endif
   if (doom_state_ == DOOM_NONE && backend_ptr) {
     backend_ptr->index()->UpdateEntrySize(
         entry_hash_, base::checked_cast<uint32_t>(GetDiskUsage()));
index efc9cb6ece10ad44bd1e32aae19c3594d77b1171..fed23c50c527f59d9c5e12317892b3d7ba18d1fa 100644 (file)
@@ -41,21 +41,6 @@ struct NET_EXPORT_PRIVATE SimpleIndexLoadResult {
   bool flush_required = false;
 };
 
-// Header for the master index file.
-struct NET_EXPORT_PRIVATE SimpleIndexHeader {
-  SimpleIndexHeader() {
-    memset(this, 0, sizeof(*this));
-    magic_number = kSimpleIndexMagicNumber;
-    version = kSimpleVersion;
-  }
-
-  uint64_t magic_number;
-  uint32_t version;
-  SimpleIndex::IndexWriteToDiskReason reason;
-  uint64_t entry_count;
-  uint64_t cache_size;  // Total cache storage size in bytes.
-};
-
 // Simple Index File format is a pickle of IndexMetadata and EntryMetadata
 // objects. The file format is as follows: one instance of |IndexMetadata|
 // followed by |EntryMetadata| repeated |entry_count| times. To learn more about