Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_ | |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <queue> | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/callback.h" | |
| 14 #include "base/containers/hash_tables.h" | |
| 15 #include "base/gtest_prod_util.h" | |
| 16 #include "base/macros.h" | |
| 17 #include "base/memory/scoped_vector.h" | |
| 18 #include "base/threading/thread_checker.h" | |
| 19 #include "chrome/browser/media/router/media_route_provider_manager_host.h" | |
| 20 #include "chrome/browser/media/router/media_router.h" | |
| 21 #include "chrome/browser/media/router/media_sinks_observer.h" | |
| 22 #include "components/keyed_service/core/keyed_service.h" | |
| 23 | |
| 24 namespace base { | |
| 25 template <typename T> | |
| 26 struct DefaultLazyInstanceTraits; | |
| 27 } // namespace base | |
| 28 | |
| 29 namespace media_router { | |
| 30 | |
| 31 class MediaRoute; | |
| 32 class MediaRouterApiImpl; | |
| 33 class MediaRoutesObserver; | |
| 34 struct RoutesQueryResult; | |
| 35 | |
| 36 // Implementation of MediaRouter that delegates calls to | |
| 37 // MediaRouteProviderManagerHost, which in turn handles communication | |
| 38 // with the Media Route Provider Manager (MRPM). | |
| 39 // In addition, responses from MediaRouteProviderManagerHost are delegated to | |
| 40 // this class which then invokes the observers / callbacks. | |
| 41 // Instances of this class are created by MediaRouterImplFactory. | |
| 42 // MediaRouterImpl is a profile-keyed service. | |
| 43 // MediaRouterImpl runs on the browser UI thread. All observers/callbacks | |
| 44 // registered to this class must also run in the UI thread. | |
| 45 class MediaRouterImpl : public MediaRouter, | |
| 46 public KeyedService, | |
| 47 public MediaRouteProviderManagerHost::Delegate { | |
| 48 public: | |
| 49 ~MediaRouterImpl() override; | |
| 50 | |
| 51 // |mrpm_host_| must be null at the time this is called. | |
| 52 // |mrpm_host| must not be null. | |
| 53 // Does not take ownership of |mrpm_host_|. | |
| 54 // This function can only be called once. | |
| 55 void Initialize(MediaRouteProviderManagerHost* mrpm_host); | |
| 56 | |
| 57 // MediaRouter implementation. | |
| 58 RouteRequestId StartRouteRequest( | |
| 59 const MediaSource& source, | |
| 60 const MediaSinkId& sink_id, | |
| 61 const MediaRouteResponseCallback& callback) override; | |
| 62 void UnregisterMediaRouteResponseCallback( | |
| 63 const RouteRequestId& request_id) override; | |
| 64 void CloseRoute(const MediaRouteId& route_id) override; | |
| 65 bool RegisterMediaSinksObserver(MediaSinksObserver* observer) override; | |
| 66 void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override; | |
| 67 void PostMessage(const MediaRouteId& route_id, | |
| 68 const std::string& message) override; | |
| 69 bool RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override; | |
| 70 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override; | |
| 71 | |
| 72 // MediaRouteProviderManagerHost::Delegate implementation. | |
| 73 void OnMessage(const MediaRouteId& route_id, | |
| 74 const std::string& message) override; | |
| 75 void OnSinksReceived(const MediaSource& source, | |
| 76 const std::vector<MediaSink>& sinks) override; | |
| 77 void OnRouteResponseReceived(const RouteRequestId& request_id, | |
| 78 const MediaRoute& route) override; | |
| 79 void OnRouteResponseError(const RouteRequestId& request_id, | |
| 80 const std::string& error_text) override; | |
| 81 void OnRoutesUpdated( | |
| 82 const std::vector<MediaRoute>& routes, | |
| 83 const std::vector<MediaSink>& sinks) override; | |
| 84 void OnHostDestroyed(MediaRouteProviderManagerHost* host) override; | |
| 85 | |
| 86 private: | |
| 87 friend class MediaRouterImplFactory; | |
| 88 | |
| 89 // Use MediaRouterImplFactory::GetForBrowserContext(). | |
| 90 MediaRouterImpl(); | |
| 91 | |
| 92 // MRPM host to forward calls to MRPM to. | |
| 93 // Responses from MRPM are also received from this host. | |
| 94 // Not owned by this object. | |
| 95 MediaRouteProviderManagerHost* mrpm_host_; | |
|
xhwang
2015/04/02 17:13:02
Most people have no idea what "mrpm" is, use full
imcheng
2015/04/02 23:05:24
renamed to provider_manager_host_.
Yes, the class
| |
| 96 | |
| 97 DISALLOW_COPY_AND_ASSIGN(MediaRouterImpl); | |
| 98 }; | |
| 99 | |
| 100 } // namespace media_router | |
| 101 | |
| 102 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_IMPL_H_ | |
| OLD | NEW |