| 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 <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/containers/scoped_ptr_hash_map.h" | 15 #include "base/containers/scoped_ptr_hash_map.h" |
| 16 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | |
| 19 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 21 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
| 22 #include "base/thread_task_runner_handle.h" | 21 #include "base/thread_task_runner_handle.h" |
| 23 #include "base/threading/thread_checker.h" | |
| 24 #include "chrome/browser/media/router/issue.h" | 22 #include "chrome/browser/media/router/issue.h" |
| 25 #include "chrome/browser/media/router/issue_manager.h" | 23 #include "chrome/browser/media/router/issue_manager.h" |
| 26 #include "chrome/browser/media/router/media_router.h" | |
| 27 #include "chrome/browser/media/router/media_router.mojom.h" | 24 #include "chrome/browser/media/router/media_router.mojom.h" |
| 25 #include "chrome/browser/media/router/media_router_base.h" |
| 28 #include "chrome/browser/media/router/media_routes_observer.h" | 26 #include "chrome/browser/media/router/media_routes_observer.h" |
| 29 #include "mojo/public/cpp/bindings/binding.h" | 27 #include "mojo/public/cpp/bindings/binding.h" |
| 30 | 28 |
| 31 namespace content { | 29 namespace content { |
| 32 class BrowserContext; | 30 class BrowserContext; |
| 33 } | 31 } |
| 34 | 32 |
| 35 namespace extensions { | 33 namespace extensions { |
| 36 class EventPageTracker; | 34 class EventPageTracker; |
| 37 } | 35 } |
| 38 | 36 |
| 39 namespace media_router { | 37 namespace media_router { |
| 40 | 38 |
| 41 // MediaRouter implementation that delegates calls to the component extension. | 39 // MediaRouter implementation that delegates calls to the component extension. |
| 42 // Also handles the suspension and wakeup of the component extension. | 40 // Also handles the suspension and wakeup of the component extension. |
| 43 class MediaRouterMojoImpl : public MediaRouter, | 41 class MediaRouterMojoImpl : public MediaRouterBase, |
| 44 public interfaces::MediaRouter { | 42 public interfaces::MediaRouter { |
| 45 public: | 43 public: |
| 46 ~MediaRouterMojoImpl() override; | 44 ~MediaRouterMojoImpl() override; |
| 47 | 45 |
| 48 // Sets up the MediaRouterMojoImpl instance owned by |context| to handle | 46 // Sets up the MediaRouterMojoImpl instance owned by |context| to handle |
| 49 // MediaRouterObserver requests from the component extension given by | 47 // MediaRouterObserver requests from the component extension given by |
| 50 // |extension_id|. Creates the MediaRouterMojoImpl instance if it does not | 48 // |extension_id|. Creates the MediaRouterMojoImpl instance if it does not |
| 51 // exist. | 49 // exist. |
| 52 // Called by the Mojo module registry. | 50 // Called by the Mojo module registry. |
| 53 // |extension_id|: The ID of the component extension, used for querying | 51 // |extension_id|: The ID of the component extension, used for querying |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 void RegisterIssuesObserver(IssuesObserver* observer) override; | 191 void RegisterIssuesObserver(IssuesObserver* observer) override; |
| 194 void UnregisterIssuesObserver(IssuesObserver* observer) override; | 192 void UnregisterIssuesObserver(IssuesObserver* observer) override; |
| 195 void RegisterPresentationSessionMessagesObserver( | 193 void RegisterPresentationSessionMessagesObserver( |
| 196 PresentationSessionMessagesObserver* observer) override; | 194 PresentationSessionMessagesObserver* observer) override; |
| 197 void UnregisterPresentationSessionMessagesObserver( | 195 void UnregisterPresentationSessionMessagesObserver( |
| 198 PresentationSessionMessagesObserver* observer) override; | 196 PresentationSessionMessagesObserver* observer) override; |
| 199 void RegisterLocalMediaRoutesObserver( | 197 void RegisterLocalMediaRoutesObserver( |
| 200 LocalMediaRoutesObserver* observer) override; | 198 LocalMediaRoutesObserver* observer) override; |
| 201 void UnregisterLocalMediaRoutesObserver( | 199 void UnregisterLocalMediaRoutesObserver( |
| 202 LocalMediaRoutesObserver* observer) override; | 200 LocalMediaRoutesObserver* observer) override; |
| 203 void RegisterPresentationConnectionStateObserver( | |
| 204 PresentationConnectionStateObserver* observer) override; | |
| 205 void UnregisterPresentationConnectionStateObserver( | |
| 206 PresentationConnectionStateObserver* observer) override; | |
| 207 | 201 |
| 208 // These calls invoke methods in the component extension via Mojo. | 202 // These calls invoke methods in the component extension via Mojo. |
| 209 void DoCreateRoute(const MediaSource::Id& source_id, | 203 void DoCreateRoute(const MediaSource::Id& source_id, |
| 210 const MediaSink::Id& sink_id, | 204 const MediaSink::Id& sink_id, |
| 211 const std::string& origin, | 205 const std::string& origin, |
| 212 int tab_id, | 206 int tab_id, |
| 213 const std::vector<MediaRouteResponseCallback>& callbacks); | 207 const std::vector<MediaRouteResponseCallback>& callbacks); |
| 214 void DoJoinRoute(const MediaSource::Id& source_id, | 208 void DoJoinRoute(const MediaSource::Id& source_id, |
| 215 const std::string& presentation_id, | 209 const std::string& presentation_id, |
| 216 const std::string& origin, | 210 const std::string& origin, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 base::ScopedPtrHashMap<MediaRoute::Id, | 294 base::ScopedPtrHashMap<MediaRoute::Id, |
| 301 scoped_ptr<PresentationSessionMessagesObserverList>> | 295 scoped_ptr<PresentationSessionMessagesObserverList>> |
| 302 messages_observers_; | 296 messages_observers_; |
| 303 | 297 |
| 304 // IDs of MediaRoutes being listened for messages. Note that this is | 298 // IDs of MediaRoutes being listened for messages. Note that this is |
| 305 // different from |message_observers_| because we might be waiting for | 299 // different from |message_observers_| because we might be waiting for |
| 306 // |OnRouteMessagesReceived()| to be invoked after all observers for that | 300 // |OnRouteMessagesReceived()| to be invoked after all observers for that |
| 307 // route have been removed. | 301 // route have been removed. |
| 308 std::set<MediaRoute::Id> route_ids_listening_for_messages_; | 302 std::set<MediaRoute::Id> route_ids_listening_for_messages_; |
| 309 | 303 |
| 310 using PresentationConnectionStateObserverList = | |
| 311 base::ObserverList<PresentationConnectionStateObserver>; | |
| 312 base::ScopedPtrHashMap<MediaRoute::Id, | |
| 313 scoped_ptr<PresentationConnectionStateObserverList>> | |
| 314 presentation_connection_state_observers_; | |
| 315 | |
| 316 IssueManager issue_manager_; | 304 IssueManager issue_manager_; |
| 317 | 305 |
| 318 // Binds |this| to a Mojo connection stub for interfaces::MediaRouter. | 306 // Binds |this| to a Mojo connection stub for interfaces::MediaRouter. |
| 319 scoped_ptr<mojo::Binding<interfaces::MediaRouter>> binding_; | 307 scoped_ptr<mojo::Binding<interfaces::MediaRouter>> binding_; |
| 320 | 308 |
| 321 // Mojo proxy object for the Media Route Provider Manager. | 309 // Mojo proxy object for the Media Route Provider Manager. |
| 322 // Set to null initially, and later set to the Provider Manager proxy object | 310 // Set to null initially, and later set to the Provider Manager proxy object |
| 323 // passed in via |RegisterMediaRouteProvider()|. | 311 // passed in via |RegisterMediaRouteProvider()|. |
| 324 // This is set to null again when the component extension is suspended | 312 // This is set to null again when the component extension is suspended |
| 325 // if or a Mojo channel error occured. | 313 // if or a Mojo channel error occured. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 344 | 332 |
| 345 // Observes local routes in order to notify LocalMediaRoutesObservers when | 333 // Observes local routes in order to notify LocalMediaRoutesObservers when |
| 346 // there are no more local routes. | 334 // there are no more local routes. |
| 347 scoped_ptr<MediaRoutesObserver> routes_observer_; | 335 scoped_ptr<MediaRoutesObserver> routes_observer_; |
| 348 | 336 |
| 349 // The last reported sink availability from the media route provider manager. | 337 // The last reported sink availability from the media route provider manager. |
| 350 interfaces::MediaRouter::SinkAvailability availability_; | 338 interfaces::MediaRouter::SinkAvailability availability_; |
| 351 | 339 |
| 352 int wakeup_attempt_count_; | 340 int wakeup_attempt_count_; |
| 353 | 341 |
| 354 base::ThreadChecker thread_checker_; | |
| 355 | |
| 356 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 342 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
| 357 | 343 |
| 358 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 344 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 359 }; | 345 }; |
| 360 | 346 |
| 361 } // namespace media_router | 347 } // namespace media_router |
| 362 | 348 |
| 363 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ | 349 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |