// 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
#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 {
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;
}
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,
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
}
#endif
-#if BUILDFLAG(IS_TIZEN_TV)
- void UpdateMaxCacheSize();
- bool AlreadyUpdate() { return already_update_; }
-#endif
-
private:
class SimpleIterator;
friend class SimpleIterator;
#if BUILDFLAG(IS_ANDROID)
ApplicationStatusListenerGetter app_status_listener_getter_;
#endif
-#if BUILDFLAG(IS_TIZEN_TV)
- bool already_update_ = false;
-#endif
};
} // namespace disk_cache
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()));
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