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_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 5 #ifndef CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ |
6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 presentation::PresentationSessionState session_state); | 86 presentation::PresentationSessionState session_state); |
87 void OnSessionMessagesReceived( | 87 void OnSessionMessagesReceived( |
88 mojo::Array<presentation::SessionMessagePtr> messages); | 88 mojo::Array<presentation::SessionMessagePtr> messages); |
89 void DoSendMessage(const presentation::SessionMessage& session_message); | 89 void DoSendMessage(const presentation::SessionMessage& session_message); |
90 void HandleSendMessageRequests(bool success); | 90 void HandleSendMessageRequests(bool success); |
91 | 91 |
92 void ConnectToPresentationServiceIfNeeded(); | 92 void ConnectToPresentationServiceIfNeeded(); |
93 | 93 |
94 void UpdateListeningState(); | 94 void UpdateListeningState(); |
95 | 95 |
| 96 void StartListenForMessages(); |
| 97 |
96 // Used as a weak reference. Can be null since lifetime is bound to the frame. | 98 // Used as a weak reference. Can be null since lifetime is bound to the frame. |
97 blink::WebPresentationController* controller_; | 99 blink::WebPresentationController* controller_; |
98 presentation::PresentationServicePtr presentation_service_; | 100 presentation::PresentationServicePtr presentation_service_; |
99 mojo::Binding<presentation::PresentationServiceClient> binding_; | 101 mojo::Binding<presentation::PresentationServiceClient> binding_; |
100 | 102 |
101 // Message requests are queued here and only one message at a time is sent | 103 // Message requests are queued here and only one message at a time is sent |
102 // over mojo channel. | 104 // over mojo channel. |
103 using MessageRequestQueue = | 105 using MessageRequestQueue = |
104 std::queue<linked_ptr<presentation::SessionMessage>>; | 106 std::queue<linked_ptr<presentation::SessionMessage>>; |
105 MessageRequestQueue message_request_queue_; | 107 MessageRequestQueue message_request_queue_; |
106 | 108 |
107 enum class ListeningState { | 109 enum class ListeningState { |
108 Inactive, | 110 Inactive, |
109 Waiting, | 111 Waiting, |
110 Active, | 112 Active, |
111 }; | 113 }; |
112 | 114 |
113 ListeningState listening_state_; | 115 ListeningState listening_state_; |
114 bool last_known_availability_; | 116 bool last_known_availability_; |
115 | 117 |
116 using AvailabilityCallbacksMap = | 118 using AvailabilityCallbacksMap = |
117 IDMap<blink::WebPresentationAvailabilityCallbacks, IDMapOwnPointer>; | 119 IDMap<blink::WebPresentationAvailabilityCallbacks, IDMapOwnPointer>; |
118 AvailabilityCallbacksMap availability_callbacks_; | 120 AvailabilityCallbacksMap availability_callbacks_; |
119 | 121 |
120 using AvailabilityObserversSet = | 122 using AvailabilityObserversSet = |
121 std::set<blink::WebPresentationAvailabilityObserver*>; | 123 std::set<blink::WebPresentationAvailabilityObserver*>; |
122 AvailabilityObserversSet availability_observers_; | 124 AvailabilityObserversSet availability_observers_; |
123 | 125 |
| 126 bool listening_for_messages_; |
| 127 |
124 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); | 128 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); |
125 }; | 129 }; |
126 | 130 |
127 } // namespace content | 131 } // namespace content |
128 | 132 |
129 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 133 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ |
OLD | NEW |