未验证 提交 68ae872e 编写于 作者: G gaaclarke 提交者: GitHub

Made the persistent cache's directory a const pointer. (#9815)

上级 8720043d
......@@ -51,22 +51,33 @@ void PersistentCache::SetCacheDirectoryPath(std::string path) {
cache_base_path_ = path;
}
PersistentCache::PersistentCache(bool read_only) : is_read_only_(read_only) {
namespace {
std::shared_ptr<fml::UniqueFD> MakeCacheDirectory(
const std::string& global_cache_base_path,
bool read_only) {
fml::UniqueFD cache_base_dir;
if (cache_base_path_.length()) {
cache_base_dir = fml::OpenDirectory(cache_base_path_.c_str(), false,
if (global_cache_base_path.length()) {
cache_base_dir = fml::OpenDirectory(global_cache_base_path.c_str(), false,
fml::FilePermission::kRead);
} else {
cache_base_dir = fml::paths::GetCachesDirectory();
}
if (cache_base_dir.is_valid()) {
cache_directory_ = std::make_shared<fml::UniqueFD>(CreateDirectory(
return std::make_shared<fml::UniqueFD>(CreateDirectory(
cache_base_dir,
{"flutter_engine", GetFlutterEngineVersion(), "skia", GetSkiaVersion()},
read_only ? fml::FilePermission::kRead
: fml::FilePermission::kReadWrite));
} else {
return std::make_shared<fml::UniqueFD>();
}
}
} // namespace
PersistentCache::PersistentCache(bool read_only)
: is_read_only_(read_only),
cache_directory_(MakeCacheDirectory(cache_base_path_, read_only)) {
if (!IsValid()) {
FML_LOG(WARNING) << "Could not acquire the persistent cache directory. "
"Caching of GPU resources on disk is disabled.";
......
......@@ -19,7 +19,8 @@ namespace flutter {
/// A cache of SkData that gets stored to disk.
///
/// This is mainly used for Shaders but is also written to by Dart.
/// This is mainly used for Shaders but is also written to by Dart. It is
/// thread-safe for reading and writing from multiple threads.
class PersistentCache : public GrContextOptions::PersistentCache {
public:
// Mutable static switch that can be set before GetCacheForProcess. If true,
......@@ -52,7 +53,7 @@ class PersistentCache : public GrContextOptions::PersistentCache {
static std::string cache_base_path_;
const bool is_read_only_;
std::shared_ptr<fml::UniqueFD> cache_directory_;
const std::shared_ptr<fml::UniqueFD> cache_directory_;
mutable std::mutex worker_task_runners_mutex_;
std::multiset<fml::RefPtr<fml::TaskRunner>> worker_task_runners_
FML_GUARDED_BY(worker_task_runners_mutex_);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册