Chromium Code Reviews| Index: chrome/browser/ui/webui/media_router/media_router_dialog_controller.h |
| diff --git a/chrome/browser/ui/webui/media_router/media_router_dialog_controller.h b/chrome/browser/ui/webui/media_router/media_router_dialog_controller.h |
| index f357d00bb173adb44d65fe467591b1280f31dc7a..19ce9a5d5e1e90fcc3363322d191974c5db2ac17 100644 |
| --- a/chrome/browser/ui/webui/media_router/media_router_dialog_controller.h |
| +++ b/chrome/browser/ui/webui/media_router/media_router_dialog_controller.h |
| @@ -6,7 +6,9 @@ |
| #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_MEDIA_ROUTER_DIALOG_CONTROLLER_H_ |
| #include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| #include "chrome/browser/media/router/create_session_request.h" |
| +#include "chrome/browser/media/router/media_router.h" |
| #include "content/public/browser/web_contents_observer.h" |
| #include "content/public/browser/web_contents_user_data.h" |
| @@ -50,9 +52,26 @@ class MediaRouterDialogController |
| // It is an error to call this function if there is currently no dialog. |
| void CloseMediaRouterDialog(); |
| + // Called by the dialog when it is about to make a presentation route request |
| + // to ensure the response can be received and handled properly even when |
| + // the dialog is destroyed while the request is in progress. |
| + // Returns a MediaRouteResponseCallback that can be used to be used as the |
| + // callback argument in |MediaRouter::CreateRoute()|. |
| + // |route_response_callback|: Callback to the dialog to invoke when the |
| + // presentation route response comes back, if the dialog still exists. |
| + // |presentation_request|: The Presentation API request to respond to when |
| + // route reponse comes back, or nullptr if the presentation route request |
|
Kevin M
2015/07/13 21:55:26
Suggestion: ...or nullptr if the request did not o
imcheng
2015/07/14 01:00:24
Done.
|
| + // does not correspond to a Presentation API request (i.e. browser initiated). |
| + MediaRouteResponseCallback AddPresentationRouteRequest( |
| + const MediaRouteResponseCallback& route_response_callback, |
| + scoped_ptr<CreateSessionRequest> presentation_request); |
| + |
| private: |
| class DialogWebContentsObserver; |
| class InitiatorWebContentsObserver; |
| + class MediaRouterDialogCallbacks; |
| + class BrowserInitiatedMediaRouterDialogCallbacks; |
|
Kevin M
2015/07/13 21:55:26
alpha sort?
imcheng
2015/07/14 01:00:24
Done.
|
| + class PresentationMediaRouterDialogCallbacks; |
| friend class content::WebContentsUserData<MediaRouterDialogController>; |
| // Use MediaRouterDialogController::CreateForWebContents() to create an |
| @@ -70,6 +89,12 @@ class MediaRouterDialogController |
| void PopulateDialog(content::WebContents* media_router_dialog); |
| + // Destroys |callbacks| by removing it from |pending_dialog_callbacks_|. |
| + // Called by MediaRouterDialogCallbacks after it receives route response and |
| + // is done processing it. |
| + // |callbacks|: The MediaRouterDialogCallbacks to destroy. |
| + void DestroyDialogCallbacks(MediaRouterDialogCallbacks* callbacks); |
| + |
| scoped_ptr<InitiatorWebContentsObserver> initiator_observer_; |
| scoped_ptr<DialogWebContentsObserver> dialog_observer_; |
| @@ -84,6 +109,11 @@ class MediaRouterDialogController |
| // passed to the MediaRouterUI when it is initialized. |
| scoped_ptr<CreateSessionRequest> presentation_request_; |
| + // MediaRouterDialogCallbacks corresponding to presentation route requests |
| + // made from dialogs created from this instance. Note that they may outlive |
| + // their corresponding dialogs. |
| + ScopedVector<MediaRouterDialogCallbacks> pending_dialog_callbacks_; |
| + |
| base::ThreadChecker thread_checker_; |
| DISALLOW_COPY_AND_ASSIGN(MediaRouterDialogController); |