1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
ash / ambient / ambient_photo_cache_settings.cc [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/ambient/ambient_photo_cache_settings.h"
#include <utility>
#include "ash/ambient/ambient_constants.h"
#include "base/check_is_test.h"
#include "base/files/file_path.h"
#include "base/no_destructor.h"
#include "base/path_service.h"
namespace ash {
namespace {
base::FilePath GetCacheRootPath() {
base::FilePath home_dir;
CHECK(base::PathService::Get(base::DIR_HOME, &home_dir));
return home_dir.Append(FILE_PATH_LITERAL(kAmbientModeDirectoryName));
}
base::FilePath& GetPrimaryRootDir() {
static base::NoDestructor<base::FilePath> g_root_dir(
GetCacheRootPath().Append(
FILE_PATH_LITERAL(kAmbientModeCacheDirectoryName)));
return *g_root_dir;
}
base::FilePath& GetBackupRootDir() {
static base::NoDestructor<base::FilePath> g_root_dir(
GetCacheRootPath().Append(
FILE_PATH_LITERAL(kAmbientModeBackupCacheDirectoryName)));
return *g_root_dir;
}
} // namespace
const base::FilePath& GetAmbientPhotoCacheRootDir() {
return GetPrimaryRootDir();
}
const base::FilePath& GetAmbientBackupPhotoCacheRootDir() {
return GetBackupRootDir();
}
void SetAmbientPhotoCacheRootDirForTesting(base::FilePath root_dir) {
CHECK_IS_TEST();
GetPrimaryRootDir() = std::move(root_dir);
}
void SetAmbientBackupPhotoCacheRootDirForTesting(base::FilePath root_dir) {
CHECK_IS_TEST();
GetBackupRootDir() = std::move(root_dir);
}
} // namespace ash