graph_features.cc 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/performance_manager/embedder/graph_features.h"
  5. #include <memory>
  6. #include "build/build_config.h"
  7. #include "components/performance_manager/decorators/frame_visibility_decorator.h"
  8. #include "components/performance_manager/decorators/freezing_vote_decorator.h"
  9. #include "components/performance_manager/decorators/page_load_tracker_decorator.h"
  10. #include "components/performance_manager/decorators/process_hosted_content_types_aggregator.h"
  11. #include "components/performance_manager/execution_context/execution_context_registry_impl.h"
  12. #include "components/performance_manager/execution_context_priority/execution_context_priority_decorator.h"
  13. #include "components/performance_manager/graph/frame_node_impl_describer.h"
  14. #include "components/performance_manager/graph/page_node_impl_describer.h"
  15. #include "components/performance_manager/graph/process_node_impl_describer.h"
  16. #include "components/performance_manager/graph/worker_node_impl_describer.h"
  17. #include "components/performance_manager/public/decorators/page_live_state_decorator.h"
  18. #include "components/performance_manager/public/graph/graph.h"
  19. #include "components/performance_manager/public/metrics/metrics_collector.h"
  20. #include "components/performance_manager/v8_memory/v8_context_tracker.h"
  21. #include "components/performance_manager/v8_memory/web_memory_stress_tester.h"
  22. #if !BUILDFLAG(IS_ANDROID)
  23. #include "components/performance_manager/public/decorators/site_data_recorder.h"
  24. #endif
  25. namespace performance_manager {
  26. namespace {
  27. template <typename ObjectType>
  28. void Install(Graph* graph) {
  29. graph->PassToGraph(std::make_unique<ObjectType>());
  30. }
  31. } // namespace
  32. void GraphFeatures::ConfigureGraph(Graph* graph) const {
  33. if (flags_.execution_context_registry)
  34. Install<execution_context::ExecutionContextRegistryImpl>(graph);
  35. if (flags_.frame_node_impl_describer)
  36. Install<FrameNodeImplDescriber>(graph);
  37. if (flags_.frame_visibility_decorator)
  38. Install<FrameVisibilityDecorator>(graph);
  39. if (flags_.metrics_collector)
  40. Install<MetricsCollector>(graph);
  41. if (flags_.freezing_vote_decorator)
  42. Install<FreezingVoteDecorator>(graph);
  43. if (flags_.page_live_state_decorator)
  44. Install<PageLiveStateDecorator>(graph);
  45. if (flags_.page_load_tracker_decorator)
  46. Install<PageLoadTrackerDecorator>(graph);
  47. if (flags_.page_node_impl_describer)
  48. Install<PageNodeImplDescriber>(graph);
  49. if (flags_.process_hosted_content_types_aggregator)
  50. Install<ProcessHostedContentTypesAggregator>(graph);
  51. if (flags_.process_node_impl_describer)
  52. Install<ProcessNodeImplDescriber>(graph);
  53. if (flags_.worker_node_impl_describer)
  54. Install<WorkerNodeImplDescriber>(graph);
  55. #if !BUILDFLAG(IS_ANDROID)
  56. if (flags_.site_data_recorder)
  57. Install<SiteDataRecorder>(graph);
  58. #endif
  59. // These classes have a dependency on ExecutionContextRegistry, so must be
  60. // installed after it.
  61. if (flags_.execution_context_priority_decorator) {
  62. Install<execution_context_priority::ExecutionContextPriorityDecorator>(
  63. graph);
  64. }
  65. if (flags_.v8_context_tracker) {
  66. Install<v8_memory::V8ContextTracker>(graph);
  67. if (v8_memory::WebMeasureMemoryStressTester::FeatureIsEnabled())
  68. Install<v8_memory::WebMeasureMemoryStressTester>(graph);
  69. }
  70. }
  71. } // namespace performance_manager