Chromium Code Reviews| Index: content/browser/memory/memory_coordinator_impl.h |
| diff --git a/content/browser/memory/memory_coordinator_impl.h b/content/browser/memory/memory_coordinator_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2238c733445bf4c4f53a01a95d7add72eea65b16 |
| --- /dev/null |
| +++ b/content/browser/memory/memory_coordinator_impl.h |
| @@ -0,0 +1,61 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ |
| +#define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ |
| + |
| +#include "base/memory/singleton.h" |
| +#include "base/single_thread_task_runner.h" |
| +#include "base/time/time.h" |
| +#include "base/timer/timer.h" |
| +#include "content/browser/memory/memory_coordinator.h" |
| + |
| +namespace content { |
| + |
| +class MemoryMonitor; |
| +struct MemoryCoordinatorSingletonTraits; |
| + |
| +class MemoryCoordinatorImpl : public MemoryCoordinator { |
| + public: |
| + MemoryCoordinatorImpl(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| + std::unique_ptr<MemoryMonitor> monitor); |
| + ~MemoryCoordinatorImpl() override; |
| + |
| + void Start() override; |
| + |
| + void OnChildAdded(int render_process_id) override; |
| + |
| + private: |
| + friend struct MemoryCoordinatorSingletonTraits; |
| + |
| + // This struct holds some parameters to determine the global state. |
| + struct Configuration { |
| + int predicted_renderer_size; |
| + int pressure_threshold_mb; |
| + int num_children_until_throttled; |
| + int num_children_until_suspended; |
| + base::TimeDelta minimum_transition_period; |
| + base::TimeDelta monitoring_iterval; |
| + }; |
|
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
|
| + |
| + using MemoryState = base::MemoryState; |
| + |
| + MemoryState CalculateNextState(); |
| + void UpdateState(); |
| + void NotifyStateToClients(); |
| + void NotifyStateToChildren(); |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| + base::RepeatingTimer timer_; |
| + std::unique_ptr<MemoryMonitor> memory_monitor_; |
| + Configuration config_; |
| + base::MemoryState current_state_ = MemoryState::NORMAL; |
| + base::TimeTicks last_state_change_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_ |