| 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_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| 6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <unordered_map> | 15 #include <unordered_map> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/containers/hash_tables.h" | 18 #include "base/containers/hash_tables.h" |
| 19 #include "base/gtest_prod_util.h" | 19 #include "base/gtest_prod_util.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/observer_list.h" | 22 #include "base/observer_list.h" |
| 23 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
| 24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 25 #include "chrome/browser/media/router/issue.h" | 25 #include "chrome/browser/media/router/issue.h" |
| 26 #include "chrome/browser/media/router/issue_manager.h" | 26 #include "chrome/browser/media/router/issue_manager.h" |
| 27 #include "chrome/browser/media/router/media_router_base.h" | 27 #include "chrome/browser/media/router/media_router_base.h" |
| 28 #include "chrome/browser/media/router/media_routes_observer.h" | 28 #include "chrome/browser/media/router/media_routes_observer.h" |
| 29 #include "chrome/browser/media/router/mojo/media_router.mojom.h" | 29 #include "chrome/browser/media/router/mojo/media_router.mojom.h" |
| 30 #include "chrome/browser/media/router/route_request_result.h" |
| 30 #include "mojo/public/cpp/bindings/binding.h" | 31 #include "mojo/public/cpp/bindings/binding.h" |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 class BrowserContext; | 34 class BrowserContext; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace extensions { | 37 namespace extensions { |
| 37 class EventPageTracker; | 38 class EventPageTracker; |
| 38 class Extension; | 39 class Extension; |
| 39 } | 40 } |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 // Error handler callback for |binding_| and |media_route_provider_|. | 279 // Error handler callback for |binding_| and |media_route_provider_|. |
| 279 void OnConnectionError(); | 280 void OnConnectionError(); |
| 280 | 281 |
| 281 // mojom::MediaRouter implementation. | 282 // mojom::MediaRouter implementation. |
| 282 void RegisterMediaRouteProvider( | 283 void RegisterMediaRouteProvider( |
| 283 mojom::MediaRouteProviderPtr media_route_provider_ptr, | 284 mojom::MediaRouteProviderPtr media_route_provider_ptr, |
| 284 const mojom::MediaRouter::RegisterMediaRouteProviderCallback& | 285 const mojom::MediaRouter::RegisterMediaRouteProviderCallback& |
| 285 callback) override; | 286 callback) override; |
| 286 void OnIssue(const IssueInfo& issue) override; | 287 void OnIssue(const IssueInfo& issue) override; |
| 287 void OnSinksReceived(const std::string& media_source, | 288 void OnSinksReceived(const std::string& media_source, |
| 288 std::vector<mojom::MediaSinkPtr> sinks, | 289 const std::vector<MediaSink>& sinks, |
| 289 const std::vector<url::Origin>& origins) override; | 290 const std::vector<url::Origin>& origins) override; |
| 290 void OnRoutesUpdated( | 291 void OnRoutesUpdated( |
| 291 std::vector<mojom::MediaRoutePtr> routes, | 292 const std::vector<MediaRoute>& routes, |
| 292 const std::string& media_source, | 293 const std::string& media_source, |
| 293 const std::vector<std::string>& joinable_route_ids) override; | 294 const std::vector<std::string>& joinable_route_ids) override; |
| 294 void OnSinkAvailabilityUpdated( | 295 void OnSinkAvailabilityUpdated( |
| 295 mojom::MediaRouter::SinkAvailability availability) override; | 296 mojom::MediaRouter::SinkAvailability availability) override; |
| 296 void OnPresentationConnectionStateChanged( | 297 void OnPresentationConnectionStateChanged( |
| 297 const std::string& route_id, | 298 const std::string& route_id, |
| 298 mojom::MediaRouter::PresentationConnectionState state) override; | 299 content::PresentationConnectionState state) override; |
| 299 void OnPresentationConnectionClosed( | 300 void OnPresentationConnectionClosed( |
| 300 const std::string& route_id, | 301 const std::string& route_id, |
| 301 mojom::MediaRouter::PresentationConnectionCloseReason reason, | 302 content::PresentationConnectionCloseReason reason, |
| 302 const std::string& message) override; | 303 const std::string& message) override; |
| 303 void OnRouteMessagesReceived( | 304 void OnRouteMessagesReceived( |
| 304 const std::string& route_id, | 305 const std::string& route_id, |
| 305 const std::vector<RouteMessage>& messages) override; | 306 const std::vector<RouteMessage>& messages) override; |
| 306 | 307 |
| 307 // Result callback when Mojo terminateRoute is invoked. |route_id| is bound | 308 // Result callback when Mojo terminateRoute is invoked. |route_id| is bound |
| 308 // to the ID of the route that was terminated. | 309 // to the ID of the route that was terminated. |
| 309 void OnTerminateRouteResult(const MediaRoute::Id& route_id, | 310 void OnTerminateRouteResult(const MediaRoute::Id& route_id, |
| 310 const base::Optional<std::string>& error_text, | 311 const base::Optional<std::string>& error_text, |
| 311 mojom::RouteRequestResultCode result_code); | 312 RouteRequestResult::ResultCode result_code); |
| 312 | 313 |
| 313 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() | 314 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() |
| 314 // into a local callback. | 315 // into a local callback. |
| 315 void RouteResponseReceived( | 316 void RouteResponseReceived( |
| 316 const std::string& presentation_id, | 317 const std::string& presentation_id, |
| 317 bool is_incognito, | 318 bool is_incognito, |
| 318 const std::vector<MediaRouteResponseCallback>& callbacks, | 319 const std::vector<MediaRouteResponseCallback>& callbacks, |
| 319 bool is_join, | 320 bool is_join, |
| 320 mojom::MediaRoutePtr media_route, | 321 const base::Optional<MediaRoute>& media_route, |
| 321 const base::Optional<std::string>& error_text, | 322 const base::Optional<std::string>& error_text, |
| 322 mojom::RouteRequestResultCode result_code); | 323 RouteRequestResult::ResultCode result_code); |
| 323 | 324 |
| 324 // Callback invoked by |event_page_tracker_| after an attempt to wake the | 325 // Callback invoked by |event_page_tracker_| after an attempt to wake the |
| 325 // component extension. If |success| is false, the pending request queue is | 326 // component extension. If |success| is false, the pending request queue is |
| 326 // drained. | 327 // drained. |
| 327 void EventPageWakeComplete(bool success); | 328 void EventPageWakeComplete(bool success); |
| 328 | 329 |
| 329 // Removes all requests from the pending requests queue. Called when there is | 330 // Removes all requests from the pending requests queue. Called when there is |
| 330 // a permanent error connecting to component extension. | 331 // a permanent error connecting to component extension. |
| 331 void DrainRequestQueue(); | 332 void DrainRequestQueue(); |
| 332 | 333 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 #endif | 430 #endif |
| 430 | 431 |
| 431 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; | 432 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; |
| 432 | 433 |
| 433 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); | 434 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); |
| 434 }; | 435 }; |
| 435 | 436 |
| 436 } // namespace media_router | 437 } // namespace media_router |
| 437 | 438 |
| 438 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ | 439 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ |
| OLD | NEW |