OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/browser/media/router/offscreen_presentation_manager.h" | 5 #include "chrome/browser/media/router/offscreen_presentation_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 OffscreenPresentationManager::OffscreenPresentation::~OffscreenPresentation() {} | 114 OffscreenPresentationManager::OffscreenPresentation::~OffscreenPresentation() {} |
115 | 115 |
116 void OffscreenPresentationManager::OffscreenPresentation::RegisterController( | 116 void OffscreenPresentationManager::OffscreenPresentation::RegisterController( |
117 const RenderFrameHostId& render_frame_host_id, | 117 const RenderFrameHostId& render_frame_host_id, |
118 content::PresentationConnectionPtr controller_connection_ptr, | 118 content::PresentationConnectionPtr controller_connection_ptr, |
119 content::PresentationConnectionRequest receiver_connection_request, | 119 content::PresentationConnectionRequest receiver_connection_request, |
120 const MediaRoute& route) { | 120 const MediaRoute& route) { |
121 if (!receiver_callback_.is_null()) { | 121 if (!receiver_callback_.is_null()) { |
122 receiver_callback_.Run( | 122 receiver_callback_.Run( |
123 content::PresentationSessionInfo(presentation_url_, presentation_id_), | 123 content::PresentationInfo(presentation_url_, presentation_id_), |
124 std::move(controller_connection_ptr), | 124 std::move(controller_connection_ptr), |
125 std::move(receiver_connection_request)); | 125 std::move(receiver_connection_request)); |
126 } else { | 126 } else { |
127 pending_controllers_.insert(std::make_pair( | 127 pending_controllers_.insert(std::make_pair( |
128 render_frame_host_id, base::MakeUnique<ControllerConnection>( | 128 render_frame_host_id, base::MakeUnique<ControllerConnection>( |
129 std::move(controller_connection_ptr), | 129 std::move(controller_connection_ptr), |
130 std::move(receiver_connection_request)))); | 130 std::move(receiver_connection_request)))); |
131 } | 131 } |
132 | 132 |
133 route_ = route; | 133 route_ = route; |
134 } | 134 } |
135 | 135 |
136 void OffscreenPresentationManager::OffscreenPresentation::UnregisterController( | 136 void OffscreenPresentationManager::OffscreenPresentation::UnregisterController( |
137 const RenderFrameHostId& render_frame_host_id) { | 137 const RenderFrameHostId& render_frame_host_id) { |
138 pending_controllers_.erase(render_frame_host_id); | 138 pending_controllers_.erase(render_frame_host_id); |
139 } | 139 } |
140 | 140 |
141 void OffscreenPresentationManager::OffscreenPresentation::RegisterReceiver( | 141 void OffscreenPresentationManager::OffscreenPresentation::RegisterReceiver( |
142 const content::ReceiverConnectionAvailableCallback& receiver_callback) { | 142 const content::ReceiverConnectionAvailableCallback& receiver_callback) { |
143 DCHECK(receiver_callback_.is_null()); | 143 DCHECK(receiver_callback_.is_null()); |
144 | 144 |
145 for (auto& controller : pending_controllers_) { | 145 for (auto& controller : pending_controllers_) { |
146 receiver_callback.Run( | 146 receiver_callback.Run( |
147 content::PresentationSessionInfo(presentation_url_, presentation_id_), | 147 content::PresentationInfo(presentation_url_, presentation_id_), |
148 std::move(controller.second->controller_connection_ptr), | 148 std::move(controller.second->controller_connection_ptr), |
149 std::move(controller.second->receiver_connection_request)); | 149 std::move(controller.second->receiver_connection_request)); |
150 } | 150 } |
151 receiver_callback_ = receiver_callback; | 151 receiver_callback_ = receiver_callback; |
152 pending_controllers_.clear(); | 152 pending_controllers_.clear(); |
153 } | 153 } |
154 | 154 |
155 bool OffscreenPresentationManager::OffscreenPresentation::IsValid() const { | 155 bool OffscreenPresentationManager::OffscreenPresentation::IsValid() const { |
156 return !(pending_controllers_.empty() && receiver_callback_.is_null()); | 156 return !(pending_controllers_.empty() && receiver_callback_.is_null()); |
157 } | 157 } |
158 | 158 |
159 OffscreenPresentationManager::OffscreenPresentation::ControllerConnection:: | 159 OffscreenPresentationManager::OffscreenPresentation::ControllerConnection:: |
160 ControllerConnection( | 160 ControllerConnection( |
161 content::PresentationConnectionPtr controller_connection_ptr, | 161 content::PresentationConnectionPtr controller_connection_ptr, |
162 content::PresentationConnectionRequest receiver_connection_request) | 162 content::PresentationConnectionRequest receiver_connection_request) |
163 : controller_connection_ptr(std::move(controller_connection_ptr)), | 163 : controller_connection_ptr(std::move(controller_connection_ptr)), |
164 receiver_connection_request(std::move(receiver_connection_request)) {} | 164 receiver_connection_request(std::move(receiver_connection_request)) {} |
165 | 165 |
166 OffscreenPresentationManager::OffscreenPresentation::ControllerConnection:: | 166 OffscreenPresentationManager::OffscreenPresentation::ControllerConnection:: |
167 ~ControllerConnection() {} | 167 ~ControllerConnection() {} |
168 | 168 |
169 } // namespace media_router | 169 } // namespace media_router |
OLD | NEW |