Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(391)

Side by Side Diff: chrome/browser/media/router/mojo/media_router_mojo_impl.h

Issue 2111303003: [Media Router] Replace route messaging API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 OffTheRecordRoutesTerminatedOnProfileShutdown); 129 OffTheRecordRoutesTerminatedOnProfileShutdown);
130 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, 130 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
131 RegisterAndUnregisterMediaSinksObserver); 131 RegisterAndUnregisterMediaSinksObserver);
132 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, 132 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
133 RegisterMediaSinksObserverWithAvailabilityChange); 133 RegisterMediaSinksObserverWithAvailabilityChange);
134 FRIEND_TEST_ALL_PREFIXES( 134 FRIEND_TEST_ALL_PREFIXES(
135 MediaRouterMojoImplTest, 135 MediaRouterMojoImplTest,
136 RegisterAndUnregisterMediaSinksObserverWithAvailabilityChange); 136 RegisterAndUnregisterMediaSinksObserverWithAvailabilityChange);
137 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, 137 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
138 RegisterAndUnregisterMediaRoutesObserver); 138 RegisterAndUnregisterMediaRoutesObserver);
139 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
140 PresentationSessionMessagesSingleObserver);
141 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
142 PresentationSessionMessagesMultipleObservers);
139 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, HandleIssue); 143 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, HandleIssue);
140 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 144 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
141 DeferredBindingAndSuspension); 145 DeferredBindingAndSuspension);
142 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 146 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
143 DrainPendingRequestQueue); 147 DrainPendingRequestQueue);
144 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 148 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
145 DropOldestPendingRequest); 149 DropOldestPendingRequest);
146 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 150 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
147 AttemptedWakeupTooManyTimes); 151 AttemptedWakeupTooManyTimes);
148 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 152 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 base::TimeDelta timeout, 258 base::TimeDelta timeout,
255 bool off_the_record); 259 bool off_the_record);
256 void DoTerminateRoute(const MediaRoute::Id& route_id); 260 void DoTerminateRoute(const MediaRoute::Id& route_id);
257 void DoDetachRoute(const MediaRoute::Id& route_id); 261 void DoDetachRoute(const MediaRoute::Id& route_id);
258 void DoSendSessionMessage(const MediaRoute::Id& route_id, 262 void DoSendSessionMessage(const MediaRoute::Id& route_id,
259 const std::string& message, 263 const std::string& message,
260 const SendRouteMessageCallback& callback); 264 const SendRouteMessageCallback& callback);
261 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id, 265 void DoSendSessionBinaryMessage(const MediaRoute::Id& route_id,
262 std::unique_ptr<std::vector<uint8_t>> data, 266 std::unique_ptr<std::vector<uint8_t>> data,
263 const SendRouteMessageCallback& callback); 267 const SendRouteMessageCallback& callback);
264 void DoListenForRouteMessages(const MediaRoute::Id& route_id); 268 void DoStartListeningForRouteMessages(const MediaRoute::Id& route_id);
265 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id); 269 void DoStopListeningForRouteMessages(const MediaRoute::Id& route_id);
266 void DoStartObservingMediaSinks(const MediaSource::Id& source_id); 270 void DoStartObservingMediaSinks(const MediaSource::Id& source_id);
267 void DoStopObservingMediaSinks(const MediaSource::Id& source_id); 271 void DoStopObservingMediaSinks(const MediaSource::Id& source_id);
268 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id); 272 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id);
269 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id); 273 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id);
270 void DoSearchSinks( 274 void DoSearchSinks(
271 const MediaSink::Id& sink_id, 275 const MediaSink::Id& sink_id,
272 const MediaSource::Id& source_id, 276 const MediaSource::Id& source_id,
273 const std::string& search_input, 277 const std::string& search_input,
274 const std::string& domain, 278 const std::string& domain,
275 const MediaSinkSearchResponseCallback& sink_callback); 279 const MediaSinkSearchResponseCallback& sink_callback);
276 280
277 // Invoked when the next batch of messages arrives.
278 // |route_id|: ID of route of the messages.
279 // |messages|: A list of messages received.
280 // |error|: true if an error occurred.
281 void OnRouteMessagesReceived(
282 const MediaRoute::Id& route_id,
283 mojo::Array<interfaces::RouteMessagePtr> messages,
284 bool error);
285
286 // Error handler callback for |binding_| and |media_route_provider_|. 281 // Error handler callback for |binding_| and |media_route_provider_|.
287 void OnConnectionError(); 282 void OnConnectionError();
288 283
289 // interfaces::MediaRouter implementation. 284 // interfaces::MediaRouter implementation.
290 void RegisterMediaRouteProvider( 285 void RegisterMediaRouteProvider(
291 interfaces::MediaRouteProviderPtr media_route_provider_ptr, 286 interfaces::MediaRouteProviderPtr media_route_provider_ptr,
292 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& 287 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback&
293 callback) override; 288 callback) override;
294 void OnIssue(interfaces::IssuePtr issue) override; 289 void OnIssue(interfaces::IssuePtr issue) override;
295 void OnSinksReceived(const mojo::String& media_source, 290 void OnSinksReceived(const mojo::String& media_source,
296 mojo::Array<interfaces::MediaSinkPtr> sinks, 291 mojo::Array<interfaces::MediaSinkPtr> sinks,
297 mojo::Array<mojo::String> origins) override; 292 mojo::Array<mojo::String> origins) override;
298 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes, 293 void OnRoutesUpdated(mojo::Array<interfaces::MediaRoutePtr> routes,
299 const mojo::String& media_source, 294 const mojo::String& media_source,
300 mojo::Array<mojo::String> joinable_route_ids) override; 295 mojo::Array<mojo::String> joinable_route_ids) override;
301 void OnSinkAvailabilityUpdated( 296 void OnSinkAvailabilityUpdated(
302 interfaces::MediaRouter::SinkAvailability availability) override; 297 interfaces::MediaRouter::SinkAvailability availability) override;
303 void OnPresentationConnectionStateChanged( 298 void OnPresentationConnectionStateChanged(
304 const mojo::String& route_id, 299 const mojo::String& route_id,
305 interfaces::MediaRouter::PresentationConnectionState state) override; 300 interfaces::MediaRouter::PresentationConnectionState state) override;
306 void OnPresentationConnectionClosed( 301 void OnPresentationConnectionClosed(
307 const mojo::String& route_id, 302 const mojo::String& route_id,
308 interfaces::MediaRouter::PresentationConnectionCloseReason reason, 303 interfaces::MediaRouter::PresentationConnectionCloseReason reason,
309 const mojo::String& message) override; 304 const mojo::String& message) override;
305 void OnRouteMessagesReceived(
306 const mojo::String& route_id,
307 mojo::Array<interfaces::RouteMessagePtr> messages) override;
310 308
311 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() 309 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute()
312 // into a local callback. 310 // into a local callback.
313 void RouteResponseReceived( 311 void RouteResponseReceived(
314 const std::string& presentation_id, 312 const std::string& presentation_id,
315 bool off_the_record, 313 bool off_the_record,
316 const std::vector<MediaRouteResponseCallback>& callbacks, 314 const std::vector<MediaRouteResponseCallback>& callbacks,
317 interfaces::MediaRoutePtr media_route, 315 interfaces::MediaRoutePtr media_route,
318 mojo::String error_text, 316 mojo::String error_text,
319 interfaces::RouteRequestResultCode result_code); 317 interfaces::RouteRequestResultCode result_code);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 base::ScopedPtrHashMap<MediaSource::Id, std::unique_ptr<MediaRoutesQuery>> 369 base::ScopedPtrHashMap<MediaSource::Id, std::unique_ptr<MediaRoutesQuery>>
372 routes_queries_; 370 routes_queries_;
373 371
374 using PresentationSessionMessagesObserverList = 372 using PresentationSessionMessagesObserverList =
375 base::ObserverList<PresentationSessionMessagesObserver>; 373 base::ObserverList<PresentationSessionMessagesObserver>;
376 base::ScopedPtrHashMap< 374 base::ScopedPtrHashMap<
377 MediaRoute::Id, 375 MediaRoute::Id,
378 std::unique_ptr<PresentationSessionMessagesObserverList>> 376 std::unique_ptr<PresentationSessionMessagesObserverList>>
379 messages_observers_; 377 messages_observers_;
380 378
381 // IDs of MediaRoutes being listened for messages. Note that this is
382 // different from |message_observers_| because we might be waiting for
383 // |OnRouteMessagesReceived()| to be invoked after all observers for that
384 // route have been removed.
385 std::set<MediaRoute::Id> route_ids_listening_for_messages_;
386
387 IssueManager issue_manager_; 379 IssueManager issue_manager_;
388 380
389 // Binds |this| to a Mojo connection stub for interfaces::MediaRouter. 381 // Binds |this| to a Mojo connection stub for interfaces::MediaRouter.
390 std::unique_ptr<mojo::Binding<interfaces::MediaRouter>> binding_; 382 std::unique_ptr<mojo::Binding<interfaces::MediaRouter>> binding_;
391 383
392 // Mojo proxy object for the Media Route Provider Manager. 384 // Mojo proxy object for the Media Route Provider Manager.
393 // Set to null initially, and later set to the Provider Manager proxy object 385 // Set to null initially, and later set to the Provider Manager proxy object
394 // passed in via |RegisterMediaRouteProvider()|. 386 // passed in via |RegisterMediaRouteProvider()|.
395 // This is set to null again when the component extension is suspended 387 // This is set to null again when the component extension is suspended
396 // if or a Mojo channel error occured. 388 // if or a Mojo channel error occured.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 #endif 427 #endif
436 428
437 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; 429 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_;
438 430
439 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); 431 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl);
440 }; 432 };
441 433
442 } // namespace media_router 434 } // namespace media_router
443 435
444 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ 436 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/media/router/mojo/media_router.mojom ('k') | chrome/browser/media/router/mojo/media_router_mojo_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698