| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> |
| 12 #include <queue> | 13 #include <queue> |
| 13 | 14 |
| 14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 15 #include "base/id_map.h" | 16 #include "base/id_map.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 17 #include "base/memory/scoped_ptr.h" | |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/common/presentation/presentation_service.mojom.h" | 19 #include "content/common/presentation/presentation_service.mojom.h" |
| 20 #include "content/public/renderer/render_frame_observer.h" | 20 #include "content/public/renderer/render_frame_observer.h" |
| 21 #include "mojo/public/cpp/bindings/binding.h" | 21 #include "mojo/public/cpp/bindings/binding.h" |
| 22 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nClient.h" | 22 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio
nClient.h" |
| 23 | 23 |
| 24 namespace blink { | 24 namespace blink { |
| 25 class WebPresentationAvailabilityObserver; | 25 class WebPresentationAvailabilityObserver; |
| 26 class WebString; | 26 class WebString; |
| 27 } // namespace blink | 27 } // namespace blink |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 void UpdateListeningState(); | 127 void UpdateListeningState(); |
| 128 | 128 |
| 129 // Used as a weak reference. Can be null since lifetime is bound to the frame. | 129 // Used as a weak reference. Can be null since lifetime is bound to the frame. |
| 130 blink::WebPresentationController* controller_; | 130 blink::WebPresentationController* controller_; |
| 131 mojom::PresentationServicePtr presentation_service_; | 131 mojom::PresentationServicePtr presentation_service_; |
| 132 mojo::Binding<mojom::PresentationServiceClient> binding_; | 132 mojo::Binding<mojom::PresentationServiceClient> binding_; |
| 133 | 133 |
| 134 // Message requests are queued here and only one message at a time is sent | 134 // Message requests are queued here and only one message at a time is sent |
| 135 // over mojo channel. | 135 // over mojo channel. |
| 136 using MessageRequestQueue = std::queue<scoped_ptr<SendMessageRequest>>; | 136 using MessageRequestQueue = std::queue<std::unique_ptr<SendMessageRequest>>; |
| 137 MessageRequestQueue message_request_queue_; | 137 MessageRequestQueue message_request_queue_; |
| 138 | 138 |
| 139 enum class ListeningState { | 139 enum class ListeningState { |
| 140 INACTIVE, | 140 INACTIVE, |
| 141 WAITING, | 141 WAITING, |
| 142 ACTIVE, | 142 ACTIVE, |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 using AvailabilityCallbacksMap = | 145 using AvailabilityCallbacksMap = |
| 146 IDMap<blink::WebPresentationAvailabilityCallbacks, IDMapOwnPointer>; | 146 IDMap<blink::WebPresentationAvailabilityCallbacks, IDMapOwnPointer>; |
| 147 using AvailabilityObserversSet = | 147 using AvailabilityObserversSet = |
| 148 std::set<blink::WebPresentationAvailabilityObserver*>; | 148 std::set<blink::WebPresentationAvailabilityObserver*>; |
| 149 | 149 |
| 150 // Tracks status of presentation displays availability for |availability_url|. | 150 // Tracks status of presentation displays availability for |availability_url|. |
| 151 struct AvailabilityStatus { | 151 struct AvailabilityStatus { |
| 152 explicit AvailabilityStatus(const std::string& availability_url); | 152 explicit AvailabilityStatus(const std::string& availability_url); |
| 153 ~AvailabilityStatus(); | 153 ~AvailabilityStatus(); |
| 154 | 154 |
| 155 const std::string url; | 155 const std::string url; |
| 156 bool last_known_availability; | 156 bool last_known_availability; |
| 157 ListeningState listening_state; | 157 ListeningState listening_state; |
| 158 AvailabilityCallbacksMap availability_callbacks; | 158 AvailabilityCallbacksMap availability_callbacks; |
| 159 AvailabilityObserversSet availability_observers; | 159 AvailabilityObserversSet availability_observers; |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 std::map<std::string, scoped_ptr<AvailabilityStatus>> availability_status_; | 162 std::map<std::string, std::unique_ptr<AvailabilityStatus>> |
| 163 availability_status_; |
| 163 | 164 |
| 164 // Updates the listening state of availability for |status| and notifies the | 165 // Updates the listening state of availability for |status| and notifies the |
| 165 // client. | 166 // client. |
| 166 void UpdateListeningState(AvailabilityStatus* status); | 167 void UpdateListeningState(AvailabilityStatus* status); |
| 167 | 168 |
| 168 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); | 169 DISALLOW_COPY_AND_ASSIGN(PresentationDispatcher); |
| 169 }; | 170 }; |
| 170 | 171 |
| 171 } // namespace content | 172 } // namespace content |
| 172 | 173 |
| 173 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ | 174 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_DISPATCHER_H_ |
| OLD | NEW |