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

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

Issue 2943603002: Remove MemoryCondition::WARNING (Closed)
Patch Set: rebase Created 3 years, 6 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 | content/browser/memory/memory_condition_observer.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 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 namespace content { 14 namespace content {
15 15
16 // MemoryConditionObserver is an internal implementation of MemoryCoordinator 16 // MemoryConditionObserver observes system memory usage and determines the
17 // which uses a heuristic to determine the current memory condition. The 17 // current MemoryCondition. It dispatches the current condition if the condition
18 // heuristic is: 18 // has changed.
19 // * Compute number of renderers which can be created until the system will
20 // be in a critical state. Call this N.
21 // (See memory_monitor.h for the definition of "critical")
22 // * Covert N to memory condition (one of NORMAL/WARNING/CRITICAL) by using some
23 // thresholds and hysteresis.
24 class CONTENT_EXPORT MemoryConditionObserver { 19 class CONTENT_EXPORT MemoryConditionObserver {
25 public: 20 public:
26 // |coordinator| must outlive than this instance. 21 // |coordinator| must outlive than this instance.
27 MemoryConditionObserver( 22 MemoryConditionObserver(
28 MemoryCoordinatorImpl* coordinator, 23 MemoryCoordinatorImpl* coordinator,
29 scoped_refptr<base::SingleThreadTaskRunner> task_runner); 24 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
30 ~MemoryConditionObserver(); 25 ~MemoryConditionObserver();
31 26
32 // Schedules a task to update memory condition. The task will be executed 27 // Schedules a task to update memory condition. The task will be executed
33 // after |delay| has passed. 28 // after |delay| has passed.
(...skipping 19 matching lines...) Expand all
53 // a heuristic. 48 // a heuristic.
54 MemoryCondition CalculateNextCondition(); 49 MemoryCondition CalculateNextCondition();
55 50
56 // Periodically called to update the memory condition. 51 // Periodically called to update the memory condition.
57 void UpdateCondition(); 52 void UpdateCondition();
58 53
59 MemoryCoordinatorImpl* coordinator_; 54 MemoryCoordinatorImpl* coordinator_;
60 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 55 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
61 base::CancelableClosure update_condition_closure_; 56 base::CancelableClosure update_condition_closure_;
62 57
63 // Sets up parameters for the heuristic.
64 void InitializeParameters();
65
66 // Validates parameters defined below.
67 bool ValidateParameters();
68
69 // Parameters to control the heuristic.
70
71 // 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
73 // that could be started before hitting critical memory pressure.
74 int expected_renderer_size_;
75 // When in a NORMAL condition and the potential number of new renderers drops
76 // below this level, the coordinator will transition to a WARNING condition.
77 int new_renderers_until_warning_;
78 // When in a NORMAL/WARNING state and the potential number of new renderers
79 // drops below this level, the coordinator will transition to a CRITICAL
80 // condition.
81 int new_renderers_until_critical_;
82 // When in a WARNING/CRITICAL condition and the potential number of new
83 // renderers rises above this level, the coordinator will transition to a
84 // NORMAL condition.
85 int new_renderers_back_to_normal_;
86 // When in a CRITICAL condition and the potential number of new renderers
87 // rises above this level, the coordinator will transition to a WARNING
88 // condition.
89 int new_renderers_back_to_warning_;
90 // The current interval of checking the amount of free memory. 58 // The current interval of checking the amount of free memory.
91 base::TimeDelta monitoring_interval_; 59 base::TimeDelta monitoring_interval_;
92 // The value of |monitoring_interval_| when the browser is foregrounded. 60 // The value of |monitoring_interval_| when the browser is foregrounded.
93 base::TimeDelta monitoring_interval_foregrounded_; 61 base::TimeDelta monitoring_interval_foregrounded_;
94 // The value of |monitoring_interval_| when the browser is backgrounded. 62 // The value of |monitoring_interval_| when the browser is backgrounded.
95 base::TimeDelta monitoring_interval_backgrounded_; 63 base::TimeDelta monitoring_interval_backgrounded_;
96 64
97 DISALLOW_COPY_AND_ASSIGN(MemoryConditionObserver); 65 DISALLOW_COPY_AND_ASSIGN(MemoryConditionObserver);
98 }; 66 };
99 67
100 } // namespace content 68 } // namespace content
101 69
102 #endif // CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_ 70 #endif // CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/memory/memory_condition_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698