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

Unified Diff: chrome/browser/ui/webui/media_router/media_router_ui.h

Issue 1224093004: [Media Router] 2nd take on fix route response callback lifetime in UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/media_router/media_router_ui.h
diff --git a/chrome/browser/ui/webui/media_router/media_router_ui.h b/chrome/browser/ui/webui/media_router/media_router_ui.h
index e3e4a21838fd8bb587d2f305f5520b6429875f1e..3c851fca487e5cd105ad48730927a5b0a6310385 100644
--- a/chrome/browser/ui/webui/media_router/media_router_ui.h
+++ b/chrome/browser/ui/webui/media_router/media_router_ui.h
@@ -31,6 +31,7 @@ namespace media_router {
class IssuesObserver;
class MediaRoute;
class MediaRouter;
+class MediaRouterDialogCallbacks;
class MediaRouterWebUIMessageHandler;
class MediaRoutesObserver;
class MediaSink;
@@ -48,24 +49,37 @@ class MediaRouterUI
~MediaRouterUI() override;
// Initializes internal state (e.g. starts listening for MediaSinks) for
- // targeting the default MediaSource (if any) of the tab. The contents of the
- // UI will change as the default MediaSource changes. If there is a default
- // MediaSource, then DEFAULT MediaCastMode will be added to |cast_modes_|.
- // |source_manager|: PresentationServiceDelegateImpl of the initiator tab.
- // Must not be null.
- // Can only be called once.
+ // targeting the default MediaSource (if any) of the initiator tab as
+ // determined by |delegate|, as well as mirroring sources of that tab.
+ // The contents of the UI will change as the default MediaSource changes.
+ // If there is a default MediaSource, then DEFAULT MediaCastMode will be
+ // added to |cast_modes_|.
+ // Init* methods can only be called once.
+ // |delegate|: PresentationServiceDelegateImpl of the initiator tab.
+ // Must not be null.
+ // |dialog_callbacks|: The set of callbacks to be invoked by the UI as a
+ // result of certain operations. Must not be null.
// TODO(imcheng): Replace use of impl with an intermediate abstract
// interface.
- void InitWithDefaultMediaSource(PresentationServiceDelegateImpl* delegate);
+ void InitWithDefaultMediaSource(
+ const base::WeakPtr<PresentationServiceDelegateImpl>& delegate,
+ MediaRouterDialogCallbacks* dialog_callbacks);
// Initializes internal state targeting the presentation specified in
- // |request|. Also sets up mirroring sources based on |initiator|.
+ // the CreateSessionRequest in |dialog_callbacks|.
+ // Also sets up mirroring sources based on |initiator|.
// This is different from |InitWithDefaultMediaSource| in that it does not
// listen for default media source changes, as the UI is fixed to the source
// in |request|.
+ // Init* methods can only be called once.
+ // |intiator|: Reference to the WebContents that initiated the dialog.
+ // Must not be null.
+ // |dialog_callbacks|: The set of callbacks to be invoked by the UI as a
+ // result of certain operations. Must not be null, and
+ // must contain a CreateSessionRequest.
void InitWithPresentationSessionRequest(
const content::WebContents* initiator,
- scoped_ptr<CreateSessionRequest> request);
+ MediaRouterDialogCallbacks* dialog_callbacks);
// Closes the media router UI.
void Close();
@@ -125,7 +139,7 @@ class MediaRouterUI
// Callback passed to MediaRouter to receive response to route creation
// requests.
- void OnRouteResponseReceived(scoped_ptr<MediaRoute> route,
+ void OnRouteResponseReceived(const MediaRoute* route,
const std::string& error);
bool DoCreateRoute(const MediaSink::Id& sink_id, MediaCastMode cast_mode);
@@ -139,12 +153,8 @@ class MediaRouterUI
// and optional |default_source| and |default_frame_url| if any.
void InitCommon(const content::WebContents* initiator,
const MediaSource& default_source,
- const GURL& default_frame_url);
-
- // Invoke presentation callbacks based on |route| and |error| if the dialog
- // was created for Presentation API.
- void HandleRouteResponseForPresentation(const MediaRoute* route,
- const std::string& error);
+ const GURL& default_frame_url,
+ MediaRouterDialogCallbacks* dialog_callbacks);
// PresentationServiceDelegateImpl::DefaultMediaSourceObserver
void OnDefaultMediaSourceChanged(const MediaSource& source,
@@ -174,9 +184,6 @@ class MediaRouterUI
scoped_ptr<QueryResultManager> query_result_manager_;
- // Only set if the UI is created as a result of Presentation API.
- scoped_ptr<CreateSessionRequest> presentation_session_request_;
-
// It's possible for PresentationServiceDelegateImpl to be destroyed before
// this class.
// (e.g. if a tab with the UI open is closed, then the tab WebContents will
@@ -186,6 +193,8 @@ class MediaRouterUI
// TODO(imcheng): hold a weak ptr to an abstract type instead.
base::WeakPtr<PresentationServiceDelegateImpl> presentation_service_delegate_;
+ MediaRouterDialogCallbacks* dialog_callbacks_;
+
const content::WebContents* initiator_;
// Cached pointer to the MediaRouter for this instance's BrowserContext.

Powered by Google App Engine
This is Rietveld 408576698