Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
flutter::ResourceCacheLimitCalculator Class Reference

#include <resource_cache_limit_calculator.h>

Public Member Functions

 ResourceCacheLimitCalculator (size_t max_bytes_threshold)
 
 ~ResourceCacheLimitCalculator ()=default
 
void AddResourceCacheLimitItem (const fml::WeakPtr< ResourceCacheLimitItem > &item)
 
size_t GetResourceCacheMaxBytes ()
 

Detailed Description

Definition at line 25 of file resource_cache_limit_calculator.h.

Constructor & Destructor Documentation

◆ ResourceCacheLimitCalculator()

flutter::ResourceCacheLimitCalculator::ResourceCacheLimitCalculator ( size_t  max_bytes_threshold)
inlineexplicit

Definition at line 27 of file resource_cache_limit_calculator.h.

28 : max_bytes_threshold_(max_bytes_threshold) {}

◆ ~ResourceCacheLimitCalculator()

flutter::ResourceCacheLimitCalculator::~ResourceCacheLimitCalculator ( )
default

Member Function Documentation

◆ AddResourceCacheLimitItem()

void flutter::ResourceCacheLimitCalculator::AddResourceCacheLimitItem ( const fml::WeakPtr< ResourceCacheLimitItem > &  item)
inline

Definition at line 33 of file resource_cache_limit_calculator.h.

34 {
35 items_.push_back(item);
36 }

◆ GetResourceCacheMaxBytes()

size_t flutter::ResourceCacheLimitCalculator::GetResourceCacheMaxBytes ( )

Definition at line 9 of file resource_cache_limit_calculator.cc.

9 {
10 size_t max_bytes = 0;
11 size_t max_bytes_threshold = max_bytes_threshold_ > 0
12 ? max_bytes_threshold_
14 std::vector<fml::WeakPtr<ResourceCacheLimitItem>> live_items;
15 for (const auto& item : items_) {
16 if (item) {
17 live_items.push_back(item);
18 max_bytes += item->GetResourceCacheLimit();
19 }
20 }
21 items_ = std::move(live_items);
22 return std::min(max_bytes, max_bytes_threshold);
23}
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48

The documentation for this class was generated from the following files: