This source file includes following definitions.
- value
- TakeValue
- CheckValidity
#include "base/logging.h"
#include "base/platform_file.h"
#include "dbus/file_descriptor.h"
namespace dbus {
FileDescriptor::~FileDescriptor() {
if (owner_)
base::ClosePlatformFile(value_);
}
int FileDescriptor::value() const {
CHECK(valid_);
return value_;
}
int FileDescriptor::TakeValue() {
CHECK(valid_);
owner_ = false;
return value_;
}
void FileDescriptor::CheckValidity() {
base::PlatformFileInfo info;
bool ok = base::GetPlatformFileInfo(value_, &info);
valid_ = (ok && !info.is_directory);
}
}