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

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

Issue 2185293002: [Media Router] Rename mojo namespace from interfaces to mojom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename mojo namespace in tests Created 4 years, 4 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 29 matching lines...) Expand all
40 } 40 }
41 41
42 namespace media_router { 42 namespace media_router {
43 43
44 enum class MediaRouteProviderWakeReason; 44 enum class MediaRouteProviderWakeReason;
45 45
46 // MediaRouter implementation that delegates calls to the component extension. 46 // MediaRouter implementation that delegates calls to the component extension.
47 // Also handles the suspension and wakeup of the component extension. 47 // Also handles the suspension and wakeup of the component extension.
48 // Lives on the UI thread. 48 // Lives on the UI thread.
49 class MediaRouterMojoImpl : public MediaRouterBase, 49 class MediaRouterMojoImpl : public MediaRouterBase,
50 public interfaces::MediaRouter { 50 public mojom::MediaRouter {
51 public: 51 public:
52 ~MediaRouterMojoImpl() override; 52 ~MediaRouterMojoImpl() override;
53 53
54 // Sets up the MediaRouterMojoImpl instance owned by |context| to handle 54 // Sets up the MediaRouterMojoImpl instance owned by |context| to handle
55 // MediaRouterObserver requests from the component extension given by 55 // MediaRouterObserver requests from the component extension given by
56 // |extension|. Creates the MediaRouterMojoImpl instance if it does not 56 // |extension|. Creates the MediaRouterMojoImpl instance if it does not
57 // exist. 57 // exist.
58 // Called by the Mojo module registry. 58 // Called by the Mojo module registry.
59 // |extension|: The component extension, used for querying 59 // |extension|: The component extension, used for querying
60 // suspension state. 60 // suspension state.
61 // |context|: The BrowserContext which owns the extension process. 61 // |context|: The BrowserContext which owns the extension process.
62 // |request|: The Mojo connection request used for binding. 62 // |request|: The Mojo connection request used for binding.
63 static void BindToRequest( 63 static void BindToRequest(
64 const extensions::Extension* extension, 64 const extensions::Extension* extension,
65 content::BrowserContext* context, 65 content::BrowserContext* context,
66 mojo::InterfaceRequest<interfaces::MediaRouter> request); 66 mojo::InterfaceRequest<mojom::MediaRouter> request);
67 67
68 // MediaRouter implementation. 68 // MediaRouter implementation.
69 // Execution of the requests is delegated to the Do* methods, which can be 69 // Execution of the requests is delegated to the Do* methods, which can be
70 // enqueued for later use if the extension is temporarily suspended. 70 // enqueued for later use if the extension is temporarily suspended.
71 void CreateRoute(const MediaSource::Id& source_id, 71 void CreateRoute(const MediaSource::Id& source_id,
72 const MediaSink::Id& sink_id, 72 const MediaSink::Id& sink_id,
73 const GURL& origin, 73 const GURL& origin,
74 content::WebContents* web_contents, 74 content::WebContents* web_contents,
75 const std::vector<MediaRouteResponseCallback>& callbacks, 75 const std::vector<MediaRouteResponseCallback>& callbacks,
76 base::TimeDelta timeout, 76 base::TimeDelta timeout,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 // Standard constructor, used by 199 // Standard constructor, used by
200 // MediaRouterMojoImplFactory::GetApiForBrowserContext. 200 // MediaRouterMojoImplFactory::GetApiForBrowserContext.
201 explicit MediaRouterMojoImpl( 201 explicit MediaRouterMojoImpl(
202 extensions::EventPageTracker* event_page_tracker); 202 extensions::EventPageTracker* event_page_tracker);
203 203
204 // Binds |this| to a Mojo interface request, so that clients can acquire a 204 // Binds |this| to a Mojo interface request, so that clients can acquire a
205 // handle to a MediaRouterMojoImpl instance via the Mojo service connector. 205 // handle to a MediaRouterMojoImpl instance via the Mojo service connector.
206 // Stores the ID of |extension| in |media_route_provider_extension_id_|. 206 // Stores the ID of |extension| in |media_route_provider_extension_id_|.
207 void BindToMojoRequest( 207 void BindToMojoRequest(
208 mojo::InterfaceRequest<interfaces::MediaRouter> request, 208 mojo::InterfaceRequest<mojom::MediaRouter> request,
209 const extensions::Extension& extension); 209 const extensions::Extension& extension);
210 210
211 // Enqueues a closure for later execution by ExecutePendingRequests(). 211 // Enqueues a closure for later execution by ExecutePendingRequests().
212 void EnqueueTask(const base::Closure& closure); 212 void EnqueueTask(const base::Closure& closure);
213 213
214 // Runs a closure if the extension monitored by |extension_monitor_| is 214 // Runs a closure if the extension monitored by |extension_monitor_| is
215 // active, or defers it for later execution if the extension is suspended. 215 // active, or defers it for later execution if the extension is suspended.
216 void RunOrDefer(const base::Closure& request); 216 void RunOrDefer(const base::Closure& request);
217 217
218 // Dispatches the Mojo requests queued in |pending_requests_|. 218 // Dispatches the Mojo requests queued in |pending_requests_|.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 void DoSearchSinks( 274 void DoSearchSinks(
275 const MediaSink::Id& sink_id, 275 const MediaSink::Id& sink_id,
276 const MediaSource::Id& source_id, 276 const MediaSource::Id& source_id,
277 const std::string& search_input, 277 const std::string& search_input,
278 const std::string& domain, 278 const std::string& domain,
279 const MediaSinkSearchResponseCallback& sink_callback); 279 const MediaSinkSearchResponseCallback& sink_callback);
280 280
281 // Error handler callback for |binding_| and |media_route_provider_|. 281 // Error handler callback for |binding_| and |media_route_provider_|.
282 void OnConnectionError(); 282 void OnConnectionError();
283 283
284 // interfaces::MediaRouter implementation. 284 // mojom::MediaRouter implementation.
285 void RegisterMediaRouteProvider( 285 void RegisterMediaRouteProvider(
286 interfaces::MediaRouteProviderPtr media_route_provider_ptr, 286 mojom::MediaRouteProviderPtr media_route_provider_ptr,
287 const interfaces::MediaRouter::RegisterMediaRouteProviderCallback& 287 const mojom::MediaRouter::RegisterMediaRouteProviderCallback&
288 callback) override; 288 callback) override;
289 void OnIssue(interfaces::IssuePtr issue) override; 289 void OnIssue(mojom::IssuePtr issue) override;
290 void OnSinksReceived(const std::string& media_source, 290 void OnSinksReceived(const std::string& media_source,
291 std::vector<interfaces::MediaSinkPtr> sinks, 291 std::vector<mojom::MediaSinkPtr> sinks,
292 const std::vector<std::string>& origins) override; 292 const std::vector<std::string>& origins) override;
293 void OnRoutesUpdated( 293 void OnRoutesUpdated(
294 std::vector<interfaces::MediaRoutePtr> routes, 294 std::vector<mojom::MediaRoutePtr> routes,
295 const std::string& media_source, 295 const std::string& media_source,
296 const std::vector<std::string>& joinable_route_ids) override; 296 const std::vector<std::string>& joinable_route_ids) override;
297 void OnSinkAvailabilityUpdated( 297 void OnSinkAvailabilityUpdated(
298 interfaces::MediaRouter::SinkAvailability availability) override; 298 mojom::MediaRouter::SinkAvailability availability) override;
299 void OnPresentationConnectionStateChanged( 299 void OnPresentationConnectionStateChanged(
300 const std::string& route_id, 300 const std::string& route_id,
301 interfaces::MediaRouter::PresentationConnectionState state) override; 301 mojom::MediaRouter::PresentationConnectionState state) override;
302 void OnPresentationConnectionClosed( 302 void OnPresentationConnectionClosed(
303 const std::string& route_id, 303 const std::string& route_id,
304 interfaces::MediaRouter::PresentationConnectionCloseReason reason, 304 mojom::MediaRouter::PresentationConnectionCloseReason reason,
305 const std::string& message) override; 305 const std::string& message) override;
306 void OnRouteMessagesReceived( 306 void OnRouteMessagesReceived(
307 const std::string& route_id, 307 const std::string& route_id,
308 std::vector<interfaces::RouteMessagePtr> messages) override; 308 std::vector<mojom::RouteMessagePtr> messages) override;
309 309
310 // Result callback when Mojo terminateRoute is invoked. |route_id| is bound 310 // Result callback when Mojo terminateRoute is invoked. |route_id| is bound
311 // to the ID of the route that was terminated. 311 // to the ID of the route that was terminated.
312 void OnTerminateRouteResult(const MediaRoute::Id& route_id, 312 void OnTerminateRouteResult(const MediaRoute::Id& route_id,
313 const base::Optional<std::string>& error_text, 313 const base::Optional<std::string>& error_text,
314 interfaces::RouteRequestResultCode result_code); 314 mojom::RouteRequestResultCode result_code);
315 315
316 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute() 316 // Converts the callback result of calling Mojo CreateRoute()/JoinRoute()
317 // into a local callback. 317 // into a local callback.
318 void RouteResponseReceived( 318 void RouteResponseReceived(
319 const std::string& presentation_id, 319 const std::string& presentation_id,
320 bool incognito, 320 bool incognito,
321 const std::vector<MediaRouteResponseCallback>& callbacks, 321 const std::vector<MediaRouteResponseCallback>& callbacks,
322 interfaces::MediaRoutePtr media_route, 322 mojom::MediaRoutePtr media_route,
323 const base::Optional<std::string>& error_text, 323 const base::Optional<std::string>& error_text,
324 interfaces::RouteRequestResultCode result_code); 324 mojom::RouteRequestResultCode result_code);
325 325
326 // Callback invoked by |event_page_tracker_| after an attempt to wake the 326 // Callback invoked by |event_page_tracker_| after an attempt to wake the
327 // component extension. If |success| is false, the pending request queue is 327 // component extension. If |success| is false, the pending request queue is
328 // drained. 328 // drained.
329 void EventPageWakeComplete(bool success); 329 void EventPageWakeComplete(bool success);
330 330
331 // Removes all requests from the pending requests queue. Called when there is 331 // Removes all requests from the pending requests queue. Called when there is
332 // a permanent error connecting to component extension. 332 // a permanent error connecting to component extension.
333 void DrainRequestQueue(); 333 void DrainRequestQueue();
334 334
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 378
379 using PresentationSessionMessagesObserverList = 379 using PresentationSessionMessagesObserverList =
380 base::ObserverList<PresentationSessionMessagesObserver>; 380 base::ObserverList<PresentationSessionMessagesObserver>;
381 base::ScopedPtrHashMap< 381 base::ScopedPtrHashMap<
382 MediaRoute::Id, 382 MediaRoute::Id,
383 std::unique_ptr<PresentationSessionMessagesObserverList>> 383 std::unique_ptr<PresentationSessionMessagesObserverList>>
384 messages_observers_; 384 messages_observers_;
385 385
386 IssueManager issue_manager_; 386 IssueManager issue_manager_;
387 387
388 // Binds |this| to a Mojo connection stub for interfaces::MediaRouter. 388 // Binds |this| to a Mojo connection stub for mojom::MediaRouter.
389 std::unique_ptr<mojo::Binding<interfaces::MediaRouter>> binding_; 389 std::unique_ptr<mojo::Binding<mojom::MediaRouter>> binding_;
390 390
391 // Mojo proxy object for the Media Route Provider Manager. 391 // Mojo proxy object for the Media Route Provider Manager.
392 // Set to null initially, and later set to the Provider Manager proxy object 392 // Set to null initially, and later set to the Provider Manager proxy object
393 // passed in via |RegisterMediaRouteProvider()|. 393 // passed in via |RegisterMediaRouteProvider()|.
394 // This is set to null again when the component extension is suspended 394 // This is set to null again when the component extension is suspended
395 // if or a Mojo channel error occured. 395 // if or a Mojo channel error occured.
396 interfaces::MediaRouteProviderPtr media_route_provider_; 396 mojom::MediaRouteProviderPtr media_route_provider_;
397 397
398 // Id of the component extension. Used for managing its suspend/wake state 398 // Id of the component extension. Used for managing its suspend/wake state
399 // via event_page_tracker_. 399 // via event_page_tracker_.
400 std::string media_route_provider_extension_id_; 400 std::string media_route_provider_extension_id_;
401 401
402 // Allows the extension to be monitored for suspend, and woken. 402 // Allows the extension to be monitored for suspend, and woken.
403 // This is a reference to a BrowserContext keyed service that outlives this 403 // This is a reference to a BrowserContext keyed service that outlives this
404 // instance. 404 // instance.
405 extensions::EventPageTracker* event_page_tracker_; 405 extensions::EventPageTracker* event_page_tracker_;
406 406
407 // GUID unique to each browser run. Component extension uses this to detect 407 // GUID unique to each browser run. Component extension uses this to detect
408 // when its persisted state was written by an older browser instance, and is 408 // when its persisted state was written by an older browser instance, and is
409 // therefore stale. 409 // therefore stale.
410 std::string instance_id_; 410 std::string instance_id_;
411 411
412 // The last reported sink availability from the media route provider manager. 412 // The last reported sink availability from the media route provider manager.
413 interfaces::MediaRouter::SinkAvailability availability_; 413 mojom::MediaRouter::SinkAvailability availability_;
414 414
415 int wakeup_attempt_count_ = 0; 415 int wakeup_attempt_count_ = 0;
416 416
417 // Records the current reason the extension is being woken up. Is set to 417 // Records the current reason the extension is being woken up. Is set to
418 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason. 418 // MediaRouteProviderWakeReason::TOTAL_COUNT if there is no pending reason.
419 MediaRouteProviderWakeReason current_wake_reason_; 419 MediaRouteProviderWakeReason current_wake_reason_;
420 420
421 // A flag to ensure that we record the provider version once, during the 421 // A flag to ensure that we record the provider version once, during the
422 // initial event page wakeup attempt. 422 // initial event page wakeup attempt.
423 bool provider_version_was_recorded_ = false; 423 bool provider_version_was_recorded_ = false;
(...skipping 10 matching lines...) Expand all
434 #endif 434 #endif
435 435
436 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_; 436 base::WeakPtrFactory<MediaRouterMojoImpl> weak_factory_;
437 437
438 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl); 438 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoImpl);
439 }; 439 };
440 440
441 } // namespace media_router 441 } // namespace media_router
442 442
443 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_IMPL_H_ 443 #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