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