Chromium Code Reviews| Index: chrome/browser/media/router/media_router_base.h |
| diff --git a/chrome/browser/media/router/media_router_base.h b/chrome/browser/media/router/media_router_base.h |
| index e95fa177cdab3b2951b6f97b4bfdfa6375e82dd7..bb2697b8b38056c366091ac35775293b74fae424 100644 |
| --- a/chrome/browser/media/router/media_router_base.h |
| +++ b/chrome/browser/media/router/media_router_base.h |
| @@ -6,21 +6,21 @@ |
| #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_BASE_H_ |
| #include <set> |
| +#include <vector> |
| #include "base/callback_list.h" |
| #include "base/containers/scoped_ptr_hash_map.h" |
| #include "base/gtest_prod_util.h" |
| #include "base/macros.h" |
| #include "base/threading/thread_checker.h" |
| +#include "chrome/browser/media/router/media_route.h" |
| #include "chrome/browser/media/router/media_router.h" |
| - |
| -class Profile; |
| +#include "chrome/browser/media/router/media_routes_observer.h" |
| namespace media_router { |
| class MediaRouterBase : public MediaRouter { |
| public: |
| - MediaRouterBase(); |
| ~MediaRouterBase() override; |
| std::unique_ptr<PresentationConnectionStateSubscription> |
| @@ -39,6 +39,8 @@ class MediaRouterBase : public MediaRouter { |
| FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| PresentationConnectionStateChangedCallbackRemoved); |
| + MediaRouterBase(); |
| + |
| // Generates a unique presentation id. Shared between Android and desktop. |
| static std::string CreatePresentationId(); |
| @@ -50,13 +52,12 @@ class MediaRouterBase : public MediaRouter { |
| content::PresentationConnectionCloseReason reason, |
| const std::string& message); |
| - // Called when off the record route |route_id| has been created. |
| - void OnOffTheRecordRouteCreated(const MediaRoute::Id& route_id); |
| - // Called when route |route_id| has been terminated. |
| - void OnRouteTerminated(const MediaRoute::Id& route_id); |
| + // Returns true when there is at least one MediaRoute with is_local = true. |
| + bool HasLocalRoute() const; |
| using PresentationConnectionStateChangedCallbacks = base::CallbackList<void( |
| const content::PresentationConnectionStateChangeInfo&)>; |
| + |
| base::ScopedPtrHashMap< |
| MediaRoute::Id, |
| std::unique_ptr<PresentationConnectionStateChangedCallbacks>> |
| @@ -65,13 +66,41 @@ class MediaRouterBase : public MediaRouter { |
| base::ThreadChecker thread_checker_; |
| private: |
| + friend class MediaRouterFactory; |
| + friend class MediaRouterMojoTest; |
| + |
| + // Must be called before invoking any other method. |
| + void Initialize(); |
| + |
| + // A MediaRoutesObserver that maintains state about the current set of media |
| + // routes. |
| + class InternalMediaRoutesObserver : public MediaRoutesObserver { |
| + public: |
| + explicit InternalMediaRoutesObserver(MediaRouter* router); |
| + ~InternalMediaRoutesObserver() override; |
| + |
| + // MediaRoutesObserver |
| + void OnRoutesUpdated( |
| + const std::vector<MediaRoute>& routes, |
| + const std::vector<MediaRoute::Id>& joinable_route_ids) override; |
| + |
| + bool has_local_route; |
|
imcheng
2016/04/25 18:59:54
nit: prefer moving member variables to private and
mark a. foltz
2016/04/26 21:11:10
This entire class is a private implementation deta
|
| + std::vector<MediaRoute::Id> off_the_record_route_ids; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(InternalMediaRoutesObserver); |
| + }; |
| + |
| // Called when a PresentationConnectionStateChangedCallback associated with |
| // |route_id| is removed from |presentation_connection_state_callbacks_|. |
| void OnPresentationConnectionStateCallbackRemoved( |
| const MediaRoute::Id& route_id); |
| - // Ids of current off the record media routes. |
| - std::set<MediaRoute::Id> off_the_record_route_ids_; |
| + // KeyedService |
| + void Shutdown() override; |
| + |
| + std::unique_ptr<InternalMediaRoutesObserver> internal_routes_observer_; |
| + bool initialized_; |
| DISALLOW_COPY_AND_ASSIGN(MediaRouterBase); |
| }; |