| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 base::Callback<void(mojo::Array<blink::mojom::SessionMessagePtr>)>; | 103 base::Callback<void(mojo::Array<blink::mojom::SessionMessagePtr>)>; |
| 104 using SendSessionMessageCallback = base::Callback<void(bool)>; | 104 using SendSessionMessageCallback = base::Callback<void(bool)>; |
| 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( | 113 ScreenAvailabilityListenerImpl(const GURL& availability_url, |
| 114 const std::string& availability_url, | 114 PresentationServiceImpl* service); |
| 115 PresentationServiceImpl* service); | |
| 116 ~ScreenAvailabilityListenerImpl() override; | 115 ~ScreenAvailabilityListenerImpl() override; |
| 117 | 116 |
| 118 // PresentationScreenAvailabilityListener implementation. | 117 // PresentationScreenAvailabilityListener implementation. |
| 119 std::string GetAvailabilityUrl() const override; | 118 GURL GetAvailabilityUrl() const override; |
| 120 void OnScreenAvailabilityChanged(bool available) override; | 119 void OnScreenAvailabilityChanged(bool available) override; |
| 121 void OnScreenAvailabilityNotSupported() override; | 120 void OnScreenAvailabilityNotSupported() override; |
| 122 | 121 |
| 123 private: | 122 private: |
| 124 const std::string availability_url_; | 123 const GURL availability_url_; |
| 125 PresentationServiceImpl* const service_; | 124 PresentationServiceImpl* const service_; |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 // Ensures the provided NewSessionCallback is invoked exactly once | 127 // Ensures the provided NewSessionCallback is invoked exactly once |
| 129 // before it goes out of scope. | 128 // before it goes out of scope. |
| 130 class NewSessionCallbackWrapper { | 129 class NewSessionCallbackWrapper { |
| 131 public: | 130 public: |
| 132 explicit NewSessionCallbackWrapper( | 131 explicit NewSessionCallbackWrapper( |
| 133 const NewSessionCallback& callback); | 132 const NewSessionCallback& callback); |
| 134 ~NewSessionCallbackWrapper(); | 133 ~NewSessionCallbackWrapper(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 bool FrameMatches(content::RenderFrameHost* render_frame_host) const; | 248 bool FrameMatches(content::RenderFrameHost* render_frame_host) const; |
| 250 | 249 |
| 251 // Embedder-specific delegate to forward Presentation requests to. | 250 // Embedder-specific delegate to forward Presentation requests to. |
| 252 // May be null if embedder does not support Presentation API. | 251 // May be null if embedder does not support Presentation API. |
| 253 PresentationServiceDelegate* delegate_; | 252 PresentationServiceDelegate* delegate_; |
| 254 | 253 |
| 255 // Proxy to the PresentationServiceClient to send results (e.g., screen | 254 // Proxy to the PresentationServiceClient to send results (e.g., screen |
| 256 // availability) to. | 255 // availability) to. |
| 257 blink::mojom::PresentationServiceClientPtr client_; | 256 blink::mojom::PresentationServiceClientPtr client_; |
| 258 | 257 |
| 259 std::vector<std::string> default_presentation_urls_; | 258 std::vector<GURL> default_presentation_urls_; |
| 260 | 259 |
| 261 using ScreenAvailabilityListenerMap = | 260 using ScreenAvailabilityListenerMap = |
| 262 std::map<std::string, std::unique_ptr<ScreenAvailabilityListenerImpl>>; | 261 std::map<GURL, std::unique_ptr<ScreenAvailabilityListenerImpl>>; |
| 263 ScreenAvailabilityListenerMap screen_availability_listeners_; | 262 ScreenAvailabilityListenerMap screen_availability_listeners_; |
| 264 | 263 |
| 265 // For StartSession requests. | 264 // For StartSession requests. |
| 266 // Set to a positive value when a StartSession request is being processed. | 265 // Set to a positive value when a StartSession request is being processed. |
| 267 int start_session_request_id_; | 266 int start_session_request_id_; |
| 268 std::unique_ptr<NewSessionCallbackWrapper> pending_start_session_cb_; | 267 std::unique_ptr<NewSessionCallbackWrapper> pending_start_session_cb_; |
| 269 | 268 |
| 270 // For JoinSession requests. | 269 // For JoinSession requests. |
| 271 base::hash_map<int, linked_ptr<NewSessionCallbackWrapper>> | 270 base::hash_map<int, linked_ptr<NewSessionCallbackWrapper>> |
| 272 pending_join_session_cbs_; | 271 pending_join_session_cbs_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 286 | 285 |
| 287 // NOTE: Weak pointers must be invalidated before all other member variables. | 286 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 288 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; | 287 base::WeakPtrFactory<PresentationServiceImpl> weak_factory_; |
| 289 | 288 |
| 290 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); | 289 DISALLOW_COPY_AND_ASSIGN(PresentationServiceImpl); |
| 291 }; | 290 }; |
| 292 | 291 |
| 293 } // namespace content | 292 } // namespace content |
| 294 | 293 |
| 295 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ | 294 #endif // CONTENT_BROWSER_PRESENTATION_PRESENTATION_SERVICE_IMPL_H_ |
| OLD | NEW |