OLD | NEW |
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 proxy of MemoryCoordinator to be accessed from components that is not | 15 // The proxy of MemoryCoordinator to be accessed from components that are not |
16 // in content/browser e.g. net. | 16 // in content/browser e.g. net. |
17 class BASE_EXPORT MemoryCoordinatorProxy { | 17 class BASE_EXPORT MemoryCoordinatorProxy { |
18 public: | 18 public: |
19 using GetCurrentMemoryStateCallback = base::Callback<MemoryState()>; | 19 using GetCurrentMemoryStateCallback = base::Callback<MemoryState()>; |
| 20 using SetCurrentMemoryStateCallback = base::Callback<void(MemoryState)>; |
20 | 21 |
21 static MemoryCoordinatorProxy* GetInstance(); | 22 static MemoryCoordinatorProxy* GetInstance(); |
22 | 23 |
23 // Returns the current memory state. | 24 // Returns the current memory state. |
24 MemoryState GetCurrentMemoryState() const; | 25 MemoryState GetCurrentMemoryState() const; |
25 | 26 |
| 27 // Sets the current memory state. This function is for testing only. |
| 28 void SetCurrentMemoryStateForTesting(MemoryState memory_state); |
| 29 |
26 // Sets state-getter callback. | 30 // Sets state-getter callback. |
27 void SetGetCurrentMemoryStateCallback(GetCurrentMemoryStateCallback callback); | 31 void SetGetCurrentMemoryStateCallback(GetCurrentMemoryStateCallback callback); |
28 | 32 |
| 33 // Sets state-setter callback. |
| 34 void SetSetCurrentMemoryStateForTestingCallback( |
| 35 SetCurrentMemoryStateCallback callback); |
| 36 |
29 private: | 37 private: |
30 friend struct base::DefaultSingletonTraits<MemoryCoordinatorProxy>; | 38 friend struct base::DefaultSingletonTraits<MemoryCoordinatorProxy>; |
31 | 39 |
32 MemoryCoordinatorProxy(); | 40 MemoryCoordinatorProxy(); |
33 virtual ~MemoryCoordinatorProxy(); | 41 virtual ~MemoryCoordinatorProxy(); |
34 | 42 |
35 GetCurrentMemoryStateCallback callback_; | 43 GetCurrentMemoryStateCallback getter_callback_; |
| 44 SetCurrentMemoryStateCallback setter_callback_; |
36 | 45 |
37 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorProxy); | 46 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorProxy); |
38 }; | 47 }; |
39 | 48 |
40 } // namespace base | 49 } // namespace base |
41 | 50 |
42 #endif // BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_ | 51 #endif // BASE_MEMORY_MEMORY_COORDINATOR_PROXY_H_ |
OLD | NEW |