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

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

Issue 979413002: [Presentation API] Additional plumbing for PresentationServiceImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@REAL-NEW-MASTER
Patch Set: Rebase 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
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 65e729f49bd85d0c73f5ba844c23837237dedf05..d86474fa6490350480ab6809e6536b13fa4ba2a5 100644
--- a/content/browser/presentation/presentation_service_impl.h
+++ b/content/browser/presentation/presentation_service_impl.h
@@ -11,6 +11,7 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "content/common/presentation/presentation_service.mojom.h"
#include "content/common/presentation/presentation_session.mojom.h"
@@ -56,7 +57,7 @@ class CONTENT_EXPORT PresentationServiceImpl
presentation::PresentationErrorPtr)>;
friend class PresentationServiceImplTest;
- FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, RemoveAllListeners);
+ FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, Reset);
FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
DidNavigateThisFrame);
FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
@@ -65,6 +66,12 @@ class CONTENT_EXPORT PresentationServiceImpl
ThisRenderFrameDeleted);
FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
NotThisRenderFrameDeleted);
+ FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
+ SetDefaultPresentationUrl);
+ FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
+ SetSameDefaultPresentationUrl);
+ FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest,
+ ClearDefaultPresentationUrl);
// |render_frame_host|: The RFH this instance is associated with.
// |web_contents|: The WebContents to observe.
@@ -88,6 +95,8 @@ class CONTENT_EXPORT PresentationServiceImpl
const mojo::String& presentation_url,
const mojo::String& presentation_id,
const NewSessionMojoCallback& callback) override;
+ void SetDefaultPresentationUrl(
+ const mojo::String& presentation_url) override;
// mojo::InterfaceImpl override.
// Note that this is called when the RenderFrameHost is deleted.
@@ -103,9 +112,18 @@ class CONTENT_EXPORT PresentationServiceImpl
// PresentationServiceDelegate::Observer
void OnDelegateDestroyed() override;
- // Removes all listeners on this instance and informs the
- // PresentationServiceDelegate of such.
- void RemoveAllListeners();
+ // Sets |default_presentation_url_| to |presentation_url| and informs the
+ // delegate of such.
+ void DoSetDefaultPresentationUrl(const std::string& presentation_url);
+
+ // Removes all listeners and resets default presentation URL on this instance
+ // and informs the PresentationServiceDelegate of such.
+ void Reset();
+
+ // Callbacks from the embedder as a result of StartSession/JoinSession.
+ void OnStartOrJoinSessionSucceeded(
+ const PresentationSessionInfo& session_info);
+ void OnStartOrJoinSessionError(const PresentationError& error);
RenderFrameHost* render_frame_host_;
PresentationServiceDelegate* delegate_;
@@ -144,6 +162,11 @@ class CONTENT_EXPORT PresentationServiceImpl
// |available|: New screen availability for the presentation URL.
void OnScreenAvailabilityChanged(bool available) override;
+ // Gets the callback as a raw pointer.
+ ScreenAvailabilityMojoCallback* callback() const {
+ return callback_ptr_.get();
+ }
+
private:
std::string presentation_url_;
scoped_ptr<ScreenAvailabilityMojoCallback> callback_ptr_;
@@ -156,6 +179,16 @@ class CONTENT_EXPORT PresentationServiceImpl
std::string default_presentation_url_;
+ // This is set when there is a StartSession/JoinSession in progress.
+ // Additional StartSession/JoinSession calls are ignored while this is
+ // set.
mark a. foltz 2015/03/11 01:08:19 Normally I wouldn't expect overlapping calls, but
imcheng 2015/03/12 20:03:41 For JoinSession, we should be able to let them ove
+ // When embedder returns with a result, this callback will be invoked and then
+ // reset.
+ scoped_ptr<NewSessionMojoCallback> start_or_join_session_cb_;
+
+ // NOTE: Weak pointers must be invalidated before all other member variables.
+ base::WeakPtrFactory<PresentationServiceImpl> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl);
};

Powered by Google App Engine
This is Rietveld 408576698