| 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_MOJO_IMPL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 // Cached list of sinks for the query, if |has_cached_result| is true. | 154 // Cached list of sinks for the query, if |has_cached_result| is true. |
| 155 // Empty otherwise. | 155 // Empty otherwise. |
| 156 std::vector<MediaSink> cached_sink_list; | 156 std::vector<MediaSink> cached_sink_list; |
| 157 base::ObserverList<MediaSinksObserver> observers; | 157 base::ObserverList<MediaSinksObserver> observers; |
| 158 | 158 |
| 159 private: | 159 private: |
| 160 DISALLOW_COPY_AND_ASSIGN(MediaSinksQuery); | 160 DISALLOW_COPY_AND_ASSIGN(MediaSinksQuery); |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 // Represents a query to the MRPM for media sinks with a certain sink ID and |
| 164 // holds observers for the query. This struct owns the observers because after |
| 165 // they are notified they need to be destroyed. |
| 166 struct MediaSinksSearchQuery { |
| 167 public: |
| 168 MediaSinksSearchQuery(); |
| 169 ~MediaSinksSearchQuery(); |
| 170 |
| 171 std::vector<scoped_ptr<MediaSinksSearchRequest>> observers; |
| 172 |
| 173 private: |
| 174 DISALLOW_COPY_AND_ASSIGN(MediaSinksSearchQuery); |
| 175 }; |
| 176 |
| 163 struct MediaRoutesQuery { | 177 struct MediaRoutesQuery { |
| 164 public: | 178 public: |
| 165 MediaRoutesQuery(); | 179 MediaRoutesQuery(); |
| 166 ~MediaRoutesQuery(); | 180 ~MediaRoutesQuery(); |
| 167 | 181 |
| 168 // True if the query has been sent to the MRPM. False otherwise. | 182 // True if the query has been sent to the MRPM. False otherwise. |
| 169 bool is_active = false; | 183 bool is_active = false; |
| 170 base::ObserverList<MediaRoutesObserver> observers; | 184 base::ObserverList<MediaRoutesObserver> observers; |
| 171 | 185 |
| 172 private: | 186 private: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 195 // Dispatches the Mojo requests queued in |pending_requests_|. | 209 // Dispatches the Mojo requests queued in |pending_requests_|. |
| 196 void ExecutePendingRequests(); | 210 void ExecutePendingRequests(); |
| 197 | 211 |
| 198 // Drops all pending requests. Called when we have a connection error to | 212 // Drops all pending requests. Called when we have a connection error to |
| 199 // component extension and further reattempts are unlikely to help. | 213 // component extension and further reattempts are unlikely to help. |
| 200 void DrainPendingRequests(); | 214 void DrainPendingRequests(); |
| 201 | 215 |
| 202 // MediaRouter implementation. | 216 // MediaRouter implementation. |
| 203 bool RegisterMediaSinksObserver(MediaSinksObserver* observer) override; | 217 bool RegisterMediaSinksObserver(MediaSinksObserver* observer) override; |
| 204 void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override; | 218 void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override; |
| 219 bool RegisterMediaSinksSearchRequest( |
| 220 scoped_ptr<MediaSinksSearchRequest> request) override; |
| 205 void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override; | 221 void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override; |
| 206 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override; | 222 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override; |
| 207 void RegisterIssuesObserver(IssuesObserver* observer) override; | 223 void RegisterIssuesObserver(IssuesObserver* observer) override; |
| 208 void UnregisterIssuesObserver(IssuesObserver* observer) override; | 224 void UnregisterIssuesObserver(IssuesObserver* observer) override; |
| 209 void RegisterPresentationSessionMessagesObserver( | 225 void RegisterPresentationSessionMessagesObserver( |
| 210 PresentationSessionMessagesObserver* observer) override; | 226 PresentationSessionMessagesObserver* observer) override; |
| 211 void UnregisterPresentationSessionMessagesObserver( | 227 void UnregisterPresentationSessionMessagesObserver( |
| 212 PresentationSessionMessagesObserver* observer) override; | 228 PresentationSessionMessagesObserver* observer) override; |
| 213 | 229 |
| 214 // These calls invoke methods in the component extension via Mojo. | 230 // These calls invoke methods in the component extension via Mojo. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 240 const SendRouteMessageCallback& callback); | 256 const SendRouteMessageCallback& callback); |
| 241 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, | 257 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, |
| 242 scoped_ptr<std::vector<uint8_t>> data, | 258 scoped_ptr<std::vector<uint8_t>> data, |
| 243 const SendRouteMessageCallback& callback); | 259 const SendRouteMessageCallback& callback); |
| 244 void DoListenForRouteMessages(const MediaRoute::Id& route_id); | 260 void DoListenForRouteMessages(const MediaRoute::Id& route_id); |
| 245 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); | 261 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); |
| 246 void DoStartObservingMediaSinks(const MediaSource::Id& source_id); | 262 void DoStartObservingMediaSinks(const MediaSource::Id& source_id); |
| 247 void DoStopObservingMediaSinks(const MediaSource::Id& source_id); | 263 void DoStopObservingMediaSinks(const MediaSource::Id& source_id); |
| 248 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id); | 264 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id); |
| 249 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id); | 265 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id); |
| 266 void DoSearchProviders(const MediaSource::Id& source_id, |
| 267 const MediaSink::Id& sink_id); |
| 250 | 268 |
| 251 // Invoked when the next batch of messages arrives. | 269 // Invoked when the next batch of messages arrives. |
| 252 // |route_id|: ID of route of the messages. | 270 // |route_id|: ID of route of the messages. |
| 253 // |messages|: A list of messages received. | 271 // |messages|: A list of messages received. |
| 254 // |error|: true if an error occurred. | 272 // |error|: true if an error occurred. |
| 255 void OnRouteMessagesReceived( | 273 void OnRouteMessagesReceived( |
| 256 const MediaRoute::Id& route_id, | 274 const MediaRoute::Id& route_id, |
| 257 mojo::Array<interfaces::RouteMessagePtr> messages, | 275 mojo::Array<interfaces::RouteMessagePtr> messages, |
| 258 bool error); | 276 bool error); |
| 259 | 277 |
| 260 // Error handler callback for |binding_| and |media_route_provider_|. | 278 // Error handler callback for |binding_| and |media_route_provider_|. |
| 261 void OnConnectionError(); | 279 void OnConnectionError(); |
| 262 | 280 |
| 263 // interfaces::MediaRouter implementation. | 281 // interfaces::MediaRouter implementation. |
| 264 void RegisterMediaRouteProvider( | 282 void RegisterMediaRouteProvider( |
| 265 interfaces::MediaRouteProviderPtr media_route_provider_ptr, | 283 interfaces::MediaRouteProviderPtr media_route_provider_ptr, |
| 266 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& | 284 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& |
| 267 callback) override; | 285 callback) override; |
| 268 void OnIssue(interfaces::IssuePtr issue) override; | 286 void OnIssue(interfaces::IssuePtr issue) override; |
| 269 void OnSinksReceived(const mojo::String& media_source, | 287 void OnSinksReceived(const mojo::String& media_source, |
| 270 mojo::Array<interfaces::MediaSinkPtr> sinks) override; | 288 mojo::Array<interfaces::MediaSinkPtr> sinks) override; |
| 289 void OnSearchSinksReceived( |
| 290 const mojo::String& sink_id, |
| 291 mojo::Array<interfaces::MediaSinkPtr> sinks) override; |
| 271 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes, | 292 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes, |
| 272 const mojo::String& media_source, | 293 const mojo::String& media_source, |
| 273 mojo::Array<mojo::String> joinable_route_ids) override; | 294 mojo::Array<mojo::String> joinable_route_ids) override; |
| 274 void OnSinkAvailabilityUpdated( | 295 void OnSinkAvailabilityUpdated( |
| 275 interfaces::MediaRouter::SinkAvailability availability) override; | 296 interfaces::MediaRouter::SinkAvailability availability) override; |
| 276 void OnPresentationConnectionStateChanged( | 297 void OnPresentationConnectionStateChanged( |
| 277 const mojo::String& route_id, | 298 const mojo::String& route_id, |
| 278 interfaces::MediaRouter::PresentationConnectionState state) override; | 299 interfaces::MediaRouter::PresentationConnectionState state) override; |
| 279 void OnPresentationConnectionClosed( | 300 void OnPresentationConnectionClosed( |
| 280 const mojo::String& route_id, | 301 const mojo::String& route_id, |
| 281 interfaces::MediaRouter::PresentationConnectionCloseReason reason, | 302 interfaces::MediaRouter::PresentationConnectionCloseReason reason, |
| 282 const mojo::String& message) override; | 303 const mojo::String& message) override; |
| 283 | 304 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 314 // Clears the wake reason after the extension has been awoken. | 335 // Clears the wake reason after the extension has been awoken. |
| 315 void ClearWakeReason(); | 336 void ClearWakeReason(); |
| 316 | 337 |
| 317 // Pending requests queued to be executed once component extension | 338 // Pending requests queued to be executed once component extension |
| 318 // becomes ready. | 339 // becomes ready. |
| 319 std::deque<base::Closure> pending_requests_; | 340 std::deque<base::Closure> pending_requests_; |
| 320 | 341 |
| 321 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaSinksQuery>> | 342 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaSinksQuery>> |
| 322 sinks_queries_; | 343 sinks_queries_; |
| 323 | 344 |
| 345 std::unordered_map<MediaSink::Id, scoped_ptr<MediaSinksSearchQuery>> |
| 346 search_queries_; |
| 347 |
| 324 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaRoutesQuery>> | 348 base::ScopedPtrHashMap<MediaSource::Id, scoped_ptr<MediaRoutesQuery>> |
| 325 routes_queries_; | 349 routes_queries_; |
| 326 | 350 |
| 327 using PresentationSessionMessagesObserverList = | 351 using PresentationSessionMessagesObserverList = |
| 328 base::ObserverList<PresentationSessionMessagesObserver>; | 352 base::ObserverList<PresentationSessionMessagesObserver>; |
| 329 base::ScopedPtrHashMap<MediaRoute::Id, | 353 base::ScopedPtrHashMap<MediaRoute::Id, |
| 330 scoped_ptr<PresentationSessionMessagesObserverList>> | 354 scoped_ptr<PresentationSessionMessagesObserverList>> |
| 331 messages_observers_; | 355 messages_observers_; |
| 332 | 356 |
| 333 // IDs of MediaRoutes being listened for messages. Note that this is | 357 // IDs of MediaRoutes being listened for messages. Note that this is |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 MediaRouteProviderWakeReason current_wake_reason_; | 396 MediaRouteProviderWakeReason current_wake_reason_; |
| 373 | 397 |
| 374 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 398 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
| 375 | 399 |
| 376 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 400 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 377 }; | 401 }; |
| 378 | 402 |
| 379 } // namespace media_router | 403 } // namespace media_router |
| 380 | 404 |
| 381 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ | 405 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |