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

Unified Diff: chrome/browser/media/router/offscreen_presentation_manager.h

Issue 2477573002: [Presentation API] (3rd) (1-UA) Split PresentationServiceDelegateImpl(PSDImpl) (Closed)
Patch Set: resolve code review comments from dcheng Created 3 years, 11 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: chrome/browser/media/router/offscreen_presentation_manager.h
diff --git a/chrome/browser/media/router/offscreen_presentation_manager.h b/chrome/browser/media/router/offscreen_presentation_manager.h
index df276101817b84457e4d5f89f3ab08bffc4f3997..8eec5331cb0072b0d0bf73168723cf24f8a33f0e 100644
--- a/chrome/browser/media/router/offscreen_presentation_manager.h
+++ b/chrome/browser/media/router/offscreen_presentation_manager.h
@@ -18,20 +18,6 @@
class GURL;
-// TODO(zhaobin): move these back to
-// content/public/browser/presentation_service_delegate.h when they are actually
-// used in content.
-namespace content {
-// TODO(zhaobin): A class stub for blink::mojom::PresentationConnectionPtr.
-// presentation.mojom is under security review. Change this to
-// blink::mojom::PresentationConnectionPtr once that is done.
-class PresentationConnectionPtr {};
-
-using ReceiverConnectionAvailableCallback =
- base::Callback<void(const content::PresentationSessionInfo&,
- PresentationConnectionPtr)>;
-} // namespace content
-
namespace media_router {
// Manages all offscreen presentations started in the associated Profile and
// facilitates communication between the controllers and the receiver of an
@@ -114,31 +100,32 @@ class OffscreenPresentationManager : public KeyedService {
// exists.
// |controller|: Not owned by this class. Ownership is transferred to the
// presentation receiver via |receiver_callback| passed below.
- void RegisterOffscreenPresentationController(
+ virtual void RegisterOffscreenPresentationController(
const std::string& presentation_id,
const GURL& presentation_url,
const RenderFrameHostId& render_frame_id,
- content::PresentationConnectionPtr controller);
+ content::PresentationConnectionPtr controller_conn_ptr,
+ content::PresentationConnectionRequest receiver_conn_request);
// Unregisters controller PresentationConnectionPtr to presentation with
// |presentation_id|, |render_frame_id|. It does nothing if there is no
// controller that matches the provided arguments. It removes presentation
// that matches the arguments if the presentation has no receiver_callback and
// any other pending controller.
- void UnregisterOffscreenPresentationController(
+ virtual void UnregisterOffscreenPresentationController(
const std::string& presentation_id,
const RenderFrameHostId& render_frame_id);
// Registers ReceiverConnectionAvailableCallback to presentation
// with |presentation_id|.
- void OnOffscreenPresentationReceiverCreated(
+ virtual void OnOffscreenPresentationReceiverCreated(
const std::string& presentation_id,
const GURL& presentation_url,
const content::ReceiverConnectionAvailableCallback& receiver_callback);
// Unregisters the ReceiverConnectionAvailableCallback associated with
// |presentation_id|.
- void OnOffscreenPresentationReceiverTerminated(
+ virtual void OnOffscreenPresentationReceiverTerminated(
const std::string& presentation_id);
private:
@@ -157,8 +144,10 @@ class OffscreenPresentationManager : public KeyedService {
// Register |controller| with |render_frame_id|. If |receiver_callback_| has
// been set, invoke |receiver_callback_| with |controller| as parameter,
// else store |controller| in |pending_controllers_| map.
- void RegisterController(const RenderFrameHostId& render_frame_id,
- content::PresentationConnectionPtr controller);
+ void RegisterController(
+ const RenderFrameHostId& render_frame_id,
+ content::PresentationConnectionPtr controller_conn_ptr,
+ content::PresentationConnectionRequest receiver_conn_request);
// Unregister controller with |render_frame_id|. Do nothing if there is no
// pending controller with |render_frame_id|.
@@ -185,10 +174,21 @@ class OffscreenPresentationManager : public KeyedService {
// Callback to invoke whenever a receiver connection is available.
content::ReceiverConnectionAvailableCallback receiver_callback_;
+ struct ControllerConnection {
+ public:
+ ControllerConnection(
+ content::PresentationConnectionPtr controller_conn_ptr,
+ content::PresentationConnectionRequest receiver_conn_request);
+ ~ControllerConnection();
+
+ content::PresentationConnectionPtr controller_conn_ptr;
+ content::PresentationConnectionRequest receiver_conn_request;
+ };
+
// Contains Mojo pointers to controller PresentationConnections registered
// via |RegisterController()| before |receiver_callback_| is set.
std::unordered_map<RenderFrameHostId,
- content::PresentationConnectionPtr,
+ std::unique_ptr<ControllerConnection>,
RenderFrameHostIdHasher>
pending_controllers_;
@@ -198,6 +198,9 @@ class OffscreenPresentationManager : public KeyedService {
private:
friend class OffscreenPresentationManagerFactory;
friend class OffscreenPresentationManagerTest;
+ friend class MockOffscreenPresentationManager;
+ FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest,
+ ConnectToOffscreenPresentation);
// Used by OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext.
OffscreenPresentationManager();

Powered by Google App Engine
This is Rietveld 408576698