Chromium Code Reviews| Index: content/renderer/presentation/presentation_dispatcher.h |
| diff --git a/content/renderer/presentation/presentation_dispatcher.h b/content/renderer/presentation/presentation_dispatcher.h |
| index 0693f1363f1731366f0e61ec02b49fc63746b415..beac99f55c070d71db4aba6d42e1abff33697fec 100644 |
| --- a/content/renderer/presentation/presentation_dispatcher.h |
| +++ b/content/renderer/presentation/presentation_dispatcher.h |
| @@ -47,6 +47,7 @@ class CONTENT_EXPORT PresentationDispatcher |
| ~PresentationDispatcher() override; |
| private: |
| + friend class PresentationDispatcherTest; |
| struct SendMessageRequest { |
| SendMessageRequest(blink::mojom::PresentationSessionInfoPtr session_info, |
| blink::mojom::ConnectionMessagePtr message); |
| @@ -140,6 +141,8 @@ class CONTENT_EXPORT PresentationDispatcher |
| void HandleSendMessageRequests(bool success); |
| void ConnectToPresentationServiceIfNeeded(); |
| + void SetPresentationServiceForTest( |
| + blink::mojom::PresentationServicePtr presentation_service); |
| void UpdateListeningState(); |
| @@ -160,6 +163,13 @@ class CONTENT_EXPORT PresentationDispatcher |
| ACTIVE, |
| }; |
| + enum class ScreenAvailability { |
| + UNKNOWN, |
| + AVAILABLE, |
| + UNAVAILABLE, |
| + UNSUPPORTED |
|
mark a. foltz
2016/12/23 01:04:22
I don't recall exactly why we have an API in the d
zhaobin
2016/12/29 18:48:38
Done.
|
| + }; |
| + |
| using AvailabilityCallbacksMap = |
| IDMap<std::unique_ptr<blink::WebPresentationAvailabilityCallbacks>>; |
| using AvailabilityObserversSet = |
| @@ -167,24 +177,46 @@ class CONTENT_EXPORT PresentationDispatcher |
| // Tracks status of presentation displays availability for |availability_url|. |
| struct AvailabilityStatus { |
| - explicit AvailabilityStatus(const GURL& availability_url); |
| + explicit AvailabilityStatus(const std::vector<GURL>& availability_urls); |
| ~AvailabilityStatus(); |
| - const GURL url; |
| - bool last_known_availability; |
| - ListeningState listening_state; |
| + const std::vector<GURL> urls; |
| AvailabilityCallbacksMap availability_callbacks; |
| AvailabilityObserversSet availability_observers; |
| }; |
| // Map of AvailabilityStatus for known URLs. |
| - std::map<GURL, std::unique_ptr<AvailabilityStatus>> |
| + std::map<std::vector<GURL>, std::unique_ptr<AvailabilityStatus>> |
|
mark a. foltz
2016/12/23 01:04:22
Is it okay to use a container as a map key?
I us
zhaobin
2016/12/29 18:48:38
Code removed.
|
| availability_status_; |
| + // Map of ScreenAvailability for known URL. |
| + std::map<GURL, ScreenAvailability> screen_availability_; |
| + |
| + // Map of ListeningState for known URL. |
| + std::map<GURL, ListeningState> url_listening_state_; |
|
mark a. foltz
2016/12/23 01:04:22
Can we combine these with AvailabilityStatus?
zhaobin
2016/12/29 18:48:38
Code removed.
|
| + |
| // Updates the listening state of availability for |status| and notifies the |
| // client. |
| void UpdateListeningState(AvailabilityStatus* status); |
| + // Called when all urls in |status| reports ScreenAvailability::UNSUPPORTED. |
| + void OnScreenAvailabilityNotSupported(AvailabilityStatus* status); |
| + |
| + // Called when all urls in |status| reports their screen availability. |
| + void OnScreenAvailabilityUpdated(AvailabilityStatus* status, bool available); |
| + |
| + void OnScreenAvailabilityUpdated(const GURL& url, ScreenAvailability); |
| + |
| + // Returns UNKNOWN if any url in |urls| has screen availability UNKNOWN. |
| + // Returns AVAILABLE if at least one url in |urls| has screen availability |
| + // AVAILABLE, and no url has screen availability UNKNOWN; |
| + // Returns UNAVAILABLE is at least one url in |urls| has screen availability |
| + // UNAVAILABLE, and no url has screen availability UNKNOWN or AVAILABLE; |
| + // Returns UNSUPPORTED if all urls in |urls| have screen availability |
| + // UNSUPPORTED. |
| + PresentationDispatcher::ScreenAvailability GetRequestAvailability( |
| + const std::vector<GURL>& urls); |
| + |
| DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); |
| }; |