| OLD | NEW |
| 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_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
| 6 #define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 6 #define CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // related to the RFH via implementing WebContentsObserver. | 43 // related to the RFH via implementing WebContentsObserver. |
| 44 // This class is instantiated on-demand via Mojo's ConnectToRemoteService | 44 // This class is instantiated on-demand via Mojo's ConnectToRemoteService |
| 45 // from the renderer when the first presentation API request is handled. | 45 // from the renderer when the first presentation API request is handled. |
| 46 class CONTENT_EXPORT PresentationServiceImpl | 46 class CONTENT_EXPORT PresentationServiceImpl |
| 47 : public NON_EXPORTED_BASE(blink::mojom::PresentationService), | 47 : public NON_EXPORTED_BASE(blink::mojom::PresentationService), |
| 48 public WebContentsObserver, | 48 public WebContentsObserver, |
| 49 public PresentationServiceDelegate::Observer { | 49 public PresentationServiceDelegate::Observer { |
| 50 public: | 50 public: |
| 51 ~PresentationServiceImpl() override; | 51 ~PresentationServiceImpl() override; |
| 52 | 52 |
| 53 using NewSessionCallback = | 53 using NewPresentationCallback = |
| 54 base::Callback<void(const base::Optional<PresentationSessionInfo>&, | 54 base::Callback<void(const base::Optional<PresentationInfo>&, |
| 55 const base::Optional<PresentationError>&)>; | 55 const base::Optional<PresentationError>&)>; |
| 56 | 56 |
| 57 // Static factory method to create an instance of PresentationServiceImpl. | 57 // Static factory method to create an instance of PresentationServiceImpl. |
| 58 // |render_frame_host|: The RFH the instance is associated with. | 58 // |render_frame_host|: The RFH the instance is associated with. |
| 59 // |request|: The instance will be bound to this request. Used for Mojo setup. | 59 // |request|: The instance will be bound to this request. Used for Mojo setup. |
| 60 static void CreateMojoService( | 60 static void CreateMojoService( |
| 61 RenderFrameHost* render_frame_host, | 61 RenderFrameHost* render_frame_host, |
| 62 mojo::InterfaceRequest<blink::mojom::PresentationService> request); | 62 mojo::InterfaceRequest<blink::mojom::PresentationService> request); |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 friend class PresentationServiceImplTest; | 65 friend class PresentationServiceImplTest; |
| 66 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, Reset); | 66 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, Reset); |
| 67 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, DidNavigateThisFrame); | 67 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, DidNavigateThisFrame); |
| 68 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 68 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 69 DidNavigateOtherFrame); | 69 DidNavigateOtherFrame); |
| 70 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, ThisRenderFrameDeleted); | 70 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, ThisRenderFrameDeleted); |
| 71 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 71 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 72 OtherRenderFrameDeleted); | 72 OtherRenderFrameDeleted); |
| 73 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, DelegateFails); | 73 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, DelegateFails); |
| 74 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 74 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 75 SetDefaultPresentationUrls); | 75 SetDefaultPresentationUrls); |
| 76 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 76 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 77 SetSameDefaultPresentationUrls); | 77 SetSameDefaultPresentationUrls); |
| 78 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 78 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 79 ClearDefaultPresentationUrls); | 79 ClearDefaultPresentationUrls); |
| 80 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 80 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 81 ListenForDefaultSessionStart); | 81 ListenForDefaultPresentationStart); |
| 82 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 82 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 83 ListenForDefaultSessionStartAfterSet); | 83 ListenForDefaultPresentationStartAfterSet); |
| 84 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 84 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 85 DefaultSessionStartReset); | 85 DefaultPresentationStartReset); |
| 86 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 86 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 87 ReceiveConnectionMessagesAfterReset); | 87 ReceiveConnectionMessagesAfterReset); |
| 88 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 88 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 89 MaxPendingStartSessionRequests); | 89 MaxPendingStartPresentationRequests); |
| 90 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 90 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 91 MaxPendingJoinSessionRequests); | 91 MaxPendingReconnectPresentationRequests); |
| 92 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 92 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 93 ListenForConnectionStateChange); | 93 ListenForConnectionStateChange); |
| 94 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 94 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 95 ListenForConnectionClose); | 95 ListenForConnectionClose); |
| 96 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 96 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 97 SetPresentationConnection); | 97 SetPresentationConnection); |
| 98 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 98 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 99 ReceiverPresentationServiceDelegate); | 99 ReceiverPresentationServiceDelegate); |
| 100 | 100 |
| 101 // Maximum number of pending JoinSession requests at any given time. | 101 // Maximum number of pending ReconnectPresentation requests at any given time. |
| 102 static const int kMaxNumQueuedSessionRequests = 10; | 102 static const int kMaxQueuedRequests = 10; |
| 103 | 103 |
| 104 using ConnectionMessagesCallback = | 104 using ConnectionMessagesCallback = |
| 105 base::Callback<void(std::vector<PresentationConnectionMessage>)>; | 105 base::Callback<void(std::vector<PresentationConnectionMessage>)>; |
| 106 | 106 |
| 107 // Listener implementation owned by PresentationServiceImpl. An instance of | 107 // Listener implementation owned by PresentationServiceImpl. An instance of |
| 108 // this is created when PresentationRequest.getAvailability() is resolved. | 108 // this is created when PresentationRequest.getAvailability() is resolved. |
| 109 // The instance receives screen availability results from the embedder and | 109 // The instance receives screen availability results from the embedder and |
| 110 // propagates results back to PresentationServiceImpl. | 110 // propagates results back to PresentationServiceImpl. |
| 111 class CONTENT_EXPORT ScreenAvailabilityListenerImpl | 111 class CONTENT_EXPORT ScreenAvailabilityListenerImpl |
| 112 : public PresentationScreenAvailabilityListener { | 112 : public PresentationScreenAvailabilityListener { |
| 113 public: | 113 public: |
| 114 ScreenAvailabilityListenerImpl(const GURL& availability_url, | 114 ScreenAvailabilityListenerImpl(const GURL& availability_url, |
| 115 PresentationServiceImpl* service); | 115 PresentationServiceImpl* service); |
| 116 ~ScreenAvailabilityListenerImpl() override; | 116 ~ScreenAvailabilityListenerImpl() override; |
| 117 | 117 |
| 118 // PresentationScreenAvailabilityListener implementation. | 118 // PresentationScreenAvailabilityListener implementation. |
| 119 GURL GetAvailabilityUrl() const override; | 119 GURL GetAvailabilityUrl() const override; |
| 120 void OnScreenAvailabilityChanged(bool available) override; | 120 void OnScreenAvailabilityChanged(bool available) override; |
| 121 void OnScreenAvailabilityNotSupported() override; | 121 void OnScreenAvailabilityNotSupported() override; |
| 122 | 122 |
| 123 private: | 123 private: |
| 124 const GURL availability_url_; | 124 const GURL availability_url_; |
| 125 PresentationServiceImpl* const service_; | 125 PresentationServiceImpl* const service_; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 // Ensures the provided NewSessionCallback is invoked exactly once | 128 // Ensures the provided NewPresentationCallback is invoked exactly once |
| 129 // before it goes out of scope. | 129 // before it goes out of scope. |
| 130 class NewSessionCallbackWrapper { | 130 class NewPresentationCallbackWrapper { |
| 131 public: | 131 public: |
| 132 explicit NewSessionCallbackWrapper( | 132 explicit NewPresentationCallbackWrapper( |
| 133 const NewSessionCallback& callback); | 133 const NewPresentationCallback& callback); |
| 134 ~NewSessionCallbackWrapper(); | 134 ~NewPresentationCallbackWrapper(); |
| 135 | 135 |
| 136 void Run(const base::Optional<PresentationSessionInfo>& session_info, | 136 void Run(const base::Optional<PresentationInfo>& presentation_info, |
| 137 const base::Optional<PresentationError>& error); | 137 const base::Optional<PresentationError>& error); |
| 138 | 138 |
| 139 private: | 139 private: |
| 140 NewSessionCallback callback_; | 140 NewPresentationCallback callback_; |
| 141 | 141 |
| 142 DISALLOW_COPY_AND_ASSIGN(NewSessionCallbackWrapper); | 142 DISALLOW_COPY_AND_ASSIGN(NewPresentationCallbackWrapper); |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 // |render_frame_host|: The RFH this instance is associated with. | 145 // |render_frame_host|: The RFH this instance is associated with. |
| 146 // |web_contents|: The WebContents to observe. | 146 // |web_contents|: The WebContents to observe. |
| 147 // |controller_delegate|: Where Presentation API requests are delegated to in | 147 // |controller_delegate|: Where Presentation API requests are delegated to in |
| 148 // controller frame. Set to nullptr if current frame is receiver frame. Not | 148 // controller frame. Set to nullptr if current frame is receiver frame. Not |
| 149 // owned by this class. | 149 // owned by this class. |
| 150 // |receiver_delegate|: Where Presentation API requests are delegated to in | 150 // |receiver_delegate|: Where Presentation API requests are delegated to in |
| 151 // receiver frame. Set to nullptr if current frame is controller frame. Not | 151 // receiver frame. Set to nullptr if current frame is controller frame. Not |
| 152 // owned by this class. | 152 // owned by this class. |
| 153 PresentationServiceImpl( | 153 PresentationServiceImpl( |
| 154 RenderFrameHost* render_frame_host, | 154 RenderFrameHost* render_frame_host, |
| 155 WebContents* web_contents, | 155 WebContents* web_contents, |
| 156 ControllerPresentationServiceDelegate* controller_delegate, | 156 ControllerPresentationServiceDelegate* controller_delegate, |
| 157 ReceiverPresentationServiceDelegate* receiver_delegate); | 157 ReceiverPresentationServiceDelegate* receiver_delegate); |
| 158 | 158 |
| 159 // PresentationService implementation. | 159 // PresentationService implementation. |
| 160 void SetDefaultPresentationUrls( | 160 void SetDefaultPresentationUrls( |
| 161 const std::vector<GURL>& presentation_urls) override; | 161 const std::vector<GURL>& presentation_urls) override; |
| 162 void SetClient(blink::mojom::PresentationServiceClientPtr client) override; | 162 void SetClient(blink::mojom::PresentationServiceClientPtr client) override; |
| 163 void ListenForScreenAvailability(const GURL& url) override; | 163 void ListenForScreenAvailability(const GURL& url) override; |
| 164 void StopListeningForScreenAvailability(const GURL& url) override; | 164 void StopListeningForScreenAvailability(const GURL& url) override; |
| 165 void StartSession(const std::vector<GURL>& presentation_urls, | 165 void StartPresentation(const std::vector<GURL>& presentation_urls, |
| 166 const NewSessionCallback& callback) override; | 166 const NewPresentationCallback& callback) override; |
| 167 void JoinSession(const std::vector<GURL>& presentation_urls, | 167 void ReconnectPresentation(const std::vector<GURL>& presentation_urls, |
| 168 const base::Optional<std::string>& presentation_id, | 168 const base::Optional<std::string>& presentation_id, |
| 169 const NewSessionCallback& callback) override; | 169 const NewPresentationCallback& callback) override; |
| 170 void CloseConnection(const GURL& presentation_url, | 170 void CloseConnection(const GURL& presentation_url, |
| 171 const std::string& presentation_id) override; | 171 const std::string& presentation_id) override; |
| 172 void Terminate(const GURL& presentation_url, | 172 void Terminate(const GURL& presentation_url, |
| 173 const std::string& presentation_id) override; | 173 const std::string& presentation_id) override; |
| 174 void ListenForConnectionMessages( | 174 void ListenForConnectionMessages( |
| 175 const PresentationSessionInfo& session_info) override; | 175 const PresentationInfo& presentation_info) override; |
| 176 void SetPresentationConnection( | 176 void SetPresentationConnection( |
| 177 const PresentationSessionInfo& session_info, | 177 const PresentationInfo& presentation_info, |
| 178 blink::mojom::PresentationConnectionPtr controller_connection_ptr, | 178 blink::mojom::PresentationConnectionPtr controller_connection_ptr, |
| 179 blink::mojom::PresentationConnectionRequest receiver_connection_request) | 179 blink::mojom::PresentationConnectionRequest receiver_connection_request) |
| 180 override; | 180 override; |
| 181 | 181 |
| 182 // Creates a binding between this object and |request|. | 182 // Creates a binding between this object and |request|. |
| 183 void Bind(mojo::InterfaceRequest<blink::mojom::PresentationService> request); | 183 void Bind(mojo::InterfaceRequest<blink::mojom::PresentationService> request); |
| 184 | 184 |
| 185 // WebContentsObserver override. | 185 // WebContentsObserver override. |
| 186 void DidFinishNavigation(NavigationHandle* navigation_handle) override; | 186 void DidFinishNavigation(NavigationHandle* navigation_handle) override; |
| 187 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; | 187 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
| 188 void WebContentsDestroyed() override; | 188 void WebContentsDestroyed() override; |
| 189 | 189 |
| 190 // PresentationServiceDelegate::Observer | 190 // PresentationServiceDelegate::Observer |
| 191 void OnDelegateDestroyed() override; | 191 void OnDelegateDestroyed() override; |
| 192 | 192 |
| 193 // Passed to embedder's implementation of PresentationServiceDelegate for | 193 // Passed to embedder's implementation of PresentationServiceDelegate for |
| 194 // later invocation when default presentation has started. | 194 // later invocation when default presentation has started. |
| 195 void OnDefaultPresentationStarted( | 195 void OnDefaultPresentationStarted(const PresentationInfo& presentation_info); |
| 196 const PresentationSessionInfo& session_info); | |
| 197 | 196 |
| 198 // Finds the callback from |pending_join_session_cbs_| using | 197 // Finds the callback from |pending_reconnect_presentation_cbs_| using |
| 199 // |request_session_id|. | 198 // |request_id|. |
| 200 // If it exists, invoke it with |session_info| and |error|, then erase it from | 199 // If it exists, invoke it with |presentation_info| and |error|, then erase it |
| 201 // |pending_join_session_cbs_|. | 200 // from |pending_reconnect_presentation_cbs_|. Returns true if the callback |
| 202 // Returns true if the callback was found. | 201 // was found. |
| 203 bool RunAndEraseJoinSessionMojoCallback( | 202 bool RunAndEraseReconnectPresentationMojoCallback( |
| 204 int request_session_id, | 203 int request_id, |
| 205 const base::Optional<PresentationSessionInfo>& session_info, | 204 const base::Optional<PresentationInfo>& presentation_info, |
| 206 const base::Optional<PresentationError>& error); | 205 const base::Optional<PresentationError>& error); |
| 207 | 206 |
| 208 // Removes all listeners and resets default presentation URL on this instance | 207 // Removes all listeners and resets default presentation URL on this instance |
| 209 // and informs the PresentationServiceDelegate of such. | 208 // and informs the PresentationServiceDelegate of such. |
| 210 void Reset(); | 209 void Reset(); |
| 211 | 210 |
| 212 // These functions are bound as base::Callbacks and passed to | 211 // These functions are bound as base::Callbacks and passed to |
| 213 // embedder's implementation of PresentationServiceDelegate for later | 212 // embedder's implementation of PresentationServiceDelegate for later |
| 214 // invocation. | 213 // invocation. |
| 215 void OnStartSessionSucceeded( | 214 void OnStartPresentationSucceeded(int request_id, |
| 216 int request_session_id, | 215 const PresentationInfo& presentation_info); |
| 217 const PresentationSessionInfo& session_info); | 216 void OnStartPresentationError(int request_id, const PresentationError& error); |
| 218 void OnStartSessionError( | 217 void OnReconnectPresentationSucceeded( |
| 219 int request_session_id, | 218 int request_id, |
| 220 const PresentationError& error); | 219 const PresentationInfo& presentation_info); |
| 221 void OnJoinSessionSucceeded( | 220 void OnReconnectPresentationError(int request_id, |
| 222 int request_session_id, | 221 const PresentationError& error); |
| 223 const PresentationSessionInfo& session_info); | |
| 224 void OnJoinSessionError( | |
| 225 int request_session_id, | |
| 226 const PresentationError& error); | |
| 227 | 222 |
| 228 // Calls to |delegate_| to start listening for state changes for |connection|. | 223 // Calls to |delegate_| to start listening for state changes for |connection|. |
| 229 // State changes will be returned via |OnConnectionStateChanged|. | 224 // State changes will be returned via |OnConnectionStateChanged|. |
| 230 void ListenForConnectionStateChange( | 225 void ListenForConnectionStateChange(const PresentationInfo& connection); |
| 231 const PresentationSessionInfo& connection); | |
| 232 | 226 |
| 233 // Passed to embedder's implementation of PresentationServiceDelegate for | 227 // Passed to embedder's implementation of PresentationServiceDelegate for |
| 234 // later invocation when session messages arrive. | 228 // later invocation when connection messages arrive. |
| 235 void OnConnectionMessages( | 229 void OnConnectionMessages( |
| 236 const content::PresentationSessionInfo& session_info, | 230 const content::PresentationInfo& presentation_info, |
| 237 std::vector<content::PresentationConnectionMessage> messages); | 231 std::vector<content::PresentationConnectionMessage> messages); |
| 238 | 232 |
| 239 // A callback registered to OffscreenPresentationManager when | 233 // A callback registered to OffscreenPresentationManager when |
| 240 // the PresentationServiceImpl for the presentation receiver is initialized. | 234 // the PresentationServiceImpl for the presentation receiver is initialized. |
| 241 // Calls |client_| to create a new PresentationConnection on receiver page. | 235 // Calls |client_| to create a new PresentationConnection on receiver page. |
| 242 void OnReceiverConnectionAvailable( | 236 void OnReceiverConnectionAvailable( |
| 243 const content::PresentationSessionInfo& session_info, | 237 const content::PresentationInfo& presentation_info, |
| 244 PresentationConnectionPtr controller_connection_ptr, | 238 PresentationConnectionPtr controller_connection_ptr, |
| 245 PresentationConnectionRequest receiver_connection_request); | 239 PresentationConnectionRequest receiver_connection_request); |
| 246 | 240 |
| 247 // Associates a JoinSession |callback| with a unique request ID and | 241 // Associates a ReconnectPresentation |callback| with a unique request ID and |
| 248 // stores it in a map. | 242 // stores it in a map. |
| 249 // Returns a positive value on success. | 243 // Returns a positive value on success. |
| 250 int RegisterJoinSessionCallback(const NewSessionCallback& callback); | 244 int RegisterReconnectPresentationCallback( |
| 245 const NewPresentationCallback& callback); |
| 251 | 246 |
| 252 // Invoked by the embedder's PresentationServiceDelegate when a | 247 // Invoked by the embedder's PresentationServiceDelegate when a |
| 253 // PresentationConnection's state has changed. | 248 // PresentationConnection's state has changed. |
| 254 void OnConnectionStateChanged( | 249 void OnConnectionStateChanged( |
| 255 const PresentationSessionInfo& connection, | 250 const PresentationInfo& connection, |
| 256 const PresentationConnectionStateChangeInfo& info); | 251 const PresentationConnectionStateChangeInfo& info); |
| 257 | 252 |
| 258 // Returns true if this object is associated with |render_frame_host|. | 253 // Returns true if this object is associated with |render_frame_host|. |
| 259 bool FrameMatches(content::RenderFrameHost* render_frame_host) const; | 254 bool FrameMatches(content::RenderFrameHost* render_frame_host) const; |
| 260 | 255 |
| 261 // Returns |controller_delegate| if current frame is controller frame; Returns | 256 // Returns |controller_delegate| if current frame is controller frame; Returns |
| 262 // |receiver_delegate| if current frame is receiver frame. | 257 // |receiver_delegate| if current frame is receiver frame. |
| 263 PresentationServiceDelegate* GetPresentationServiceDelegate(); | 258 PresentationServiceDelegate* GetPresentationServiceDelegate(); |
| 264 | 259 |
| 265 // Embedder-specific delegate for controller to forward Presentation requests | 260 // Embedder-specific delegate for controller to forward Presentation requests |
| 266 // to. Must be nullptr if current page is receiver page or | 261 // to. Must be nullptr if current page is receiver page or |
| 267 // embedder does not support Presentation API . | 262 // embedder does not support Presentation API . |
| 268 ControllerPresentationServiceDelegate* controller_delegate_; | 263 ControllerPresentationServiceDelegate* controller_delegate_; |
| 269 | 264 |
| 270 // Embedder-specific delegate for receiver to forward Presentation requests | 265 // Embedder-specific delegate for receiver to forward Presentation requests |
| 271 // to. Must be nullptr if current page is receiver page or | 266 // to. Must be nullptr if current page is receiver page or |
| 272 // embedder does not support Presentation API. | 267 // embedder does not support Presentation API. |
| 273 ReceiverPresentationServiceDelegate* receiver_delegate_; | 268 ReceiverPresentationServiceDelegate* receiver_delegate_; |
| 274 | 269 |
| 275 // Proxy to the PresentationServiceClient to send results (e.g., screen | 270 // Proxy to the PresentationServiceClient to send results (e.g., screen |
| 276 // availability) to. | 271 // availability) to. |
| 277 blink::mojom::PresentationServiceClientPtr client_; | 272 blink::mojom::PresentationServiceClientPtr client_; |
| 278 | 273 |
| 279 std::vector<GURL> default_presentation_urls_; | 274 std::vector<GURL> default_presentation_urls_; |
| 280 | 275 |
| 281 using ScreenAvailabilityListenerMap = | 276 using ScreenAvailabilityListenerMap = |
| 282 std::map<GURL, std::unique_ptr<ScreenAvailabilityListenerImpl>>; | 277 std::map<GURL, std::unique_ptr<ScreenAvailabilityListenerImpl>>; |
| 283 ScreenAvailabilityListenerMap screen_availability_listeners_; | 278 ScreenAvailabilityListenerMap screen_availability_listeners_; |
| 284 | 279 |
| 285 // For StartSession requests. | 280 // For StartPresentation requests. |
| 286 // Set to a positive value when a StartSession request is being processed. | 281 // Set to a positive value when a StartPresentation request is being |
| 287 int start_session_request_id_; | 282 // processed. |
| 288 std::unique_ptr<NewSessionCallbackWrapper> pending_start_session_cb_; | 283 int start_presentation_request_id_; |
| 284 std::unique_ptr<NewPresentationCallbackWrapper> |
| 285 pending_start_presentation_cb_; |
| 289 | 286 |
| 290 // For JoinSession requests. | 287 // For ReconnectPresentation requests. |
| 291 base::hash_map<int, linked_ptr<NewSessionCallbackWrapper>> | 288 base::hash_map<int, linked_ptr<NewPresentationCallbackWrapper>> |
| 292 pending_join_session_cbs_; | 289 pending_reconnect_presentation_cbs_; |
| 293 | 290 |
| 294 // RAII binding of |this| to an Presentation interface request. | 291 // RAII binding of |this| to an Presentation interface request. |
| 295 // The binding is removed when binding_ is cleared or goes out of scope. | 292 // The binding is removed when binding_ is cleared or goes out of scope. |
| 296 std::unique_ptr<mojo::Binding<blink::mojom::PresentationService>> binding_; | 293 std::unique_ptr<mojo::Binding<blink::mojom::PresentationService>> binding_; |
| 297 | 294 |
| 298 // ID of the RenderFrameHost this object is associated with. | 295 // ID of the RenderFrameHost this object is associated with. |
| 299 int render_process_id_; | 296 int render_process_id_; |
| 300 int render_frame_id_; | 297 int render_frame_id_; |
| 301 | 298 |
| 302 // NOTE: Weak pointers must be invalidated before all other member variables. | 299 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 303 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 300 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
| 304 | 301 |
| 305 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 302 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
| 306 }; | 303 }; |
| 307 | 304 |
| 308 } // namespace content | 305 } // namespace content |
| 309 | 306 |
| 310 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 307 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
| OLD | NEW |