Index: content/browser/presentation/presentation_service_impl.h |
diff --git a/content/browser/presentation/presentation_service_impl.h b/content/browser/presentation/presentation_service_impl.h |
index 104b3ae9b92b5d79fb731a844629e0e9f1f0d941..315f0a760155bd2e675778470d7f420292066257 100644 |
--- a/content/browser/presentation/presentation_service_impl.h |
+++ b/content/browser/presentation/presentation_service_impl.h |
@@ -181,6 +181,14 @@ class CONTENT_EXPORT PresentationServiceImpl |
// PresentationServiceDelegate::Observer |
void OnDelegateDestroyed() override; |
+ // Finds the callback from |pending_session_cbs_| using |request_session_id|. |
+ // If it exists, invoke it with |session| and |error|, then erase it from |
+ // |pending_session_cbs_|. |
+ void RunAndEraseNewSessionMojoCallback( |
+ int request_session_id, |
+ presentation::PresentationSessionInfoPtr session, |
+ presentation::PresentationErrorPtr error); |
+ |
// Sets |default_presentation_url_| to |presentation_url| and informs the |
// delegate of new default presentation URL and ID. |
void DoSetDefaultPresentationUrl( |
@@ -196,11 +204,11 @@ class CONTENT_EXPORT PresentationServiceImpl |
// invocation. |
void OnStartOrJoinSessionSucceeded( |
bool is_start_session, |
- const NewSessionMojoCallback& callback, |
+ int request_session_id, |
const PresentationSessionInfo& session_info); |
void OnStartOrJoinSessionError( |
bool is_start_session, |
- const NewSessionMojoCallback& callback, |
+ int request_session_id, |
const PresentationError& error); |
// Requests delegate to start a session. |
@@ -215,6 +223,14 @@ class CONTENT_EXPORT PresentationServiceImpl |
// the first one in the queue. |
void HandleQueuedStartSessionRequests(); |
+ // Associates |callback| with a unique request ID and stores it in a map. |
+ int RegisterNewSessionCallback( |
+ const NewSessionMojoCallback& callback); |
+ |
+ // Invokes |callback| with an error. |
+ void InvokeNewSessionMojoCallbackWithError( |
+ const NewSessionMojoCallback& callback); |
+ |
// Gets the ScreenAvailabilityContext for |presentation_url|, or creates one |
// if it does not exist. |
ScreenAvailabilityContext* GetOrCreateAvailabilityContext( |
@@ -235,6 +251,9 @@ class CONTENT_EXPORT PresentationServiceImpl |
// it is removed from head of the queue. |
std::deque<linked_ptr<StartSessionRequest>> queued_start_session_requests_; |
+ int next_request_session_id_; |
+ base::hash_map<int, linked_ptr<NewSessionMojoCallback>> pending_session_cbs_; |
+ |
// NOTE: Weak pointers must be invalidated before all other member variables. |
base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |