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

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

Issue 2731913002: NotForReview: Expose the global memory budget (chromium side)
Patch Set: Add --simulate-memory-pressure Created 3 years, 9 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"
(...skipping 12 matching lines...) Expand all
23 // thresholds and hysteresis. 23 // thresholds and hysteresis.
24 class CONTENT_EXPORT MemoryConditionObserver { 24 class CONTENT_EXPORT MemoryConditionObserver {
25 public: 25 public:
26 // |coordinator| must outlive than this instance. 26 // |coordinator| must outlive than this instance.
27 MemoryConditionObserver( 27 MemoryConditionObserver(
28 MemoryCoordinatorImpl* coordinator, 28 MemoryCoordinatorImpl* coordinator,
29 scoped_refptr<base::SingleThreadTaskRunner> task_runner); 29 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
30 ~MemoryConditionObserver(); 30 ~MemoryConditionObserver();
31 31
32 // Schedules a task to update memory condition. The task will be executed 32 // Schedules a task to update memory condition. The task will be executed
33 // after |delay| has passed. 33 // at a given interval.
34 void ScheduleUpdateCondition(base::TimeDelta delay); 34 void ScheduleUpdateCondition(base::TimeDelta interval);
35 35
36 private: 36 private:
37 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, CalculateNextCondition); 37 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, CalculateNextCondition);
38 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, UpdateCondition); 38 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, UpdateCondition);
39 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, ForceSetMemoryCondition); 39 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, ForceSetMemoryCondition);
40 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, DiscardTabUnderCritical); 40 FRIEND_TEST_ALL_PREFIXES(MemoryCoordinatorImplTest, DiscardTabUnderCritical);
41 41
42 // Calculates next memory condition from the amount of free memory using 42 // Calculates next memory condition from the amount of free memory using
43 // a heuristic. 43 // a heuristic.
44 MemoryCondition CalculateNextCondition(); 44 MemoryCondition CalculateNextCondition();
45 45
46 // Periodically called to update the memory condition. 46 // Periodically called to update the memory condition.
47 void UpdateCondition(); 47 void UpdateCondition();
48 48
49 MemoryCoordinatorImpl* coordinator_; 49 MemoryCoordinatorImpl* coordinator_;
50 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 50 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
51 base::CancelableClosure update_condition_closure_; 51 base::CancelableClosure update_condition_closure_;
52 52
53 // Current available free memory provided by MemoryMonitor.
54 int current_available_;
55
56 // The maximum value of available free memory. Used to simulate memory
57 // pressure.
58 int max_available_;
59
53 // Sets up parameters for the heuristic. 60 // Sets up parameters for the heuristic.
54 void InitializeParameters(); 61 void InitializeParameters();
55 62
56 // Validates parameters defined below. 63 // Validates parameters defined below.
57 bool ValidateParameters(); 64 bool ValidateParameters();
58 65
59 // Parameters to control the heuristic. 66 // Parameters to control the heuristic.
60 67
61 // The median size of a renderer on the current platform. This is used to 68 // The median size of a renderer on the current platform. This is used to
62 // convert the amount of free memory to an expected number of new renderers 69 // convert the amount of free memory to an expected number of new renderers
(...skipping 16 matching lines...) Expand all
79 int new_renderers_back_to_warning_; 86 int new_renderers_back_to_warning_;
80 // The interval of checking the amount of free memory. 87 // The interval of checking the amount of free memory.
81 base::TimeDelta monitoring_interval_; 88 base::TimeDelta monitoring_interval_;
82 89
83 DISALLOW_COPY_AND_ASSIGN(MemoryConditionObserver); 90 DISALLOW_COPY_AND_ASSIGN(MemoryConditionObserver);
84 }; 91 };
85 92
86 } // namespace content 93 } // namespace content
87 94
88 #endif // CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_ 95 #endif // CONTENT_BROWSER_MEMORY_MEMORY_CONDITION_OBSERVER_H_
OLDNEW
« no previous file with comments | « base/memory/memory_coordinator_proxy.cc ('k') | content/browser/memory/memory_condition_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698