| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 const base::Optional<PresentationError>&)>; | 58 const base::Optional<PresentationError>&)>; |
| 59 | 59 |
| 60 // Static factory method to create an instance of PresentationServiceImpl. | 60 // Static factory method to create an instance of PresentationServiceImpl. |
| 61 // |render_frame_host|: The RFH the instance is associated with. | 61 // |render_frame_host|: The RFH the instance is associated with. |
| 62 // |request|: The instance will be bound to this request. Used for Mojo setup. | 62 // |request|: The instance will be bound to this request. Used for Mojo setup. |
| 63 static void CreateMojoService( | 63 static void CreateMojoService( |
| 64 RenderFrameHost* render_frame_host, | 64 RenderFrameHost* render_frame_host, |
| 65 const service_manager::BindSourceInfo& source_info, | 65 const service_manager::BindSourceInfo& source_info, |
| 66 mojo::InterfaceRequest<blink::mojom::PresentationService> request); | 66 mojo::InterfaceRequest<blink::mojom::PresentationService> request); |
| 67 | 67 |
| 68 // PresentationService implementation. |
| 69 void SetDefaultPresentationUrls( |
| 70 const std::vector<GURL>& presentation_urls) override; |
| 71 void SetClient(blink::mojom::PresentationServiceClientPtr client) override; |
| 72 void ListenForScreenAvailability(const GURL& url) override; |
| 73 void StopListeningForScreenAvailability(const GURL& url) override; |
| 74 void StartPresentation(const std::vector<GURL>& presentation_urls, |
| 75 NewPresentationCallback callback) override; |
| 76 void ReconnectPresentation(const std::vector<GURL>& presentation_urls, |
| 77 const base::Optional<std::string>& presentation_id, |
| 78 NewPresentationCallback callback) override; |
| 79 void CloseConnection(const GURL& presentation_url, |
| 80 const std::string& presentation_id) override; |
| 81 void Terminate(const GURL& presentation_url, |
| 82 const std::string& presentation_id) override; |
| 83 void ListenForConnectionMessages( |
| 84 const PresentationInfo& presentation_info) override; |
| 85 void SetPresentationConnection( |
| 86 const PresentationInfo& presentation_info, |
| 87 blink::mojom::PresentationConnectionPtr controller_connection_ptr, |
| 88 blink::mojom::PresentationConnectionRequest receiver_connection_request) |
| 89 override; |
| 90 |
| 68 private: | 91 private: |
| 69 friend class PresentationServiceImplTest; | 92 friend class PresentationServiceImplTest; |
| 70 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, Reset); | 93 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, Reset); |
| 71 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, DidNavigateThisFrame); | |
| 72 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | |
| 73 DidNavigateOtherFrame); | |
| 74 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, ThisRenderFrameDeleted); | 94 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, ThisRenderFrameDeleted); |
| 75 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 95 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 76 OtherRenderFrameDeleted); | 96 OtherRenderFrameDeleted); |
| 77 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, DelegateFails); | 97 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, DelegateFails); |
| 78 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 98 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 79 SetDefaultPresentationUrls); | 99 ListenForConnectionStateChange); |
| 80 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 100 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 81 SetSameDefaultPresentationUrls); | 101 ListenForConnectionClose); |
| 82 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | |
| 83 ClearDefaultPresentationUrls); | |
| 84 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | |
| 85 ListenForDefaultPresentationStart); | |
| 86 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | |
| 87 ListenForDefaultPresentationStartAfterSet); | |
| 88 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | |
| 89 DefaultPresentationStartReset); | |
| 90 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | |
| 91 ReceiveConnectionMessagesAfterReset); | |
| 92 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 102 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 93 MaxPendingStartPresentationRequests); | 103 MaxPendingStartPresentationRequests); |
| 94 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 104 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 95 MaxPendingReconnectPresentationRequests); | 105 MaxPendingReconnectPresentationRequests); |
| 96 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | 106 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, |
| 97 ListenForConnectionStateChange); | |
| 98 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | |
| 99 ListenForConnectionClose); | |
| 100 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | |
| 101 SetPresentationConnection); | |
| 102 FRIEND_TEST_ALL_PREFIXES(PresentationServiceImplTest, | |
| 103 ReceiverPresentationServiceDelegate); | 107 ReceiverPresentationServiceDelegate); |
| 104 | 108 |
| 105 // Maximum number of pending ReconnectPresentation requests at any given time. | 109 // Maximum number of pending ReconnectPresentation requests at any given time. |
| 106 static const int kMaxQueuedRequests = 10; | 110 static const int kMaxQueuedRequests = 10; |
| 107 | 111 |
| 108 using ConnectionMessagesCallback = | 112 using ConnectionMessagesCallback = |
| 109 base::OnceCallback<void(std::vector<PresentationConnectionMessage>)>; | 113 base::OnceCallback<void(std::vector<PresentationConnectionMessage>)>; |
| 110 | 114 |
| 111 // Listener implementation owned by PresentationServiceImpl. An instance of | 115 // Listener implementation owned by PresentationServiceImpl. An instance of |
| 112 // this is created when PresentationRequest.getAvailability() is resolved. | 116 // this is created when PresentationRequest.getAvailability() is resolved. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 // owned by this class. | 156 // owned by this class. |
| 153 // |receiver_delegate|: Where Presentation API requests are delegated to in | 157 // |receiver_delegate|: Where Presentation API requests are delegated to in |
| 154 // receiver frame. Set to nullptr if current frame is controller frame. Not | 158 // receiver frame. Set to nullptr if current frame is controller frame. Not |
| 155 // owned by this class. | 159 // owned by this class. |
| 156 PresentationServiceImpl( | 160 PresentationServiceImpl( |
| 157 RenderFrameHost* render_frame_host, | 161 RenderFrameHost* render_frame_host, |
| 158 WebContents* web_contents, | 162 WebContents* web_contents, |
| 159 ControllerPresentationServiceDelegate* controller_delegate, | 163 ControllerPresentationServiceDelegate* controller_delegate, |
| 160 ReceiverPresentationServiceDelegate* receiver_delegate); | 164 ReceiverPresentationServiceDelegate* receiver_delegate); |
| 161 | 165 |
| 162 // PresentationService implementation. | |
| 163 void SetDefaultPresentationUrls( | |
| 164 const std::vector<GURL>& presentation_urls) override; | |
| 165 void SetClient(blink::mojom::PresentationServiceClientPtr client) override; | |
| 166 void ListenForScreenAvailability(const GURL& url) override; | |
| 167 void StopListeningForScreenAvailability(const GURL& url) override; | |
| 168 void StartPresentation(const std::vector<GURL>& presentation_urls, | |
| 169 NewPresentationCallback callback) override; | |
| 170 void ReconnectPresentation(const std::vector<GURL>& presentation_urls, | |
| 171 const base::Optional<std::string>& presentation_id, | |
| 172 NewPresentationCallback callback) override; | |
| 173 void CloseConnection(const GURL& presentation_url, | |
| 174 const std::string& presentation_id) override; | |
| 175 void Terminate(const GURL& presentation_url, | |
| 176 const std::string& presentation_id) override; | |
| 177 void ListenForConnectionMessages( | |
| 178 const PresentationInfo& presentation_info) override; | |
| 179 void SetPresentationConnection( | |
| 180 const PresentationInfo& presentation_info, | |
| 181 blink::mojom::PresentationConnectionPtr controller_connection_ptr, | |
| 182 blink::mojom::PresentationConnectionRequest receiver_connection_request) | |
| 183 override; | |
| 184 | |
| 185 // Creates a binding between this object and |request|. | 166 // Creates a binding between this object and |request|. |
| 186 void Bind(blink::mojom::PresentationServiceRequest request); | 167 void Bind(blink::mojom::PresentationServiceRequest request); |
| 187 | 168 |
| 188 // WebContentsObserver override. | 169 // WebContentsObserver override. |
| 189 void DidFinishNavigation(NavigationHandle* navigation_handle) override; | 170 void DidFinishNavigation(NavigationHandle* navigation_handle) override; |
| 190 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; | 171 void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; |
| 191 void WebContentsDestroyed() override; | 172 void WebContentsDestroyed() override; |
| 192 | 173 |
| 193 // PresentationServiceDelegate::Observer | 174 // PresentationServiceDelegate::Observer |
| 194 void OnDelegateDestroyed() override; | 175 void OnDelegateDestroyed() override; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 282 |
| 302 // NOTE: Weak pointers must be invalidated before all other member variables. | 283 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 303 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 284 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
| 304 | 285 |
| 305 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 286 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
| 306 }; | 287 }; |
| 307 | 288 |
| 308 } // namespace content | 289 } // namespace content |
| 309 | 290 |
| 310 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 291 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
| OLD | NEW |