Refactor RenderProcessHostImpl widget aggregation
Combine updating visibility and importance of a widget into a single
call on RenderProcessHost to update its priority. RPH keeps track of
the priority of each widget (client) and aggregates over them to
compute the effective priority of the process.
This CL is meant to be a pure refactor with no behavior changes.
There are few reasons for this design for future changes:
* New fields are going to be added, so combining them into a single
struct will adding new fields easier.
* New fields will not be independent, but have meaning that depends on
existing priority. Tracking fields independently will lead to
incorrect result; see crbug.com/813232#c12. So they have to be
updated together.
* Wording has been changed from "widget" to "client" so that workers
can also contribute priority to RPH in the future.
Bug: 813232
Change-Id: Iaa6877af5010100562655be6b1aa2951219d67b5
Reviewed-on: https://chromium-review.googlesource.com/933224
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Alex Moshchuk <[email protected]>
Commit-Queue: Bo <[email protected]>
Cr-Commit-Position: refs/heads/master@{#544824}
diff --git a/components/visitedlink/test/visitedlink_unittest.cc b/components/visitedlink/test/visitedlink_unittest.cc
index cde6fc1..7e91065 100644
--- a/components/visitedlink/test/visitedlink_unittest.cc
+++ b/components/visitedlink/test/visitedlink_unittest.cc
@@ -602,7 +602,7 @@
explicit VisitRelayingRenderProcessHost(
content::BrowserContext* browser_context,
VisitCountingContext* context)
- : MockRenderProcessHost(browser_context), widgets_(0) {
+ : MockRenderProcessHost(browser_context) {
OverrideBinderForTesting(
mojom::VisitedLinkNotificationSink::Name_,
base::Bind(&VisitCountingContext::Bind, base::Unretained(context)));
@@ -618,13 +618,7 @@
content::NotificationService::NoDetails());
}
- void WidgetRestored() override { widgets_++; }
- void WidgetHidden() override { widgets_--; }
- int VisibleWidgetCount() const override { return widgets_; }
-
private:
- int widgets_;
-
DISALLOW_COPY_AND_ASSIGN(VisitRelayingRenderProcessHost);
};