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

Unified Diff: content/browser/presentation/presentation_service_impl.h

Issue 996173006: [Presentation API] Fix potential callback leaks in PSImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Anton's comments Created 5 years, 9 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
« no previous file with comments | « no previous file | content/browser/presentation/presentation_service_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « no previous file | content/browser/presentation/presentation_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698