Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: athena/resource_manager/delegate/resource_manager_delegate.cc

Issue 513523002: Adding Baseframework of the ResourceManager (all hooks and observers) are being put in place with a… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Odd - DEPS files are not shown by git status. Added. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « athena/resource_manager/OWNERS ('k') | athena/resource_manager/memory_pressure_notifier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "athena/resource_manager/public/resource_manager_delegate.h"
6
7 #include <string>
8
9 #include "base/logging.h"
10 #include "base/macros.h"
11 #include "base/process/process_metrics.h"
12
13 namespace athena {
14
15 namespace {
16 // This is the minimum amount of time in milliseconds between checks for
17 // memory pressure.
18 const int kMemoryPressureIntervalMs = 750;
19 } // namespace
20
21 class ResourceManagerDelegateImpl : public ResourceManagerDelegate {
22 public:
23 ResourceManagerDelegateImpl() {}
24 virtual ~ResourceManagerDelegateImpl() {}
25
26 private:
27 virtual int GetUsedMemoryInPercent() OVERRIDE {
28 base::SystemMemoryInfoKB memory;
29 if (base::GetSystemMemoryInfo(&memory) &&
30 memory.total > 0 && memory.free >= 0) {
31 return ((memory.total - memory.free) * 100) / memory.total;
Luigi Semenzato 2014/08/27 21:24:08 Is memory.free the same as the MemFree field of /p
Mr4D (OOO till 08-26) 2014/08/27 22:34:01 Okay, I will change that in a separate patch. Let'
32 }
33 LOG(WARNING) << "Cannot determine the free memory of the system.";
34 return 0;
35 }
36
37 virtual int MemoryPressureIntervalInMS() OVERRIDE {
38 return kMemoryPressureIntervalMs;
39 }
40 DISALLOW_COPY_AND_ASSIGN(ResourceManagerDelegateImpl);
41 };
42
43 // static
44 ResourceManagerDelegate*
45 ResourceManagerDelegate::CreateResourceManagerDelegate() {
46 return new ResourceManagerDelegateImpl;
47 }
48
49 } // namespace athena
OLDNEW
« no previous file with comments | « athena/resource_manager/OWNERS ('k') | athena/resource_manager/memory_pressure_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698