| Index: services/resource_coordinator/coordination_unit/frame_coordination_unit_impl.cc
|
| diff --git a/services/resource_coordinator/coordination_unit/frame_coordination_unit_impl.cc b/services/resource_coordinator/coordination_unit/frame_coordination_unit_impl.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a64d1c1f02826b3b32369c096061d46faa04fa61
|
| --- /dev/null
|
| +++ b/services/resource_coordinator/coordination_unit/frame_coordination_unit_impl.cc
|
| @@ -0,0 +1,48 @@
|
| +// 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.
|
| +
|
| +#include "services/resource_coordinator/coordination_unit/frame_coordination_unit_impl.h"
|
| +
|
| +#include <utility>
|
| +
|
| +namespace service_manager {
|
| +class ServiceContextRef;
|
| +}
|
| +
|
| +namespace resource_coordinator {
|
| +
|
| +struct CoordinationUnitID;
|
| +
|
| +FrameCoordinationUnitImpl::FrameCoordinationUnitImpl(
|
| + const CoordinationUnitID& id,
|
| + std::unique_ptr<service_manager::ServiceContextRef> service_ref)
|
| + : CoordinationUnitImpl(id, std::move(service_ref)) {}
|
| +
|
| +FrameCoordinationUnitImpl::~FrameCoordinationUnitImpl() = default;
|
| +
|
| +std::set<CoordinationUnitImpl*>
|
| +FrameCoordinationUnitImpl::GetAssociatedCoordinationUnitsOfType(
|
| + CoordinationUnitType type) {
|
| + switch (type) {
|
| + case CoordinationUnitType::kProcess:
|
| + case CoordinationUnitType::kWebContents:
|
| + // Processes and WebContents are only associated with a frame if
|
| + // they are a direct parents of the frame.
|
| + return GetParentCoordinationUnitsOfType(type);
|
| + case CoordinationUnitType::kFrame: {
|
| + // Frame association is recursive: any frame connected to a frame the
|
| + // frame is connected to are all associated with one another.
|
| + auto frame_coordination_units = GetChildCoordinationUnitsOfType(type);
|
| + for (auto* frame_coordination_unit :
|
| + GetParentCoordinationUnitsOfType(type)) {
|
| + frame_coordination_units.insert(frame_coordination_unit);
|
| + }
|
| + return frame_coordination_units;
|
| + }
|
| + default:
|
| + return std::set<CoordinationUnitImpl*>();
|
| + }
|
| +}
|
| +
|
| +} // namespace resource_coordinator
|
|
|