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

Side by Side Diff: content/browser/memory/memory_coordinator_impl.h

Issue 2448953002: Add MemoryCoordinatorProxy::SetCurrentMemoryStateForTesting (Closed)
Patch Set: Add tests Created 4 years, 1 month 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
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 CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ 5 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_
6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ 6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 std::unique_ptr<MemoryMonitor> monitor); 44 std::unique_ptr<MemoryMonitor> monitor);
45 ~MemoryCoordinatorImpl() override; 45 ~MemoryCoordinatorImpl() override;
46 46
47 // MemoryCoordinator implementations: 47 // MemoryCoordinator implementations:
48 void Start() override; 48 void Start() override;
49 void OnChildAdded(int render_process_id) override; 49 void OnChildAdded(int render_process_id) override;
50 50
51 MemoryMonitor* memory_monitor() { return memory_monitor_.get(); } 51 MemoryMonitor* memory_monitor() { return memory_monitor_.get(); }
52 52
53 base::MemoryState GetCurrentMemoryState() const override; 53 base::MemoryState GetCurrentMemoryState() const override;
54 void SetCurrentMemoryStateForTesting(base::MemoryState memory_state) override;
54 55
55 // NotificationObserver implementation: 56 // NotificationObserver implementation:
56 void Observe(int type, 57 void Observe(int type,
57 const NotificationSource& source, 58 const NotificationSource& source,
58 const NotificationDetails& details) override; 59 const NotificationDetails& details) override;
59 60
60 private: 61 private:
61 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, CalculateNextState); 62 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, CalculateNextState);
62 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, UpdateState); 63 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, UpdateState);
64 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, SetMemoryStateForTesting);
63 65
64 friend struct MemoryCoordinatorSingletonTraits; 66 friend struct MemoryCoordinatorSingletonTraits;
65 67
66 using MemoryState = base::MemoryState; 68 using MemoryState = base::MemoryState;
67 69
68 // Calculates the next global state from the amount of free memory using 70 // Calculates the next global state from the amount of free memory using
69 // a heuristic. 71 // a heuristic.
70 MemoryState CalculateNextState(); 72 MemoryState CalculateNextState();
71 73
72 // Updates the global state and notifies state changes to clients (lives in 74 // Updates the global state and notifies state changes to clients (lives in
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 base::TimeDelta monitoring_interval_; 123 base::TimeDelta monitoring_interval_;
122 124
123 base::WeakPtrFactory<MemoryCoordinatorImpl> weak_ptr_factory_; 125 base::WeakPtrFactory<MemoryCoordinatorImpl> weak_ptr_factory_;
124 126
125 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl); 127 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl);
126 }; 128 };
127 129
128 } // namespace content 130 } // namespace content
129 131
130 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ 132 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/memory/memory_coordinator.cc ('k') | content/browser/memory/memory_coordinator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698