This source file includes following definitions.
- memory_info
- InitializeForTesting
- QueryInfo
- Get
#include "chrome/browser/extensions/api/system_memory/memory_info_provider.h"
#include "base/sys_info.h"
namespace extensions {
using api::system_memory::MemoryInfo;
base::LazyInstance<scoped_refptr<MemoryInfoProvider> >
MemoryInfoProvider::provider_ = LAZY_INSTANCE_INITIALIZER;
MemoryInfoProvider::MemoryInfoProvider() {}
MemoryInfoProvider::~MemoryInfoProvider() {}
const MemoryInfo& MemoryInfoProvider::memory_info() const {
return info_;
}
void MemoryInfoProvider::InitializeForTesting(
scoped_refptr<MemoryInfoProvider> provider) {
DCHECK(provider.get() != NULL);
provider_.Get() = provider;
}
bool MemoryInfoProvider::QueryInfo() {
info_.capacity = static_cast<double>(base::SysInfo::AmountOfPhysicalMemory());
info_.available_capacity =
static_cast<double>(base::SysInfo::AmountOfAvailablePhysicalMemory());
return true;
}
MemoryInfoProvider* MemoryInfoProvider::Get() {
if (provider_.Get().get() == NULL)
provider_.Get() = new MemoryInfoProvider();
return provider_.Get();
}
}