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

Side by Side Diff: content/public/browser/presentation_service_delegate.h

Issue 2477573002: [Presentation API] (3rd) (1-UA) Split PresentationServiceDelegateImpl(PSDImpl) (Closed)
Patch Set: resolve code review comments from Derek Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_
6 #define CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ 6 #define CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_
7 7
8 #include <map>
8 #include <memory> 9 #include <memory>
9 #include <string> 10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 #include "content/public/browser/presentation_session.h" 16 #include "content/public/browser/presentation_session.h"
16 #include "content/public/browser/presentation_session_message.h" 17 #include "content/public/browser/presentation_session_message.h"
17 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h" 18 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 50
50 using PresentationConnectionStateChangedCallback = 51 using PresentationConnectionStateChangedCallback =
51 base::Callback<void(const PresentationConnectionStateChangeInfo&)>; 52 base::Callback<void(const PresentationConnectionStateChangeInfo&)>;
52 53
53 using PresentationConnectionPtr = blink::mojom::PresentationConnectionPtr; 54 using PresentationConnectionPtr = blink::mojom::PresentationConnectionPtr;
54 55
55 using ReceiverConnectionAvailableCallback = 56 using ReceiverConnectionAvailableCallback =
56 base::Callback<void(const content::PresentationSessionInfo&, 57 base::Callback<void(const content::PresentationSessionInfo&,
57 PresentationConnectionPtr)>; 58 PresentationConnectionPtr)>;
58 59
59 // An interface implemented by embedders to handle presentation API calls 60 // Base class for ControllerPresentationServiceDelegate and
60 // forwarded from PresentationServiceImpl. 61 // ReceiverPresentationServiceDelegate.
61 class CONTENT_EXPORT PresentationServiceDelegate { 62 class CONTENT_EXPORT PresentationServiceDelegate {
62 public: 63 public:
63 // Observer interface to listen for changes to PresentationServiceDelegate. 64 // Observer interface to listen for changes to PresentationServiceDelegate.
64 class CONTENT_EXPORT Observer { 65 class Observer {
65 public: 66 public:
66 // Called when the PresentationServiceDelegate is being destroyed. 67 // Called when the PresentationServiceDelegate is being destroyed.
67 virtual void OnDelegateDestroyed() = 0; 68 virtual void OnDelegateDestroyed() = 0;
68 69
69 protected: 70 protected:
70 virtual ~Observer() {} 71 virtual ~Observer() {}
71 }; 72 };
72 73
73 using SendMessageCallback = base::Callback<void(bool)>; 74 PresentationServiceDelegate();
74 75 virtual ~PresentationServiceDelegate();
75 virtual ~PresentationServiceDelegate() {}
76 76
77 // Registers an observer associated with frame with |render_process_id| 77 // Registers an observer associated with frame with |render_process_id|
78 // and |render_frame_id| with this class to listen for updates. 78 // and |render_frame_id| with this class to listen for updates.
79 // This class does not own the observer. 79 // This class does not own the observer.
80 // It is an error to add an observer if there is already an observer for that 80 // It is an error to add an observer if there is already an observer for that
81 // frame. 81 // frame.
82 virtual void AddObserver(int render_process_id, 82 virtual void AddObserver(int render_process_id,
83 int render_frame_id, 83 int render_frame_id,
84 Observer* observer) = 0; 84 Observer* observer);
85 85
86 // Unregisters the observer associated with the frame with |render_process_id| 86 // Unregisters the observer associated with the frame with |render_process_id|
87 // and |render_frame_id|. 87 // and |render_frame_id|.
88 // The observer will no longer receive updates. 88 // The observer will no longer receive updates.
89 virtual void RemoveObserver(int render_process_id, int render_frame_id) = 0; 89 virtual void RemoveObserver(int render_process_id, int render_frame_id);
90
91 // Resets the presentation state for the frame given by |render_process_id|
92 // and |render_frame_id|.
93 // This unregisters all screen availability associated with the given frame,
94 // and clears the default presentation URL for the frame.
95 virtual void Reset(int render_process_id, int render_frame_id) = 0;
96
97 private:
98 // Use as a key in the render frame map. Corresponds to a unique
99 // RenderFrameHost.
100 using RenderFrameHostID = std::pair<int, int>;
101 std::map<RenderFrameHostID, Observer*> observers_;
102 };
103
104 // An interface implemented by embedders to handle Presentation API calls
105 // forwarded from PresentationServiceImpl.
106 class CONTENT_EXPORT ControllerPresentationServiceDelegate
107 : public PresentationServiceDelegate {
108 public:
109 using SendMessageCallback = base::Callback<void(bool)>;
90 110
91 // Registers |listener| to continuously listen for 111 // Registers |listener| to continuously listen for
92 // availability updates for a presentation URL, originated from the frame 112 // availability updates for a presentation URL, originated from the frame
93 // given by |render_process_id| and |render_frame_id|. 113 // given by |render_process_id| and |render_frame_id|.
94 // This class does not own |listener|. 114 // This class does not own |listener|.
95 // Returns true on success. 115 // Returns true on success.
96 // This call will return false if a listener with the same presentation URL 116 // This call will return false if a listener with the same presentation URL
97 // from the same frame is already registered. 117 // from the same frame is already registered.
98 virtual bool AddScreenAvailabilityListener( 118 virtual bool AddScreenAvailabilityListener(
99 int render_process_id, 119 int render_process_id,
100 int render_frame_id, 120 int render_frame_id,
101 PresentationScreenAvailabilityListener* listener) = 0; 121 PresentationScreenAvailabilityListener* listener) = 0;
102 122
103 // Unregisters |listener| originated from the frame given by 123 // Unregisters |listener| originated from the frame given by
104 // |render_process_id| and |render_frame_id| from this class. The listener 124 // |render_process_id| and |render_frame_id| from this class. The listener
105 // will no longer receive availability updates. 125 // will no longer receive availability updates.
106 virtual void RemoveScreenAvailabilityListener( 126 virtual void RemoveScreenAvailabilityListener(
107 int render_process_id, 127 int render_process_id,
108 int render_frame_id, 128 int render_frame_id,
109 PresentationScreenAvailabilityListener* listener) = 0; 129 PresentationScreenAvailabilityListener* listener) = 0;
110 130
111 // Resets the presentation state for the frame given by |render_process_id|
112 // and |render_frame_id|.
113 // This unregisters all listeners associated with the given frame, and clears
114 // the default presentation URL and ID set for the frame.
115 virtual void Reset(
116 int render_process_id,
117 int render_frame_id) = 0;
118
119 // Sets the default presentation URLs for frame given by |render_process_id| 131 // Sets the default presentation URLs for frame given by |render_process_id|
120 // and |render_frame_id|. When the default presentation is started on this 132 // and |render_frame_id|. When the default presentation is started on this
121 // frame, |callback| will be invoked with the corresponding 133 // frame, |callback| will be invoked with the corresponding
122 // PresentationSessionInfo object. 134 // PresentationSessionInfo object.
123 // If |default_presentation_urls| is empty, the default presentation URLs will 135 // If |default_presentation_urls| is empty, the default presentation URLs will
124 // be cleared and the previously registered callback (if any) will be removed. 136 // be cleared and the previously registered callback (if any) will be removed.
125 virtual void SetDefaultPresentationUrls( 137 virtual void SetDefaultPresentationUrls(
126 int render_process_id, 138 int render_process_id,
127 int render_frame_id, 139 int render_frame_id,
128 const std::vector<GURL>& default_presentation_urls, 140 const std::vector<GURL>& default_presentation_urls,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // frame. 214 // frame.
203 // |render_process_id|, |render_frame_id|: ID of frame. 215 // |render_process_id|, |render_frame_id|: ID of frame.
204 // |connection|: PresentationConnection to listen for state changes. 216 // |connection|: PresentationConnection to listen for state changes.
205 // |state_changed_cb|: Invoked with the PresentationConnection and its new 217 // |state_changed_cb|: Invoked with the PresentationConnection and its new
206 // state whenever there is a state change. 218 // state whenever there is a state change.
207 virtual void ListenForConnectionStateChange( 219 virtual void ListenForConnectionStateChange(
208 int render_process_id, 220 int render_process_id,
209 int render_frame_id, 221 int render_frame_id,
210 const PresentationSessionInfo& connection, 222 const PresentationSessionInfo& connection,
211 const PresentationConnectionStateChangedCallback& state_changed_cb) = 0; 223 const PresentationConnectionStateChangedCallback& state_changed_cb) = 0;
224
225 // Connect |connection| owned by the controlling frame to the offscreen
226 // presentation represented by |session|.
227 // |render_process_id|, |render_frame_id|: ID of originating frame.
228 // |connection|: Pointer to controller's presentation connection,
229 // ownership passed from controlling frame to the offscreen presentation.
230 virtual void ConnectToOffscreenPresentation(
231 int render_process_id,
232 int render_frame_id,
233 const PresentationSessionInfo& session,
234 PresentationConnectionPtr connection) = 0;
235 };
236
237 // An interface implemented by embedders to handle
238 // PresentationService calls from a presentation receiver.
239 class CONTENT_EXPORT ReceiverPresentationServiceDelegate
240 : public PresentationServiceDelegate {
241 public:
242 // Registers a callback from the embedder when an offscreeen presentation has
243 // been successfully started.
244 // |receiver_available_callback|: Invoked when successfully starting a
245 // offscreen presentation session.
246 virtual void RegisterReceiverConnectionAvailableCallback(
247 const content::ReceiverConnectionAvailableCallback&
248 receiver_available_callback) = 0;
212 }; 249 };
213 250
214 } // namespace content 251 } // namespace content
215 252
216 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_ 253 #endif // CONTENT_PUBLIC_BROWSER_PRESENTATION_SERVICE_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698