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

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

Issue 2728543009: [Media Router] Custom Controls 2 - add MediaRouter::GetRouteController() (Closed)
Patch Set: Address Mark's comments Created 3 years, 8 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 const SendRouteMessageCallback& callback) override; 102 const SendRouteMessageCallback& callback) override;
103 void AddIssue(const IssueInfo& issue_info) override; 103 void AddIssue(const IssueInfo& issue_info) override;
104 void ClearIssue(const Issue::Id& issue_id) override; 104 void ClearIssue(const Issue::Id& issue_id) override;
105 void OnUserGesture() override; 105 void OnUserGesture() override;
106 void SearchSinks( 106 void SearchSinks(
107 const MediaSink::Id& sink_id, 107 const MediaSink::Id& sink_id,
108 const MediaSource::Id& source_id, 108 const MediaSource::Id& source_id,
109 const std::string& search_input, 109 const std::string& search_input,
110 const std::string& domain, 110 const std::string& domain,
111 const MediaSinkSearchResponseCallback& sink_callback) override; 111 const MediaSinkSearchResponseCallback& sink_callback) override;
112 scoped_refptr<MediaRouteController> GetRouteController(
113 const MediaRoute::Id& route_id) override;
112 114
113 const std::string& media_route_provider_extension_id() const { 115 const std::string& media_route_provider_extension_id() const {
114 return media_route_provider_extension_id_; 116 return media_route_provider_extension_id_;
115 } 117 }
116 118
117 void set_instance_id_for_test(const std::string& instance_id) { 119 void set_instance_id_for_test(const std::string& instance_id) {
118 instance_id_ = instance_id; 120 instance_id_ = instance_id;
119 } 121 }
120 122
121 private: 123 private:
(...skipping 13 matching lines...) Expand all
135 FRIEND_TEST_ALL_PREFIXES( 137 FRIEND_TEST_ALL_PREFIXES(
136 MediaRouterMojoImplTest, 138 MediaRouterMojoImplTest,
137 RegisterAndUnregisterMediaSinksObserverWithAvailabilityChange); 139 RegisterAndUnregisterMediaSinksObserverWithAvailabilityChange);
138 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, 140 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
139 RegisterAndUnregisterMediaRoutesObserver); 141 RegisterAndUnregisterMediaRoutesObserver);
140 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, 142 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
141 RouteMessagesSingleObserver); 143 RouteMessagesSingleObserver);
142 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, 144 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
143 RouteMessagesMultipleObservers); 145 RouteMessagesMultipleObservers);
144 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, HandleIssue); 146 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, HandleIssue);
147 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest, GetRouteController);
148 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
149 GetRouteControllerMultipleTimes);
150 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
151 GetRouteControllerAfterInvalidation);
152 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
153 GetRouteControllerAfterRouteInvalidation);
154 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoImplTest,
155 FailToCreateRouteController);
145 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 156 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
146 DeferredBindingAndSuspension); 157 DeferredBindingAndSuspension);
147 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 158 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
148 DrainPendingRequestQueue); 159 DrainPendingRequestQueue);
149 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 160 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
150 DropOldestPendingRequest); 161 DropOldestPendingRequest);
151 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 162 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
152 AttemptedWakeupTooManyTimes); 163 AttemptedWakeupTooManyTimes);
153 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest, 164 FRIEND_TEST_ALL_PREFIXES(MediaRouterMojoExtensionTest,
154 WakeupFailedDrainsQueue); 165 WakeupFailedDrainsQueue);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 238
228 // MediaRouter implementation. 239 // MediaRouter implementation.
229 bool RegisterMediaSinksObserver(MediaSinksObserver* observer) override; 240 bool RegisterMediaSinksObserver(MediaSinksObserver* observer) override;
230 void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override; 241 void UnregisterMediaSinksObserver(MediaSinksObserver* observer) override;
231 void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override; 242 void RegisterMediaRoutesObserver(MediaRoutesObserver* observer) override;
232 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override; 243 void UnregisterMediaRoutesObserver(MediaRoutesObserver* observer) override;
233 void RegisterIssuesObserver(IssuesObserver* observer) override; 244 void RegisterIssuesObserver(IssuesObserver* observer) override;
234 void UnregisterIssuesObserver(IssuesObserver* observer) override; 245 void UnregisterIssuesObserver(IssuesObserver* observer) override;
235 void RegisterRouteMessageObserver(RouteMessageObserver* observer) override; 246 void RegisterRouteMessageObserver(RouteMessageObserver* observer) override;
236 void UnregisterRouteMessageObserver(RouteMessageObserver* observer) override; 247 void UnregisterRouteMessageObserver(RouteMessageObserver* observer) override;
248 void DetachRouteController(const MediaRoute::Id& route_id,
249 MediaRouteController* controller) override;
237 250
238 // Notifies |observer| of any existing cached routes, if it is still 251 // Notifies |observer| of any existing cached routes, if it is still
239 // registered. 252 // registered.
240 void NotifyOfExistingRoutesIfRegistered(const MediaSource::Id& source_id, 253 void NotifyOfExistingRoutesIfRegistered(const MediaSource::Id& source_id,
241 MediaRoutesObserver* observer) const; 254 MediaRoutesObserver* observer) const;
242 255
243 // These calls invoke methods in the component extension via Mojo. 256 // These calls invoke methods in the component extension via Mojo.
244 void DoCreateRoute(const MediaSource::Id& source_id, 257 void DoCreateRoute(const MediaSource::Id& source_id,
245 const MediaSink::Id& sink_id, 258 const MediaSink::Id& sink_id,
246 const url::Origin& origin, 259 const url::Origin& origin,
(...skipping 29 matching lines...) Expand all
276 void DoStartObservingMediaSinks(const MediaSource::Id& source_id); 289 void DoStartObservingMediaSinks(const MediaSource::Id& source_id);
277 void DoStopObservingMediaSinks(const MediaSource::Id& source_id); 290 void DoStopObservingMediaSinks(const MediaSource::Id& source_id);
278 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id); 291 void DoStartObservingMediaRoutes(const MediaSource::Id& source_id);
279 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id); 292 void DoStopObservingMediaRoutes(const MediaSource::Id& source_id);
280 void DoSearchSinks( 293 void DoSearchSinks(
281 const MediaSink::Id& sink_id, 294 const MediaSink::Id& sink_id,
282 const MediaSource::Id& source_id, 295 const MediaSource::Id& source_id,
283 const std::string& search_input, 296 const std::string& search_input,
284 const std::string& domain, 297 const std::string& domain,
285 const MediaSinkSearchResponseCallback& sink_callback); 298 const MediaSinkSearchResponseCallback& sink_callback);
299 void DoCreateMediaRouteController(const MediaRoute::Id& route_id,
300 base::Callback<void(bool)> callback);
301 void DoSetMediaRouteStatusObserver(const MediaRoute::Id& route_id);
286 302
287 // Error handler callback for |binding_| and |media_route_provider_|. 303 // Error handler callback for |binding_| and |media_route_provider_|.
288 void OnConnectionError(); 304 void OnConnectionError();
289 305
290 // mojom::MediaRouter implementation. 306 // mojom::MediaRouter implementation.
291 void RegisterMediaRouteProvider( 307 void RegisterMediaRouteProvider(
292 mojom::MediaRouteProviderPtr media_route_provider_ptr, 308 mojom::MediaRouteProviderPtr media_route_provider_ptr,
293 const mojom::MediaRouter::RegisterMediaRouteProviderCallback& 309 const mojom::MediaRouter::RegisterMediaRouteProviderCallback&
294 callback) override; 310 callback) override;
295 void OnIssue(const IssueInfo& issue) override; 311 void OnIssue(const IssueInfo& issue) override;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // happen until the user is clearly interacting with MR. 382 // happen until the user is clearly interacting with MR.
367 void OnFirewallCheckComplete(bool firewall_can_use_local_ports); 383 void OnFirewallCheckComplete(bool firewall_can_use_local_ports);
368 #endif 384 #endif
369 385
370 // Requests MRPM to update media sinks. This allows MRPs that only do 386 // Requests MRPM to update media sinks. This allows MRPs that only do
371 // discovery on sink queries an opportunity to update discovery results 387 // discovery on sink queries an opportunity to update discovery results
372 // even if the MRP SinkAvailability is marked UNAVAILABLE. 388 // even if the MRP SinkAvailability is marked UNAVAILABLE.
373 void UpdateMediaSinks(const MediaSource::Id& source_id); 389 void UpdateMediaSinks(const MediaSource::Id& source_id);
374 void DoUpdateMediaSinks(const MediaSource::Id& source_id); 390 void DoUpdateMediaSinks(const MediaSource::Id& source_id);
375 391
392 // Invalidates and removes controllers from |route_controllers_| whose media
393 // routes do not appear in |routes|.
394 void RemoveInvalidRouteControllers(const std::vector<MediaRoute>& routes);
395
396 // Callback called by MRP's CreateMediaRouteController().
397 void OnMediaControllerCreated(const MediaRoute::Id& route_id, bool success);
398
376 // Pending requests queued to be executed once component extension 399 // Pending requests queued to be executed once component extension
377 // becomes ready. 400 // becomes ready.
378 std::deque<base::Closure> pending_requests_; 401 std::deque<base::Closure> pending_requests_;
379 402
380 std::unordered_map<MediaSource::Id, std::unique_ptr<MediaSinksQuery>> 403 std::unordered_map<MediaSource::Id, std::unique_ptr<MediaSinksQuery>>
381 sinks_queries_; 404 sinks_queries_;
382 405
383 std::unordered_map<MediaSource::Id, std::unique_ptr<MediaRoutesQuery>> 406 std::unordered_map<MediaSource::Id, std::unique_ptr<MediaRoutesQuery>>
384 routes_queries_; 407 routes_queries_;
385 408
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 int wakeup_attempt_count_ = 0; 442 int wakeup_attempt_count_ = 0;
420 443
421 // Records the current reason the extension is being woken up. Is set to 444 // Records the current reason the extension is being woken up. Is set to
422 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason. 445 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason.
423 MediaRouteProviderWakeReason current_wake_reason_; 446 MediaRouteProviderWakeReason current_wake_reason_;
424 447
425 // A flag to ensure that we record the provider version once, during the 448 // A flag to ensure that we record the provider version once, during the
426 // initial event page wakeup attempt. 449 // initial event page wakeup attempt.
427 bool provider_version_was_recorded_ = false; 450 bool provider_version_was_recorded_ = false;
428 451
452 // Stores route controllers that can be used to send media commands to the
453 // extension.
454 std::unordered_map<MediaRoute::Id, MediaRouteController*> route_controllers_;
455
429 #if defined(OS_WIN) 456 #if defined(OS_WIN)
430 // A pair of flags to ensure that mDNS discovery is only enabled on Windows 457 // A pair of flags to ensure that mDNS discovery is only enabled on Windows
431 // when there will be appropriate context for the user to associate a firewall 458 // when there will be appropriate context for the user to associate a firewall
432 // prompt with Media Router. |should_enable_mdns_discovery_| can only go from 459 // prompt with Media Router. |should_enable_mdns_discovery_| can only go from
433 // |false| to |true|. On Windows, |is_mdns_enabled_| is set to |false| in 460 // |false| to |true|. On Windows, |is_mdns_enabled_| is set to |false| in
434 // RegisterMediaRouteProvider and only set to |true| when we successfully call 461 // RegisterMediaRouteProvider and only set to |true| when we successfully call
435 // the extension to enable mDNS. 462 // the extension to enable mDNS.
436 bool is_mdns_enabled_ = false; 463 bool is_mdns_enabled_ = false;
437 bool should_enable_mdns_discovery_ = false; 464 bool should_enable_mdns_discovery_ = false;
438 #endif 465 #endif
439 466
440 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; 467 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_;
441 468
442 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); 469 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl);
443 }; 470 };
444 471
445 } // namespace media_router 472 } // namespace media_router
446 473
447 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ 474 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698