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

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

Issue 2479673002: Expose MemoryCoordinator's global budget information. (Closed)
Patch Set: Small cleanup. 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_H_ 5 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_
6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ 6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_
7 7
8 #include "base/memory/memory_coordinator_client_registry.h" 8 #include "base/memory/memory_coordinator_client_registry.h"
9 #include "base/process/process_handle.h" 9 #include "base/process/process_handle.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
(...skipping 30 matching lines...) Expand all
41 41
42 // Returns number of children. Only used for testing. 42 // Returns number of children. Only used for testing.
43 size_t NumChildrenForTesting(); 43 size_t NumChildrenForTesting();
44 44
45 // Dispatches a memory state change to the provided process. Returns true if 45 // Dispatches a memory state change to the provided process. Returns true if
46 // the process is tracked by this coordinator and successfully dispatches, 46 // the process is tracked by this coordinator and successfully dispatches,
47 // returns false otherwise. 47 // returns false otherwise.
48 bool SetMemoryState( 48 bool SetMemoryState(
49 int render_process_id, mojom::MemoryState memory_state); 49 int render_process_id, mojom::MemoryState memory_state);
50 50
51 // Dispatches a remaining global budget change to the provided process.
52 // Returns true if the process is tracked by this coordinator and successfully
53 // dispatches, false otherwise.
54 bool SetRemainingGlobalBudget(
55 int render_process_id, int64_t remaining_global_budget_mb);
56
51 // Returns the memory state of the specified render process. Returns UNKNOWN 57 // Returns the memory state of the specified render process. Returns UNKNOWN
52 // if the process is not tracked by this coordinator. 58 // if the process is not tracked by this coordinator.
53 mojom::MemoryState GetMemoryState(int render_process_id) const; 59 mojom::MemoryState GetMemoryState(int render_process_id) const;
54 60
55 // Called when ChildMemoryCoordinator calls AddChild(). 61 // Called when ChildMemoryCoordinator calls AddChild().
56 virtual void OnChildAdded(int render_process_id) {} 62 virtual void OnChildAdded(int render_process_id) {}
57 63
58 virtual base::MemoryState GetCurrentMemoryState() const; 64 virtual base::MemoryState GetCurrentMemoryState() const;
59 virtual void SetCurrentMemoryStateForTesting(base::MemoryState memory_state); 65 virtual void SetCurrentMemoryStateForTesting(base::MemoryState memory_state);
60 66
67 // Returns the remaining global budget usable in aggregate by all Chrome
68 // processes. This indicates how many MB of memory are remaining for Chrome
69 // processes to use before the memory coordinator will take efforts to reclaim
70 // memory. A negative amount indicates that the coordinator is actively trying
71 // to reclaim that much memory.
72 virtual int64_t GetRemainingGlobalBudget() const;
73
61 protected: 74 protected:
62 // Constructor. Protected as this is a singleton, but accessible for 75 // Constructor. Protected as this is a singleton, but accessible for
63 // unittests. 76 // unittests.
64 MemoryCoordinator(); 77 MemoryCoordinator();
65 78
66 // Adds the given ChildMemoryCoordinator as a child of this coordinator. 79 // Adds the given ChildMemoryCoordinator as a child of this coordinator.
67 void AddChildForTesting(int dummy_render_process_id, 80 void AddChildForTesting(int dummy_render_process_id,
68 mojom::ChildMemoryCoordinatorPtr child); 81 mojom::ChildMemoryCoordinatorPtr child);
69 82
70 // Callback invoked by mojo when the child connection goes down. Exposed 83 // Callback invoked by mojo when the child connection goes down. Exposed
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ChildInfoMap children_; 118 ChildInfoMap children_;
106 119
107 std::unique_ptr<MemoryCoordinatorDelegate> delegate_; 120 std::unique_ptr<MemoryCoordinatorDelegate> delegate_;
108 121
109 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinator); 122 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinator);
110 }; 123 };
111 124
112 } // namespace content 125 } // namespace content
113 126
114 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ 127 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698