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 #ifndef ATHENA_RESOURCE_MANAGER_PUBLIC_RESOURCE_MANAGER_H_
6 #define ATHENA_RESOURCE_MANAGER_PUBLIC_RESOURCE_MANAGER_H_
8 #include "athena/athena_export.h"
9 #include "athena/resource_manager/memory_pressure_notifier.h"
10 #include "base/basictypes.h"
14 // The resource manager is monitoring activity changes, low memory conditions
15 // and other events to control the activity state (pre-/un-/re-/loading them)
16 // to keep enough memory free that no jank/lag will show when new applications
17 // are loaded and / or a navigation between applications takes place.
18 class ATHENA_EXPORT ResourceManager
{
20 // Creates the instance handling the resources.
22 static ResourceManager
* Get();
23 static void Shutdown();
26 virtual ~ResourceManager();
28 // Unit tests can simulate MemoryPressure changes with this call.
29 // Note: Even though the default unit test ResourceManagerDelegte
30 // implementation ensures that the MemoryPressure event will not go off,
31 // this call will also explicitly stop the MemoryPressureNotifier.
32 virtual void SetMemoryPressureAndStopMonitoring(
33 MemoryPressureObserver::MemoryPressure pressure
) = 0;
35 // Suspend the resource manager temporarily if |pause| is set. This can be
36 // called before e.g. re-arranging the order of activities. Once called with
37 // |pause| == false any queued operations will be performed and the resource
38 // manager will continue its work.
39 virtual void Pause(bool pause
) = 0;
42 DISALLOW_COPY_AND_ASSIGN(ResourceManager
);
45 // Use this scoped object to pause/restart the resource manager.
46 class ScopedPauseResourceManager
{
48 ScopedPauseResourceManager() {
49 ResourceManager::Get()->Pause(true);
51 ~ScopedPauseResourceManager() {
52 ResourceManager::Get()->Pause(false);
55 DISALLOW_COPY_AND_ASSIGN(ScopedPauseResourceManager
);
60 #endif // ATHENA_RESOURCE_MANAGER_PUBLIC_RESOURCE_MANAGER_H_