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

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

Issue 2374343002: Add MemoryCoordinatorImpl (Closed)
Patch Set: Created 4 years, 3 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
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..befc5bbfa55bcf8dc6d7ace58038fcebd418e269
--- /dev/null
+++ b/content/browser/memory/memory_coordinator_impl.h
@@ -0,0 +1,52 @@
+// 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/time/time.h"
+#include "content/browser/memory/memory_coordinator.h"
+
+namespace content {
+
+class MemoryMonitor;
+struct MemoryCoordinatorSingletonTraits;
+
+class MemoryCoordinatorImpl : public MemoryCoordinator {
+ public:
+ explicit MemoryCoordinatorImpl(std::unique_ptr<MemoryMonitor> monitor);
+ ~MemoryCoordinatorImpl() override;
+
+ protected:
+ void OnChildAdded() override;
+ void OnChildRemoved() override;
+
+ private:
+ friend struct MemoryCoordinatorSingletonTraits;
+
+ // This struct holds some parameters to determine the global state.
+ struct Configuration {
+ int pressure_threshold_mb;
+ size_t num_children_until_suspended;
+ base::TimeDelta minimum_transition_period;
+ };
+
+ void UpdateState();
+ void NotifyStateToClients();
+ void NotifyStateToChildren();
+
+ using MemoryState = base::MemoryState;
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698