| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_BASE_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_BASE_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_BASE_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_BASE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // This will terminate all incognito media routes. | 32 // This will terminate all incognito media routes. |
| 33 void OnIncognitoProfileShutdown() override; | 33 void OnIncognitoProfileShutdown() override; |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 36 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 37 PresentationConnectionStateChangedCallback); | 37 PresentationConnectionStateChangedCallback); |
| 38 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, | 38 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, |
| 39 PresentationConnectionStateChangedCallbackRemoved); | 39 PresentationConnectionStateChangedCallbackRemoved); |
| 40 FRIEND_TEST_ALL_PREFIXES(MediaRouterBaseTest, CreatePresentationIds); | 40 FRIEND_TEST_ALL_PREFIXES(MediaRouterBaseTest, CreatePresentationIds); |
| 41 FRIEND_TEST_ALL_PREFIXES(MediaRouterBaseTest, NotifyCallbacks); | 41 FRIEND_TEST_ALL_PREFIXES(MediaRouterBaseTest, NotifyCallbacks); |
| 42 FRIEND_TEST_ALL_PREFIXES(MediaRouterBaseTest, |
| 43 NotifyCallbacksPendingStateChange); |
| 42 | 44 |
| 43 MediaRouterBase(); | 45 MediaRouterBase(); |
| 44 | 46 |
| 45 // Generates a unique presentation id. Shared between Android and desktop. | 47 // Generates a unique presentation id. Shared between Android and desktop. |
| 46 static std::string CreatePresentationId(); | 48 static std::string CreatePresentationId(); |
| 47 | 49 |
| 48 void NotifyPresentationConnectionStateChange( | 50 void NotifyPresentationConnectionStateChange( |
| 49 const MediaRoute::Id& route_id, | 51 const MediaRoute::Id& route_id, |
| 50 content::PresentationConnectionState state); | 52 content::PresentationConnectionState state); |
| 51 void NotifyPresentationConnectionClose( | 53 void NotifyPresentationConnectionClose( |
| 52 const MediaRoute::Id& route_id, | 54 const MediaRoute::Id& route_id, |
| 53 content::PresentationConnectionCloseReason reason, | 55 content::PresentationConnectionCloseReason reason, |
| 54 const std::string& message); | 56 const std::string& message); |
| 57 void NotifyPresentationConnectionStateChange( |
| 58 const MediaRoute::Id& route_id, |
| 59 const content::PresentationConnectionStateChangeInfo& info); |
| 55 | 60 |
| 56 // Returns true when there is at least one MediaRoute that can be returned by | 61 // Returns true when there is at least one MediaRoute that can be returned by |
| 57 // JoinRoute(). | 62 // JoinRoute(). |
| 58 bool HasJoinableRoute() const; | 63 bool HasJoinableRoute() const; |
| 59 | 64 |
| 60 using PresentationConnectionStateChangedCallbacks = base::CallbackList<void( | 65 using PresentationConnectionStateChangedCallbacks = base::CallbackList<void( |
| 61 const content::PresentationConnectionStateChangeInfo&)>; | 66 const content::PresentationConnectionStateChangeInfo&)>; |
| 62 | 67 |
| 63 base::ScopedPtrHashMap< | 68 base::ScopedPtrHashMap< |
| 64 MediaRoute::Id, | 69 MediaRoute::Id, |
| 65 std::unique_ptr<PresentationConnectionStateChangedCallbacks>> | 70 std::unique_ptr<PresentationConnectionStateChangedCallbacks>> |
| 66 presentation_connection_state_callbacks_; | 71 presentation_connection_state_callbacks_; |
| 67 | 72 |
| 73 // Stores ConnectionStateChange events fired before |
| 74 // PresentationConnectionStateChangedCallback is registered. |
| 75 std::map<MediaRoute::Id, content::PresentationConnectionStateChangeInfo> |
| 76 queued_state_changes_; |
| 77 |
| 68 private: | 78 private: |
| 69 friend class MediaRouterFactory; | 79 friend class MediaRouterFactory; |
| 70 friend class MediaRouterMojoTest; | 80 friend class MediaRouterMojoTest; |
| 71 | 81 |
| 72 class InternalMediaRoutesObserver; | 82 class InternalMediaRoutesObserver; |
| 73 | 83 |
| 74 // Must be called before invoking any other method. | 84 // Must be called before invoking any other method. |
| 75 void Initialize(); | 85 void Initialize(); |
| 76 | 86 |
| 77 // Called when a PresentationConnectionStateChangedCallback associated with | 87 // Called when a PresentationConnectionStateChangedCallback associated with |
| 78 // |route_id| is removed from |presentation_connection_state_callbacks_|. | 88 // |route_id| is removed from |presentation_connection_state_callbacks_|. |
| 79 void OnPresentationConnectionStateCallbackRemoved( | 89 void OnPresentationConnectionStateCallbackRemoved( |
| 80 const MediaRoute::Id& route_id); | 90 const MediaRoute::Id& route_id); |
| 81 | 91 |
| 82 // KeyedService | 92 // KeyedService |
| 83 void Shutdown() override; | 93 void Shutdown() override; |
| 84 | |
| 85 std::unique_ptr<InternalMediaRoutesObserver> internal_routes_observer_; | 94 std::unique_ptr<InternalMediaRoutesObserver> internal_routes_observer_; |
| 86 bool initialized_; | 95 bool initialized_; |
| 87 | 96 |
| 88 DISALLOW_COPY_AND_ASSIGN(MediaRouterBase); | 97 DISALLOW_COPY_AND_ASSIGN(MediaRouterBase); |
| 89 }; | 98 }; |
| 90 | 99 |
| 91 } // namespace media_router | 100 } // namespace media_router |
| 92 | 101 |
| 93 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_BASE_H_ | 102 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_BASE_H_ |
| OLD | NEW |