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

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

Issue 1436703002: Revert of [Presentation API / Media Router] Clean up default pres URL logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « chrome/chrome_tests_unit.gypi ('k') | 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 54e1a4c14975d0589cf37ae56169a4c07ce7ead5..220c256a5dc7ff31bd51271ffa98fad6ae679c34 100644
--- a/content/browser/presentation/presentation_service_impl.h
+++ b/content/browser/presentation/presentation_service_impl.h
@@ -94,7 +94,7 @@
// Maximum number of pending JoinSession requests at any given time.
static const int kMaxNumQueuedSessionRequests = 10;
- using PresentationSessionMojoCallback =
+ using DefaultSessionMojoCallback =
mojo::Callback<void(presentation::PresentationSessionInfoPtr)>;
using SessionStateCallback =
mojo::Callback<void(presentation::PresentationSessionInfoPtr,
@@ -125,6 +125,27 @@
PresentationServiceImpl* const service_;
};
+ class CONTENT_EXPORT DefaultSessionStartContext {
+ public:
+ DefaultSessionStartContext();
+ ~DefaultSessionStartContext();
+
+ // Adds a callback. May invoke the callback immediately if |session| using
+ // default presentation URL was already started.
+ void AddCallback(const DefaultSessionMojoCallback& callback);
+
+ // Sets the session info. Maybe invoke callbacks queued with AddCallback().
+ void set_session(const PresentationSessionInfo& session);
+
+ private:
+ // Flush all queued callbacks by invoking them with null
+ // PresentationSessionInfoPtr.
+ void Reset();
+
+ ScopedVector<DefaultSessionMojoCallback> callbacks_;
+ scoped_ptr<PresentationSessionInfo> session_;
+ };
+
// Ensures the provided NewSessionMojoCallback is invoked exactly once
// before it goes out of scope.
class NewSessionMojoCallbackWrapper {
@@ -156,6 +177,8 @@
void SetClient(presentation::PresentationServiceClientPtr client) override;
void ListenForScreenAvailability(const mojo::String& url) override;
void StopListeningForScreenAvailability(const mojo::String& url) override;
+ void ListenForDefaultSessionStart(
+ const DefaultSessionMojoCallback& callback) override;
void StartSession(
const mojo::String& presentation_url,
const NewSessionMojoCallback& callback) override;
@@ -185,11 +208,8 @@
// PresentationServiceDelegate::Observer
void OnDelegateDestroyed() override;
-
- // Passed to embedder's implementation of PresentationServiceDelegate for
- // later invocation when default presentation has started.
- void OnDefaultPresentationStarted(
- const PresentationSessionInfo& session_info);
+ void OnDefaultPresentationStarted(const PresentationSessionInfo& session)
+ override;
// Finds the callback from |pending_join_session_cbs_| using
// |request_session_id|.
@@ -264,6 +284,8 @@
base::hash_map<int, linked_ptr<NewSessionMojoCallbackWrapper>>
pending_join_session_cbs_;
+ scoped_ptr<DefaultSessionStartContext> default_session_start_context_;
+
// RAII binding of |this| to an Presentation interface request.
// The binding is removed when binding_ is cleared or goes out of scope.
scoped_ptr<mojo::Binding<presentation::PresentationService>> binding_;
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | content/browser/presentation/presentation_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698