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

Side by Side Diff: base/memory/memory_coordinator_proxy.h

Issue 2731913002: NotForReview: Expose the global memory budget (chromium side)
Patch Set: Add --simulate-memory-pressure Created 3 years, 9 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
« no previous file with comments | « no previous file | base/memory/memory_coordinator_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_ 5 #ifndef BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_
6 #define BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_ 6 #define BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_
7 7
8 #include "base/base_export.h" 8 #include "base/base_export.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/memory_coordinator_client.h" 10 #include "base/memory/memory_coordinator_client.h"
11 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 // The MemoryCoordinator interface. See comments in MemoryCoordinatorProxy for 15 // The MemoryCoordinator interface. See comments in MemoryCoordinatorProxy for
16 // method descriptions. 16 // method descriptions.
17 class BASE_EXPORT MemoryCoordinator { 17 class BASE_EXPORT MemoryCoordinator {
18 public: 18 public:
19 virtual ~MemoryCoordinator() {} 19 virtual ~MemoryCoordinator() {}
20 20
21 virtual MemoryState GetCurrentMemoryState() const = 0; 21 virtual MemoryState GetCurrentMemoryState() const = 0;
22 virtual int64_t GetGlobalBudget() = 0;
23 virtual void SetGlobalBudgetUpdateInterval(uint32_t interval_ms) = 0;
22 }; 24 };
23 25
24 // The proxy of MemoryCoordinator to be accessed from components that are not 26 // The proxy of MemoryCoordinator to be accessed from components that are not
25 // in content/browser e.g. net. 27 // in content/browser e.g. net.
26 class BASE_EXPORT MemoryCoordinatorProxy { 28 class BASE_EXPORT MemoryCoordinatorProxy {
27 public: 29 public:
28 static MemoryCoordinatorProxy* GetInstance(); 30 static MemoryCoordinatorProxy* GetInstance();
29 31
30 // Sets an implementation of MemoryCoordinator. MemoryCoordinatorProxy doesn't 32 // Sets an implementation of MemoryCoordinator. MemoryCoordinatorProxy doesn't
31 // take the ownership of |coordinator|. It must outlive this proxy. 33 // take the ownership of |coordinator|. It must outlive this proxy.
32 // This should be called before any components starts using this proxy. 34 // This should be called before any components starts using this proxy.
33 static void SetMemoryCoordinator(MemoryCoordinator* coordinator); 35 static void SetMemoryCoordinator(MemoryCoordinator* coordinator);
34 36
35 // Returns the current memory state. 37 // Returns the current memory state.
36 MemoryState GetCurrentMemoryState() const; 38 MemoryState GetCurrentMemoryState() const;
37 39
40 // Returns the current global memory budget. A negative value can be returned
41 // if the global budget is unknown or the system is under high memory
42 // pressure.
43 int64_t GetGlobalBudget() const;
44
45 // TODO(bashi): Tentative.
46 void SetGlobalBudgetUpdateInterval(uint32_t interval_ms);
47
48 // Returns true when an instance of MemoryCoordinator is set.
49 bool IsEnabled();
50
38 private: 51 private:
39 friend struct base::DefaultSingletonTraits<MemoryCoordinatorProxy>; 52 friend struct base::DefaultSingletonTraits<MemoryCoordinatorProxy>;
40 53
41 MemoryCoordinatorProxy(); 54 MemoryCoordinatorProxy();
42 virtual ~MemoryCoordinatorProxy(); 55 virtual ~MemoryCoordinatorProxy();
43 56
44 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorProxy); 57 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorProxy);
45 }; 58 };
46 59
47 } // namespace base 60 } // namespace base
48 61
49 #endif // BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_ 62 #endif // BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_
OLDNEW
« no previous file with comments | « no previous file | base/memory/memory_coordinator_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698