performance_manager_main_thread_mechanism.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #ifndef COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_PERFORMANCE_MANAGER_MAIN_THREAD_MECHANISM_H_
  5. #define COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_PERFORMANCE_MANAGER_MAIN_THREAD_MECHANISM_H_
  6. #include "base/observer_list_types.h"
  7. #include <memory>
  8. #include <vector>
  9. namespace content {
  10. class NavigationHandle;
  11. class NavigationThrottle;
  12. } // namespace content
  13. namespace performance_manager {
  14. // Interface for implementing PerformanceManager mechanism hooks that occur on
  15. // the main thread. All methods are invoked on the main thread.
  16. class PerformanceManagerMainThreadMechanism : public base::CheckedObserver {
  17. public:
  18. using Throttles = std::vector<std::unique_ptr<content::NavigationThrottle>>;
  19. ~PerformanceManagerMainThreadMechanism() override = default;
  20. PerformanceManagerMainThreadMechanism(
  21. const PerformanceManagerMainThreadMechanism&) = delete;
  22. PerformanceManagerMainThreadMechanism& operator=(
  23. const PerformanceManagerMainThreadMechanism&) = delete;
  24. // Invoked when a NavigationHandle is committed, providing an opportunity for
  25. // the mechanism to apply throttles.
  26. virtual Throttles CreateThrottlesForNavigation(
  27. content::NavigationHandle* handle) = 0;
  28. protected:
  29. PerformanceManagerMainThreadMechanism() = default;
  30. };
  31. } // namespace performance_manager
  32. #endif // COMPONENTS_PERFORMANCE_MANAGER_PUBLIC_PERFORMANCE_MANAGER_MAIN_THREAD_MECHANISM_H_