| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_CAST_REMOTING_CONNECTOR_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_H_ |
| 6 #define CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_H_ | 6 #define CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // back-and-forth between a CastRemotingConnector and a | 94 // back-and-forth between a CastRemotingConnector and a |
| 95 // media::mojom::RemotingSource. An instance of this class is owned by its | 95 // media::mojom::RemotingSource. An instance of this class is owned by its |
| 96 // mojo message pipe. | 96 // mojo message pipe. |
| 97 class RemotingBridge; | 97 class RemotingBridge; |
| 98 | 98 |
| 99 // A RouteMessageObserver for the remoting route that passes messages from the | 99 // A RouteMessageObserver for the remoting route that passes messages from the |
| 100 // Cast Provider back to this connector. An instance of this class only exists | 100 // Cast Provider back to this connector. An instance of this class only exists |
| 101 // while a remoting route is available, and is owned by CastRemotingConnector. | 101 // while a remoting route is available, and is owned by CastRemotingConnector. |
| 102 class MessageObserver; | 102 class MessageObserver; |
| 103 | 103 |
| 104 // Main constructor. |route_source_id| is the remoting route source specific | 104 // Main constructor. |media_source_id| refers to any remoted content managed |
| 105 // to one tab (WebContents). | 105 // by this instance (i.e., any remoted content from one tab/WebContents). |
| 106 CastRemotingConnector(media_router::MediaRouter* router, | 106 CastRemotingConnector(media_router::MediaRouter* router, |
| 107 const media_router::MediaSource::Id& route_source_id); | 107 const media_router::MediaSource::Id& media_source_id); |
| 108 | 108 |
| 109 ~CastRemotingConnector() final; | 109 ~CastRemotingConnector() final; |
| 110 | 110 |
| 111 // Creates a RemotingBridge that implements the requested Remoter service, and | 111 // Creates a RemotingBridge that implements the requested Remoter service, and |
| 112 // binds it to the interface |request|. | 112 // binds it to the interface |request|. |
| 113 void CreateBridge(media::mojom::RemotingSourcePtr source, | 113 void CreateBridge(media::mojom::RemotingSourcePtr source, |
| 114 media::mojom::RemoterRequest request); | 114 media::mojom::RemoterRequest request); |
| 115 | 115 |
| 116 // Called by the RemotingBridge constructor/destructor to register/deregister | 116 // Called by the RemotingBridge constructor/destructor to register/deregister |
| 117 // an instance. This allows this connector to broadcast notifications to all | 117 // an instance. This allows this connector to broadcast notifications to all |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 void OnDataSendFailed(); | 155 void OnDataSendFailed(); |
| 156 | 156 |
| 157 // MediaRoutesObserver implementation: Scans |routes| to check whether the | 157 // MediaRoutesObserver implementation: Scans |routes| to check whether the |
| 158 // existing remoting route has gone away and/or there is a new remoting route | 158 // existing remoting route has gone away and/or there is a new remoting route |
| 159 // established, and take the necessary actions to notify sources and/or | 159 // established, and take the necessary actions to notify sources and/or |
| 160 // shutdown an active remoting session. | 160 // shutdown an active remoting session. |
| 161 void OnRoutesUpdated( | 161 void OnRoutesUpdated( |
| 162 const std::vector<media_router::MediaRoute>& routes, | 162 const std::vector<media_router::MediaRoute>& routes, |
| 163 const std::vector<media_router::MediaRoute::Id>& ignored) final; | 163 const std::vector<media_router::MediaRoute::Id>& ignored) final; |
| 164 | 164 |
| 165 // The MediaSource ID referring to any remoted content managed by this |
| 166 // CastRemotingConnector. |
| 167 const media_router::MediaSource::Id media_source_id_; |
| 168 |
| 165 // Set of registered RemotingBridges, maintained by RegisterBridge() and | 169 // Set of registered RemotingBridges, maintained by RegisterBridge() and |
| 166 // DeregisterBridge(). These pointers are always valid while they are in this | 170 // DeregisterBridge(). These pointers are always valid while they are in this |
| 167 // set. | 171 // set. |
| 168 std::set<RemotingBridge*> bridges_; | 172 std::set<RemotingBridge*> bridges_; |
| 169 | 173 |
| 170 // Created when the Media Router Cast Provider has created a media remoting | 174 // Created when the Media Router Cast Provider has created a media remoting |
| 171 // route to a sink that supports remoting and is available for use. This | 175 // route to a sink that supports remoting and is available for use. This |
| 172 // observer simply dispatches messages from the Cast Provider and sink back to | 176 // observer simply dispatches messages from the Cast Provider and sink back to |
| 173 // this connector. Once the route is gone, this is reset to null. | 177 // this connector. Once the route is gone, this is reset to null. |
| 174 std::unique_ptr<MessageObserver> message_observer_; | 178 std::unique_ptr<MessageObserver> message_observer_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 196 base::WeakPtrFactory<CastRemotingConnector> weak_factory_; | 200 base::WeakPtrFactory<CastRemotingConnector> weak_factory_; |
| 197 | 201 |
| 198 // Key used with the base::SupportsUserData interface to search for an | 202 // Key used with the base::SupportsUserData interface to search for an |
| 199 // instance of CastRemotingConnector owned by a WebContents. | 203 // instance of CastRemotingConnector owned by a WebContents. |
| 200 static const void* const kUserDataKey; | 204 static const void* const kUserDataKey; |
| 201 | 205 |
| 202 DISALLOW_COPY_AND_ASSIGN(CastRemotingConnector); | 206 DISALLOW_COPY_AND_ASSIGN(CastRemotingConnector); |
| 203 }; | 207 }; |
| 204 | 208 |
| 205 #endif // CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_H_ | 209 #endif // CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_H_ |
| OLD | NEW |