Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ | |
| 6 #define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ | |
| 7 | |
| 8 #include "base/memory/singleton.h" | |
| 9 #include "base/single_thread_task_runner.h" | |
| 10 #include "base/time/time.h" | |
| 11 #include "base/timer/timer.h" | |
| 12 #include "content/browser/memory/memory_coordinator.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 class MemoryMonitor; | |
| 17 struct MemoryCoordinatorSingletonTraits; | |
| 18 | |
| 19 class MemoryCoordinatorImpl : public MemoryCoordinator { | |
| 20 public: | |
| 21 MemoryCoordinatorImpl(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
| 22 std::unique_ptr<MemoryMonitor> monitor); | |
| 23 ~MemoryCoordinatorImpl() override; | |
| 24 | |
| 25 void Start() override; | |
| 26 | |
| 27 void OnChildAdded(int render_process_id) override; | |
| 28 | |
| 29 private: | |
| 30 friend struct MemoryCoordinatorSingletonTraits; | |
| 31 | |
| 32 // This struct holds some parameters to determine the global state. | |
| 33 struct Configuration { | |
| 34 int predicted_renderer_size; | |
| 35 int pressure_threshold_mb; | |
| 36 int num_children_until_throttled; | |
| 37 int num_children_until_suspended; | |
| 38 base::TimeDelta minimum_transition_period; | |
| 39 base::TimeDelta monitoring_iterval; | |
| 40 }; | |
|
chrisha
2016/10/04 20:00:53
Not sure we need a separate struct for this. I'd s
bashi
2016/10/06 03:55:45
Changed to put these as member variables (though I
| |
| 41 | |
| 42 using MemoryState = base::MemoryState; | |
| 43 | |
| 44 MemoryState CalculateNextState(); | |
| 45 void UpdateState(); | |
| 46 void NotifyStateToClients(); | |
| 47 void NotifyStateToChildren(); | |
| 48 | |
| 49 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | |
| 50 base::RepeatingTimer timer_; | |
| 51 std::unique_ptr<MemoryMonitor> memory_monitor_; | |
| 52 Configuration config_; | |
| 53 base::MemoryState current_state_ = MemoryState::NORMAL; | |
| 54 base::TimeTicks last_state_change_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl); | |
| 57 }; | |
| 58 | |
| 59 } // namespace content | |
| 60 | |
| 61 #endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ | |
| OLD | NEW |