issues_observer.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2015 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_MEDIA_ROUTER_BROWSER_ISSUES_OBSERVER_H_
  5. #define COMPONENTS_MEDIA_ROUTER_BROWSER_ISSUES_OBSERVER_H_
  6. #include "base/memory/raw_ptr.h"
  7. #include "components/media_router/common/issue.h"
  8. namespace media_router {
  9. class IssueManager;
  10. // Base class for observing Media Router related Issues. IssueObserver will
  11. // receive at most one Issue at any given time.
  12. // TODO(imcheng): Combine this with issue_manager.{h,cc}.
  13. class IssuesObserver {
  14. public:
  15. explicit IssuesObserver(IssueManager* issue_manager);
  16. IssuesObserver(const IssuesObserver&) = delete;
  17. IssuesObserver& operator=(const IssuesObserver&) = delete;
  18. virtual ~IssuesObserver();
  19. // Registers with |issue_manager_| to start observing for Issues. No-ops if
  20. // Init() has already been called before.
  21. void Init();
  22. // Called when there is an updated Issue.
  23. // Note that |issue| is owned by the IssueManager that is calling the
  24. // observers. Implementations that wish to retain the data must make a copy
  25. // of |issue|.
  26. virtual void OnIssue(const Issue& issue) {}
  27. // Called when there are no more issues.
  28. virtual void OnIssuesCleared() {}
  29. private:
  30. const raw_ptr<IssueManager> issue_manager_;
  31. bool initialized_;
  32. };
  33. } // namespace media_router
  34. #endif // COMPONENTS_MEDIA_ROUTER_BROWSER_ISSUES_OBSERVER_H_