1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "athena/resource_manager/public/resource_manager_delegate.h"
9 #include "base/logging.h"
10 #include "base/macros.h"
11 #include "base/process/process_metrics.h"
16 // This is the minimum amount of time in milliseconds between checks for
18 const int kMemoryPressureIntervalMs
= 750;
21 class ResourceManagerDelegateImpl
: public ResourceManagerDelegate
{
23 ResourceManagerDelegateImpl() {}
24 virtual ~ResourceManagerDelegateImpl() {}
27 virtual int GetUsedMemoryInPercent() OVERRIDE
{
28 base::SystemMemoryInfoKB memory
;
29 // TODO(skuhne): According to semenzato this calculation has to change.
30 if (base::GetSystemMemoryInfo(&memory
) &&
31 memory
.total
> 0 && memory
.free
>= 0) {
32 return ((memory
.total
- memory
.free
) * 100) / memory
.total
;
34 LOG(WARNING
) << "Cannot determine the free memory of the system.";
38 virtual int MemoryPressureIntervalInMS() OVERRIDE
{
39 return kMemoryPressureIntervalMs
;
41 DISALLOW_COPY_AND_ASSIGN(ResourceManagerDelegateImpl
);
45 ResourceManagerDelegate
*
46 ResourceManagerDelegate::CreateResourceManagerDelegate() {
47 return new ResourceManagerDelegateImpl
;