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

Side by Side Diff: athena/resource_manager/public/resource_manager.h

Issue 863033002: Delete athena/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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 #ifndef ATHENA_RESOURCE_MANAGER_PUBLIC_RESOURCE_MANAGER_H_
6 #define ATHENA_RESOURCE_MANAGER_PUBLIC_RESOURCE_MANAGER_H_
7
8 #include "athena/athena_export.h"
9 #include "base/basictypes.h"
10
11 namespace athena {
12
13 // The resource manager is monitoring activity changes, low memory conditions
14 // and other events to control the activity state (pre-/un-/re-/loading them)
15 // to keep enough memory free that no jank/lag will show when new applications
16 // are loaded and / or a navigation between applications takes place.
17 class ATHENA_EXPORT ResourceManager {
18 public:
19 // The reported memory pressure. Note: The value is intentionally abstracted
20 // since the real amount of free memory is only estimated (due to e.g. zram).
21 // Note: The bigger the index of the pressure level, the more resources are
22 // in use.
23 enum MemoryPressure {
24 MEMORY_PRESSURE_UNKNOWN = 0, // The memory pressure cannot be determined.
25 MEMORY_PRESSURE_LOW, // Single call if fill level is below 50%.
26 MEMORY_PRESSURE_MODERATE, // Polled for fill level of ~50 .. 75%.
27 MEMORY_PRESSURE_HIGH, // Polled for fill level of ~75% .. 90%.
28 MEMORY_PRESSURE_CRITICAL, // Polled for fill level of above ~90%.
29 };
30
31 // Creates the instance handling the resources.
32 static void Create();
33 static ResourceManager* Get();
34 static void Shutdown();
35
36 ResourceManager();
37 virtual ~ResourceManager();
38
39 // Unit tests can simulate MemoryPressure changes with this call.
40 // Note: Even though the default unit test ResourceManagerDelegte
41 // implementation ensures that the MemoryPressure event will not go off,
42 // this call will also explicitly stop the MemoryPressureNotifier.
43 virtual void SetMemoryPressureAndStopMonitoring(
44 ResourceManager::MemoryPressure pressure) = 0;
45
46 // Resource management calls require time to show effect (until memory
47 // gets actually released). This function lets override the time limiter
48 // between two calls to allow for more/less aggressive timeouts.
49 // By calling this function, the next call to the Resource manager will be
50 // executed immediately.
51 virtual void SetWaitTimeBetweenResourceManageCalls(int time_in_ms) = 0;
52
53 // Suspend the resource manager temporarily if |pause| is set. This can be
54 // called before e.g. re-arranging the order of activities. Once called with
55 // |pause| == false any queued operations will be performed and the resource
56 // manager will continue its work.
57 virtual void Pause(bool pause) = 0;
58
59 private:
60 DISALLOW_COPY_AND_ASSIGN(ResourceManager);
61 };
62
63 // Use this scoped object to pause/restart the resource manager.
64 class ScopedPauseResourceManager {
65 public:
66 ScopedPauseResourceManager() {
67 ResourceManager::Get()->Pause(true);
68 }
69 ~ScopedPauseResourceManager() {
70 ResourceManager::Get()->Pause(false);
71 }
72 private:
73 DISALLOW_COPY_AND_ASSIGN(ScopedPauseResourceManager);
74 };
75
76 } // namespace athena
77
78 #endif // ATHENA_RESOURCE_MANAGER_PUBLIC_RESOURCE_MANAGER_H_
OLDNEW
« no previous file with comments | « athena/resource_manager/public/DEPS ('k') | athena/resource_manager/public/resource_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698