| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 JoinSession requests at any given time. |
| 102 static const int kMaxNumQueuedSessionRequests = 10; | 102 static const int kMaxNumQueuedSessionRequests = 10; |
| 103 | 103 |
| 104 using ConnectionMessagesCallback = | 104 using ConnectionMessagesCallback = |
| 105 base::Callback<void(std::vector<blink::mojom::ConnectionMessagePtr>)>; | 105 base::Callback<void(std::vector<blink::mojom::ConnectionMessagePtr>)>; |
| 106 using SendConnectionMessageCallback = base::Callback<void(bool)>; | |
| 107 | 106 |
| 108 // Listener implementation owned by PresentationServiceImpl. An instance of | 107 // Listener implementation owned by PresentationServiceImpl. An instance of |
| 109 // this is created when PresentationRequest.getAvailability() is resolved. | 108 // this is created when PresentationRequest.getAvailability() is resolved. |
| 110 // The instance receives screen availability results from the embedder and | 109 // The instance receives screen availability results from the embedder and |
| 111 // propagates results back to PresentationServiceImpl. | 110 // propagates results back to PresentationServiceImpl. |
| 112 class CONTENT_EXPORT ScreenAvailabilityListenerImpl | 111 class CONTENT_EXPORT ScreenAvailabilityListenerImpl |
| 113 : public PresentationScreenAvailabilityListener { | 112 : public PresentationScreenAvailabilityListener { |
| 114 public: | 113 public: |
| 115 ScreenAvailabilityListenerImpl(const GURL& availability_url, | 114 ScreenAvailabilityListenerImpl(const GURL& availability_url, |
| 116 PresentationServiceImpl* service); | 115 PresentationServiceImpl* service); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 void SetDefaultPresentationUrls( | 160 void SetDefaultPresentationUrls( |
| 162 const std::vector<GURL>& presentation_urls) override; | 161 const std::vector<GURL>& presentation_urls) override; |
| 163 void SetClient(blink::mojom::PresentationServiceClientPtr client) override; | 162 void SetClient(blink::mojom::PresentationServiceClientPtr client) override; |
| 164 void ListenForScreenAvailability(const GURL& url) override; | 163 void ListenForScreenAvailability(const GURL& url) override; |
| 165 void StopListeningForScreenAvailability(const GURL& url) override; | 164 void StopListeningForScreenAvailability(const GURL& url) override; |
| 166 void StartSession(const std::vector<GURL>& presentation_urls, | 165 void StartSession(const std::vector<GURL>& presentation_urls, |
| 167 const NewSessionCallback& callback) override; | 166 const NewSessionCallback& callback) override; |
| 168 void JoinSession(const std::vector<GURL>& presentation_urls, | 167 void JoinSession(const std::vector<GURL>& presentation_urls, |
| 169 const base::Optional<std::string>& presentation_id, | 168 const base::Optional<std::string>& presentation_id, |
| 170 const NewSessionCallback& callback) override; | 169 const NewSessionCallback& callback) override; |
| 171 void SendConnectionMessage( | |
| 172 const PresentationSessionInfo& session_info, | |
| 173 blink::mojom::ConnectionMessagePtr connection_message, | |
| 174 const SendConnectionMessageCallback& callback) override; | |
| 175 void CloseConnection(const GURL& presentation_url, | 170 void CloseConnection(const GURL& presentation_url, |
| 176 const std::string& presentation_id) override; | 171 const std::string& presentation_id) override; |
| 177 void Terminate(const GURL& presentation_url, | 172 void Terminate(const GURL& presentation_url, |
| 178 const std::string& presentation_id) override; | 173 const std::string& presentation_id) override; |
| 179 void ListenForConnectionMessages( | 174 void ListenForConnectionMessages( |
| 180 const PresentationSessionInfo& session_info) override; | 175 const PresentationSessionInfo& session_info) override; |
| 181 void SetPresentationConnection( | 176 void SetPresentationConnection( |
| 182 const PresentationSessionInfo& session_info, | 177 const PresentationSessionInfo& session_info, |
| 183 blink::mojom::PresentationConnectionPtr controller_connection_ptr, | 178 blink::mojom::PresentationConnectionPtr controller_connection_ptr, |
| 184 blink::mojom::PresentationConnectionRequest receiver_connection_request) | 179 blink::mojom::PresentationConnectionRequest receiver_connection_request) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 const PresentationSessionInfo& session_info); | 217 const PresentationSessionInfo& session_info); |
| 223 void OnStartSessionError( | 218 void OnStartSessionError( |
| 224 int request_session_id, | 219 int request_session_id, |
| 225 const PresentationError& error); | 220 const PresentationError& error); |
| 226 void OnJoinSessionSucceeded( | 221 void OnJoinSessionSucceeded( |
| 227 int request_session_id, | 222 int request_session_id, |
| 228 const PresentationSessionInfo& session_info); | 223 const PresentationSessionInfo& session_info); |
| 229 void OnJoinSessionError( | 224 void OnJoinSessionError( |
| 230 int request_session_id, | 225 int request_session_id, |
| 231 const PresentationError& error); | 226 const PresentationError& error); |
| 232 void OnSendMessageCallback(bool sent); | |
| 233 | 227 |
| 234 // Calls to |delegate_| to start listening for state changes for |connection|. | 228 // Calls to |delegate_| to start listening for state changes for |connection|. |
| 235 // State changes will be returned via |OnConnectionStateChanged|. | 229 // State changes will be returned via |OnConnectionStateChanged|. |
| 236 void ListenForConnectionStateChange( | 230 void ListenForConnectionStateChange( |
| 237 const PresentationSessionInfo& connection); | 231 const PresentationSessionInfo& connection); |
| 238 | 232 |
| 239 // Passed to embedder's implementation of PresentationServiceDelegate for | 233 // Passed to embedder's implementation of PresentationServiceDelegate for |
| 240 // later invocation when session messages arrive. | 234 // later invocation when session messages arrive. |
| 241 void OnConnectionMessages( | 235 void OnConnectionMessages( |
| 242 const content::PresentationSessionInfo& session_info, | 236 const content::PresentationSessionInfo& session_info, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 std::unique_ptr<NewSessionCallbackWrapper> pending_start_session_cb_; | 290 std::unique_ptr<NewSessionCallbackWrapper> pending_start_session_cb_; |
| 297 | 291 |
| 298 // For JoinSession requests. | 292 // For JoinSession requests. |
| 299 base::hash_map<int, linked_ptr<NewSessionCallbackWrapper>> | 293 base::hash_map<int, linked_ptr<NewSessionCallbackWrapper>> |
| 300 pending_join_session_cbs_; | 294 pending_join_session_cbs_; |
| 301 | 295 |
| 302 // RAII binding of |this| to an Presentation interface request. | 296 // RAII binding of |this| to an Presentation interface request. |
| 303 // The binding is removed when binding_ is cleared or goes out of scope. | 297 // The binding is removed when binding_ is cleared or goes out of scope. |
| 304 std::unique_ptr<mojo::Binding<blink::mojom::PresentationService>> binding_; | 298 std::unique_ptr<mojo::Binding<blink::mojom::PresentationService>> binding_; |
| 305 | 299 |
| 306 // There can be only one send message request at a time. | |
| 307 std::unique_ptr<SendConnectionMessageCallback> send_message_callback_; | |
| 308 | |
| 309 std::unique_ptr<ConnectionMessagesCallback> on_connection_messages_callback_; | |
| 310 | |
| 311 // ID of the RenderFrameHost this object is associated with. | 300 // ID of the RenderFrameHost this object is associated with. |
| 312 int render_process_id_; | 301 int render_process_id_; |
| 313 int render_frame_id_; | 302 int render_frame_id_; |
| 314 | 303 |
| 315 // NOTE: Weak pointers must be invalidated before all other member variables. | 304 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 316 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 305 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
| 317 | 306 |
| 318 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 307 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
| 319 }; | 308 }; |
| 320 | 309 |
| 321 } // namespace content | 310 } // namespace content |
| 322 | 311 |
| 323 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 312 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
| OLD | NEW |