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

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

Issue 2867353002: memory coordinator: Introduce MemoryCoordinatorImpl::Policy (Closed)
Patch Set: Tweak Created 3 years, 7 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_default_policy.h
diff --git a/content/browser/memory/memory_coordinator_default_policy.h b/content/browser/memory/memory_coordinator_default_policy.h
new file mode 100644
index 0000000000000000000000000000000000000000..599b964d428e2e36895dc60c95a6bdcd77254252
--- /dev/null
+++ b/content/browser/memory/memory_coordinator_default_policy.h
@@ -0,0 +1,43 @@
+// Copyright 2017 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_DEFAULT_POLICY_H_
+#define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_DEFAULT_POLICY_H_
+
+#include "content/browser/memory/memory_coordinator_impl.h"
+
+namespace content {
+
+// The default policy of MemoryCoordinator.
+class MemoryCoordinatorDefaultPolicy : public MemoryCoordinatorImpl::Policy {
+ public:
+ explicit MemoryCoordinatorDefaultPolicy(MemoryCoordinatorImpl* coordinator);
+ ~MemoryCoordinatorDefaultPolicy() override;
+
+ void OnWarningCondition() override;
+ void OnCriticalCondition() override;
+ void OnConditionChanged(MemoryCondition prev, MemoryCondition next) override;
+ void OnChildVisibilityChanged(int render_process_id,
+ bool is_visible) override;
+
+ private:
+ // Set the provided memory_state to all child processes.
+ void SetMemoryStateToAllChildren(MemoryState memory_state);
+
+ enum class PurgeTarget {
+ BACKGROUNDED,
+ ALL,
+ };
+
+ // Tries to find a candidate child process for purging memory and asks the
+ // child to purge memory.
+ bool TryToPurgeMemoryFromChildren(PurgeTarget target);
+
+ // Not owned.
+ MemoryCoordinatorImpl* coordinator_;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_DEFAULT_POLICY_H_

Powered by Google App Engine
This is Rietveld 408576698