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

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

Issue 2783613002: WIP: memory coordinator: Check /dev/chromeos-low-mem to determine memory condition
Patch Set: Created 3 years, 8 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
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_CONDITION_OBSERVER_H_ 5 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_
6 #define CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_ 6 #define CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_
7 7
8 #include "base/cancelable_callback.h" 8 #include "base/cancelable_callback.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "content/browser/memory/memory_coordinator_impl.h" 11 #include "content/browser/memory/memory_coordinator_impl.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 13
14 #if defined(OS_CHROMEOS)
15 #include "base/memory/low_memory_observer_chromeos.h"
16 #endif
17
14 namespace content { 18 namespace content {
15 19
16 // MemoryConditionObserver is an internal implementation of MemoryCoordinator 20 // MemoryConditionObserver is an internal implementation of MemoryCoordinator
17 // which uses a heuristic to determine the current memory condition. The 21 // which uses a heuristic to determine the current memory condition. The
18 // heuristic is: 22 // heuristic is:
19 // * Compute number of renderers which can be created until the system will 23 // * Compute number of renderers which can be created until the system will
20 // be in a critical state. Call this N. 24 // be in a critical state. Call this N.
21 // (See memory_monitor.h for the definition of "critical") 25 // (See memory_monitor.h for the definition of "critical")
22 // * Covert N to memory condition (one of NORMAL/WARNING/CRITICAL) by using some 26 // * Covert N to memory condition (one of NORMAL/WARNING/CRITICAL) by using some
23 // thresholds and hysteresis. 27 // thresholds and hysteresis.
(...skipping 29 matching lines...) Expand all
53 // a heuristic. 57 // a heuristic.
54 MemoryCondition CalculateNextCondition(); 58 MemoryCondition CalculateNextCondition();
55 59
56 // Periodically called to update the memory condition. 60 // Periodically called to update the memory condition.
57 void UpdateCondition(); 61 void UpdateCondition();
58 62
59 MemoryCoordinatorImpl* coordinator_; 63 MemoryCoordinatorImpl* coordinator_;
60 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 64 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
61 base::CancelableClosure update_condition_closure_; 65 base::CancelableClosure update_condition_closure_;
62 66
67 #if defined(OS_CHROMEOS)
68 std::unique_ptr<base::chromeos::LowMemoryObserver> low_memory_observer_;
69 #endif
70
63 // Sets up parameters for the heuristic. 71 // Sets up parameters for the heuristic.
64 void InitializeParameters(); 72 void InitializeParameters();
65 73
66 // Validates parameters defined below. 74 // Validates parameters defined below.
67 bool ValidateParameters(); 75 bool ValidateParameters();
68 76
69 // Parameters to control the heuristic. 77 // Parameters to control the heuristic.
70 78
71 // The median size of a renderer on the current platform. This is used to 79 // The median size of a renderer on the current platform. This is used to
72 // convert the amount of free memory to an expected number of new renderers 80 // convert the amount of free memory to an expected number of new renderers
(...skipping 20 matching lines...) Expand all
93 base::TimeDelta monitoring_interval_foregrounded_; 101 base::TimeDelta monitoring_interval_foregrounded_;
94 // The value of |monitoring_interval_| when the browser is backgrounded. 102 // The value of |monitoring_interval_| when the browser is backgrounded.
95 base::TimeDelta monitoring_interval_backgrounded_; 103 base::TimeDelta monitoring_interval_backgrounded_;
96 104
97 DISALLOW_COPY_AND_ASSIGN(MemoryConditionObserver); 105 DISALLOW_COPY_AND_ASSIGN(MemoryConditionObserver);
98 }; 106 };
99 107
100 } // namespace content 108 } // namespace content
101 109
102 #endif // CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_ 110 #endif // CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_
OLDNEW
« no previous file with comments | « base/memory/memory_pressure_monitor_chromeos.cc ('k') | content/browser/memory/memory_condition_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698