frame_audible_voter.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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_EXECUTION_CONTEXT_PRIORITY_FRAME_AUDIBLE_VOTER_H_
  5. #define COMPONENTS_PERFORMANCE_MANAGER_EXECUTION_CONTEXT_PRIORITY_FRAME_AUDIBLE_VOTER_H_
  6. #include "components/performance_manager/public/execution_context_priority/execution_context_priority.h"
  7. #include "components/performance_manager/public/graph/frame_node.h"
  8. namespace performance_manager {
  9. namespace execution_context_priority {
  10. // This voter casts a TaskPriority::USER_VISIBLE vote to all audible frames, and
  11. // a TaskPriority::LOWEST vote to non-audible frames.
  12. class FrameAudibleVoter : public FrameNode::ObserverDefaultImpl {
  13. public:
  14. static const char kFrameAudibleReason[];
  15. FrameAudibleVoter();
  16. ~FrameAudibleVoter() override;
  17. FrameAudibleVoter(const FrameAudibleVoter&) = delete;
  18. FrameAudibleVoter& operator=(const FrameAudibleVoter&) = delete;
  19. // Sets the voting channel where the votes will be cast.
  20. void SetVotingChannel(VotingChannel voting_channel);
  21. // FrameNodeObserver:
  22. void OnFrameNodeAdded(const FrameNode* frame_node) override;
  23. void OnBeforeFrameNodeRemoved(const FrameNode* frame_node) override;
  24. void OnIsAudibleChanged(const FrameNode* frame_node) override;
  25. private:
  26. VotingChannel voting_channel_;
  27. };
  28. } // namespace execution_context_priority
  29. } // namespace performance_manager
  30. #endif // COMPONENTS_PERFORMANCE_MANAGER_EXECUTION_CONTEXT_PRIORITY_FRAME_AUDIBLE_VOTER_H_