tether_controller.cc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 "ash/components/phonehub/tether_controller.h"
  5. namespace ash {
  6. namespace phonehub {
  7. TetherController::TetherController() = default;
  8. TetherController::~TetherController() = default;
  9. void TetherController::AddObserver(Observer* observer) {
  10. observer_list_.AddObserver(observer);
  11. }
  12. void TetherController::RemoveObserver(Observer* observer) {
  13. observer_list_.RemoveObserver(observer);
  14. }
  15. void TetherController::NotifyStatusChanged() {
  16. for (auto& observer : observer_list_)
  17. observer.OnTetherStatusChanged();
  18. }
  19. void TetherController::NotifyAttemptConnectionScanFailed() {
  20. for (auto& observer : observer_list_)
  21. observer.OnAttemptConnectionScanFailed();
  22. }
  23. std::ostream& operator<<(std::ostream& stream,
  24. TetherController::Status status) {
  25. switch (status) {
  26. case TetherController::Status::kIneligibleForFeature:
  27. stream << "[Ineligible for feature]";
  28. break;
  29. case TetherController::Status::kConnectionUnavailable:
  30. stream << "[Connection unavailable]";
  31. break;
  32. case TetherController::Status::kConnectionAvailable:
  33. stream << "[Connection available]";
  34. break;
  35. case TetherController::Status::kConnecting:
  36. stream << "[Connecting]";
  37. break;
  38. case TetherController::Status::kConnected:
  39. stream << "[Connected]";
  40. break;
  41. case TetherController::Status::kNoReception:
  42. stream << "[No Reception]";
  43. break;
  44. }
  45. return stream;
  46. }
  47. } // namespace phonehub
  48. } // namespace ash