Chromium Code Reviews| Index: third_party/WebKit/Source/platform/instrumentation/resource_coordinator/FrameResourceCoordinator.cpp |
| diff --git a/third_party/WebKit/Source/platform/instrumentation/resource_coordinator/FrameResourceCoordinator.cpp b/third_party/WebKit/Source/platform/instrumentation/resource_coordinator/FrameResourceCoordinator.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..becd3bfe13b22ea3d1f42112e84a5740fc1f648e |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/instrumentation/resource_coordinator/FrameResourceCoordinator.cpp |
| @@ -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 "platform/instrumentation/resource_coordinator/FrameResourceCoordinator.h" |
| + |
| +#include "public/platform/InterfaceProvider.h" |
| +#include "public/platform/Platform.h" |
| +#include "services/resource_coordinator/public/cpp/resource_coordinator_features.h" |
| +#include "services/resource_coordinator/public/interfaces/coordination_unit_provider.mojom-blink.h" |
| + |
| +namespace blink { |
| + |
| +namespace { |
| + |
| +void onConnectionError() {} |
| + |
| +} // namespace |
| + |
| +// static |
| +bool FrameResourceCoordinator::IsEnabled() { |
| + return base::FeatureList::IsEnabled(features::kGlobalResourceCoordinator); |
|
haraken
2017/06/02 04:28:30
It's fine to use base::FeatureList in platform/ bu
lpy
2017/06/02 20:23:52
Done.
|
| +} |
| + |
| +// static |
| +FrameResourceCoordinator* FrameResourceCoordinator::Create( |
| + InterfaceProvider* interface_provider) { |
| + return new FrameResourceCoordinator(interface_provider); |
| +} |
| + |
| +FrameResourceCoordinator::FrameResourceCoordinator( |
| + InterfaceProvider* interface_provider) { |
| + interface_provider->GetInterface(mojo::MakeRequest(&service_)); |
| + |
| + service_.set_connection_error_handler( |
| + ConvertToBaseCallback(WTF::Bind(&onConnectionError))); |
| + |
| + resource_coordinator::mojom::blink::EventPtr event = |
| + resource_coordinator::mojom::blink::Event::New(); |
| + event->type = resource_coordinator::mojom::EventType::kOnRendererFrameCreated; |
| + service_->SendEvent(std::move(event)); |
| +} |
| + |
| +FrameResourceCoordinator::~FrameResourceCoordinator() = default; |
| + |
| +DEFINE_TRACE(FrameResourceCoordinator) {} |
| + |
| +} // namespace blink |