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

Unified Diff: content/browser/memory/memory_coordinator_impl.h

Issue 2374343002: Add MemoryCoordinatorImpl (Closed)
Patch Set: Addressed comments (still lacks tests & comments) Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/memory/memory_coordinator.cc ('k') | content/browser/memory/memory_coordinator_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..42aab409057e0833f5493124f36af75cd02546e5
--- /dev/null
+++ b/content/browser/memory/memory_coordinator_impl.h
@@ -0,0 +1,67 @@
+// 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/callback.h"
+#include "base/memory/singleton.h"
+#include "base/memory/weak_ptr.h"
+#include "base/single_thread_task_runner.h"
+#include "base/threading/non_thread_safe.h"
+#include "base/time/time.h"
+#include "content/browser/memory/memory_coordinator.h"
+
+namespace content {
+
+class MemoryMonitor;
+struct MemoryCoordinatorSingletonTraits;
+
+class MemoryCoordinatorImpl : public MemoryCoordinator,
+ public base::NonThreadSafe {
+ 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;
+
+ using MemoryState = base::MemoryState;
+
+ MemoryState CalculateNextState();
+ void UpdateState();
+ void NotifyStateToClients();
+ void NotifyStateToChildren();
+
+ void ScheduleUpdateState(base::TimeDelta delay);
+
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ std::unique_ptr<MemoryMonitor> memory_monitor_;
+ base::Closure update_state_callback_;
+ base::MemoryState current_state_ = MemoryState::NORMAL;
+ base::TimeTicks last_state_change_;
+
+ // These parameters are used to determine the global state.
+ // TODO(bashi): Provide a way to change these parameters.
+ int predicted_renderer_size_;
+ int num_children_until_throttled_;
+ int num_children_until_suspended_;
+ int num_children_back_to_normal_;
+ int num_children_back_to_throttled_;
+ base::TimeDelta minimum_transition_period_;
+ base::TimeDelta monitoring_iterval_;
chrisha 2016/10/06 13:35:54 Unless these are needed for unittesting, or otherw
bashi 2016/10/07 02:10:20 Added comments. I still put these parameters in th
+
+ base::WeakPtrFactory<MemoryCoordinatorImpl> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorImpl);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_IMPL_H_
« no previous file with comments | « content/browser/memory/memory_coordinator.cc ('k') | content/browser/memory/memory_coordinator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698