libprocessgroup: Rename CgroupController -> CgroupControllerWrapper
So that the name is not overloaded with libcgrouprc_format's
CgroupController, which can be confusing.
Bug: 349105928
Test: m
Change-Id: I39df9814c500de68fd20139e661363ba51ea3543
diff --git a/libprocessgroup/cgroup_map.cpp b/libprocessgroup/cgroup_map.cpp
index 52b5afe..fb01cfd 100644
--- a/libprocessgroup/cgroup_map.cpp
+++ b/libprocessgroup/cgroup_map.cpp
@@ -38,26 +38,26 @@
static constexpr const char* CGROUP_TASKS_FILE = "/tasks";
static constexpr const char* CGROUP_TASKS_FILE_V2 = "/cgroup.threads";
-uint32_t CgroupController::version() const {
+uint32_t CgroupControllerWrapper::version() const {
CHECK(HasValue());
return ACgroupController_getVersion(controller_);
}
-const char* CgroupController::name() const {
+const char* CgroupControllerWrapper::name() const {
CHECK(HasValue());
return ACgroupController_getName(controller_);
}
-const char* CgroupController::path() const {
+const char* CgroupControllerWrapper::path() const {
CHECK(HasValue());
return ACgroupController_getPath(controller_);
}
-bool CgroupController::HasValue() const {
+bool CgroupControllerWrapper::HasValue() const {
return controller_ != nullptr;
}
-bool CgroupController::IsUsable() {
+bool CgroupControllerWrapper::IsUsable() {
if (!HasValue()) return false;
if (state_ == UNKNOWN) {
@@ -72,7 +72,7 @@
return state_ == USABLE;
}
-std::string CgroupController::GetTasksFilePath(const std::string& rel_path) const {
+std::string CgroupControllerWrapper::GetTasksFilePath(const std::string& rel_path) const {
std::string tasks_path = path();
if (!rel_path.empty()) {
@@ -81,8 +81,8 @@
return (version() == 1) ? tasks_path + CGROUP_TASKS_FILE : tasks_path + CGROUP_TASKS_FILE_V2;
}
-std::string CgroupController::GetProcsFilePath(const std::string& rel_path, uid_t uid,
- pid_t pid) const {
+std::string CgroupControllerWrapper::GetProcsFilePath(const std::string& rel_path, uid_t uid,
+ pid_t pid) const {
std::string proc_path(path());
proc_path.append("/").append(rel_path);
proc_path = regex_replace(proc_path, std::regex("<uid>"), std::to_string(uid));
@@ -91,7 +91,7 @@
return proc_path.append(CGROUP_PROCS_FILE);
}
-bool CgroupController::GetTaskGroup(pid_t tid, std::string* group) const {
+bool CgroupControllerWrapper::GetTaskGroup(pid_t tid, std::string* group) const {
std::string file_name = StringPrintf("/proc/%d/cgroup", tid);
std::string content;
if (!android::base::ReadFileToString(file_name, &content)) {
@@ -175,40 +175,40 @@
}
}
-CgroupController CgroupMap::FindController(const std::string& name) const {
+CgroupControllerWrapper CgroupMap::FindController(const std::string& name) const {
if (!loaded_) {
LOG(ERROR) << "CgroupMap::FindController called for [" << getpid()
<< "] failed, RC file was not initialized properly";
- return CgroupController(nullptr);
+ return CgroupControllerWrapper(nullptr);
}
auto controller_count = ACgroupFile_getControllerCount();
for (uint32_t i = 0; i < controller_count; ++i) {
const ACgroupController* controller = ACgroupFile_getController(i);
if (name == ACgroupController_getName(controller)) {
- return CgroupController(controller);
+ return CgroupControllerWrapper(controller);
}
}
- return CgroupController(nullptr);
+ return CgroupControllerWrapper(nullptr);
}
-CgroupController CgroupMap::FindControllerByPath(const std::string& path) const {
+CgroupControllerWrapper CgroupMap::FindControllerByPath(const std::string& path) const {
if (!loaded_) {
LOG(ERROR) << "CgroupMap::FindControllerByPath called for [" << getpid()
<< "] failed, RC file was not initialized properly";
- return CgroupController(nullptr);
+ return CgroupControllerWrapper(nullptr);
}
auto controller_count = ACgroupFile_getControllerCount();
for (uint32_t i = 0; i < controller_count; ++i) {
const ACgroupController* controller = ACgroupFile_getController(i);
if (StartsWith(path, ACgroupController_getPath(controller))) {
- return CgroupController(controller);
+ return CgroupControllerWrapper(controller);
}
}
- return CgroupController(nullptr);
+ return CgroupControllerWrapper(nullptr);
}
int CgroupMap::ActivateControllers(const std::string& path) const {