Android-cuttlefish cvd tool
caching_build_api.h
Go to the documentation of this file.
1//
2// Copyright (C) 2024 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#pragma once
17
18#include <string>
19
24
25namespace cuttlefish {
26
27bool EnsureCacheDirectory(const std::string& cache_base_path);
28
29class CachingBuildApi : public BuildApi {
30 public:
31 CachingBuildApi(BuildApi& build_api, std::string cache_base_path);
32
33 Result<Build> GetBuild(const BuildString& build_string) override;
35 const std::string& target_directory,
36 const std::string& artifact_name) override;
38 const Build& build, const std::string& target_directory,
39 const std::string& artifact_name,
40 const std::string& backup_artifact_name) override;
41
43 const std::string& artifact) override;
44
45 private:
46 Result<bool> CanCache(const std::string& target_directory);
47
49 std::string cache_base_path_;
50};
51
52} // namespace cuttlefish
Definition: expected.h:86
Definition: build_api.h:27
Definition: caching_build_api.h:29
Result< Build > GetBuild(const BuildString &build_string) override
Definition: caching_build_api.cpp:88
Result< std::string > DownloadFile(const Build &build, const std::string &target_directory, const std::string &artifact_name) override
Definition: caching_build_api.cpp:92
Result< std::string > DownloadFileWithBackup(const Build &build, const std::string &target_directory, const std::string &artifact_name, const std::string &backup_artifact_name) override
Definition: caching_build_api.cpp:113
BuildApi & build_api_
Definition: caching_build_api.h:48
CachingBuildApi(BuildApi &build_api, std::string cache_base_path)
Definition: caching_build_api.cpp:80
std::string cache_base_path_
Definition: caching_build_api.h:49
Result< SeekableZipSource > FileReader(const Build &, const std::string &artifact) override
Definition: caching_build_api.cpp:147
Result< bool > CanCache(const std::string &target_directory)
Definition: caching_build_api.cpp:84
Definition: alloc_utils.cpp:23
bool EnsureCacheDirectory(const std::string &cache_base_path)
Definition: caching_build_api.cpp:69
std::variant< DeviceBuild, DirectoryBuild > Build
Definition: android_build.h:49
std::variant< DeviceBuildString, DirectoryBuildString > BuildString
Definition: android_build_string.h:52