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 #include "content/browser/presentation/presentation_service_impl.h" | 5 #include "content/browser/presentation/presentation_service_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "content/public/browser/content_browser_client.h" | 14 #include "content/public/browser/content_browser_client.h" |
15 #include "content/public/browser/navigation_handle.h" | 15 #include "content/public/browser/navigation_handle.h" |
16 #include "content/public/browser/render_frame_host.h" | 16 #include "content/public/browser/render_frame_host.h" |
17 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
19 #include "content/public/common/content_client.h" | 19 #include "content/public/common/content_client.h" |
20 #include "content/public/common/frame_navigate_params.h" | 20 #include "content/public/common/frame_navigate_params.h" |
21 #include "content/public/common/presentation_connection_message.h" | 21 #include "content/public/common/presentation_connection_message.h" |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 const int kInvalidRequestSessionId = -1; | 27 const int kInvalidRequestId = -1; |
28 | 28 |
29 int GetNextRequestSessionId() { | 29 int GetNextRequestId() { |
30 static int next_request_session_id = 0; | 30 static int next_request_id = 0; |
31 return ++next_request_session_id; | 31 return ++next_request_id; |
32 } | 32 } |
33 | 33 |
34 void InvokeNewSessionCallbackWithError( | 34 void InvokeNewPresentationCallbackWithError( |
35 const PresentationServiceImpl::NewSessionCallback& callback) { | 35 const PresentationServiceImpl::NewPresentationCallback& callback) { |
36 callback.Run(base::nullopt, | 36 callback.Run(base::nullopt, |
37 PresentationError( | 37 PresentationError( |
38 PRESENTATION_ERROR_PREVIOUS_START_IN_PROGRESS, | 38 PRESENTATION_ERROR_PREVIOUS_START_IN_PROGRESS, |
39 "There is already an unsettled Promise from a previous call " | 39 "There is already an unsettled Promise from a previous call " |
40 "to start.")); | 40 "to start.")); |
41 } | 41 } |
42 | 42 |
43 } // namespace | 43 } // namespace |
44 | 44 |
45 PresentationServiceImpl::PresentationServiceImpl( | 45 PresentationServiceImpl::PresentationServiceImpl( |
46 RenderFrameHost* render_frame_host, | 46 RenderFrameHost* render_frame_host, |
47 WebContents* web_contents, | 47 WebContents* web_contents, |
48 ControllerPresentationServiceDelegate* controller_delegate, | 48 ControllerPresentationServiceDelegate* controller_delegate, |
49 ReceiverPresentationServiceDelegate* receiver_delegate) | 49 ReceiverPresentationServiceDelegate* receiver_delegate) |
50 : WebContentsObserver(web_contents), | 50 : WebContentsObserver(web_contents), |
51 controller_delegate_(controller_delegate), | 51 controller_delegate_(controller_delegate), |
52 receiver_delegate_(receiver_delegate), | 52 receiver_delegate_(receiver_delegate), |
53 start_session_request_id_(kInvalidRequestSessionId), | 53 start_presentation_request_id_(kInvalidRequestId), |
54 weak_factory_(this) { | 54 weak_factory_(this) { |
55 DCHECK(render_frame_host); | 55 DCHECK(render_frame_host); |
56 DCHECK(web_contents); | 56 DCHECK(web_contents); |
57 CHECK(render_frame_host->IsRenderFrameLive()); | 57 CHECK(render_frame_host->IsRenderFrameLive()); |
58 | 58 |
59 render_process_id_ = render_frame_host->GetProcess()->GetID(); | 59 render_process_id_ = render_frame_host->GetProcess()->GetID(); |
60 render_frame_id_ = render_frame_host->GetRoutingID(); | 60 render_frame_id_ = render_frame_host->GetRoutingID(); |
61 DVLOG(2) << "PresentationServiceImpl: " | 61 DVLOG(2) << "PresentationServiceImpl: " |
62 << render_process_id_ << ", " << render_frame_id_; | 62 << render_process_id_ << ", " << render_frame_id_; |
63 | 63 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 | 147 |
148 auto listener_it = screen_availability_listeners_.find(url); | 148 auto listener_it = screen_availability_listeners_.find(url); |
149 if (listener_it == screen_availability_listeners_.end()) | 149 if (listener_it == screen_availability_listeners_.end()) |
150 return; | 150 return; |
151 | 151 |
152 controller_delegate_->RemoveScreenAvailabilityListener( | 152 controller_delegate_->RemoveScreenAvailabilityListener( |
153 render_process_id_, render_frame_id_, listener_it->second.get()); | 153 render_process_id_, render_frame_id_, listener_it->second.get()); |
154 screen_availability_listeners_.erase(listener_it); | 154 screen_availability_listeners_.erase(listener_it); |
155 } | 155 } |
156 | 156 |
157 void PresentationServiceImpl::StartSession( | 157 void PresentationServiceImpl::StartPresentation( |
158 const std::vector<GURL>& presentation_urls, | 158 const std::vector<GURL>& presentation_urls, |
159 const NewSessionCallback& callback) { | 159 const NewPresentationCallback& callback) { |
160 DVLOG(2) << "StartSession"; | 160 DVLOG(2) << "StartPresentation"; |
161 if (!controller_delegate_) { | 161 if (!controller_delegate_) { |
162 callback.Run(base::nullopt, | 162 callback.Run(base::nullopt, |
163 PresentationError(PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, | 163 PresentationError(PRESENTATION_ERROR_NO_AVAILABLE_SCREENS, |
164 "No screens found.")); | 164 "No screens found.")); |
165 return; | 165 return; |
166 } | 166 } |
167 | 167 |
168 // There is a StartSession request in progress. To avoid queueing up | 168 // There is a StartPresentation request in progress. To avoid queueing up |
169 // requests, the incoming request is rejected. | 169 // requests, the incoming request is rejected. |
170 if (start_session_request_id_ != kInvalidRequestSessionId) { | 170 if (start_presentation_request_id_ != kInvalidRequestId) { |
171 InvokeNewSessionCallbackWithError(callback); | 171 InvokeNewPresentationCallbackWithError(callback); |
172 return; | 172 return; |
173 } | 173 } |
174 | 174 |
175 start_session_request_id_ = GetNextRequestSessionId(); | 175 start_presentation_request_id_ = GetNextRequestId(); |
176 pending_start_session_cb_.reset(new NewSessionCallbackWrapper(callback)); | 176 pending_start_presentation_cb_.reset( |
177 controller_delegate_->StartSession( | 177 new NewPresentationCallbackWrapper(callback)); |
178 controller_delegate_->StartPresentation( | |
178 render_process_id_, render_frame_id_, presentation_urls, | 179 render_process_id_, render_frame_id_, presentation_urls, |
179 base::Bind(&PresentationServiceImpl::OnStartSessionSucceeded, | 180 base::Bind(&PresentationServiceImpl::OnStartPresentationSucceeded, |
180 weak_factory_.GetWeakPtr(), start_session_request_id_), | 181 weak_factory_.GetWeakPtr(), start_presentation_request_id_), |
181 base::Bind(&PresentationServiceImpl::OnStartSessionError, | 182 base::Bind(&PresentationServiceImpl::OnStartPresentationError, |
182 weak_factory_.GetWeakPtr(), start_session_request_id_)); | 183 weak_factory_.GetWeakPtr(), start_presentation_request_id_)); |
183 } | 184 } |
184 | 185 |
185 void PresentationServiceImpl::JoinSession( | 186 void PresentationServiceImpl::ReconnectPresentation( |
186 const std::vector<GURL>& presentation_urls, | 187 const std::vector<GURL>& presentation_urls, |
187 const base::Optional<std::string>& presentation_id, | 188 const base::Optional<std::string>& presentation_id, |
188 const NewSessionCallback& callback) { | 189 const NewPresentationCallback& callback) { |
189 DVLOG(2) << "JoinSession"; | 190 DVLOG(2) << "ReconnectPresentation"; |
190 if (!controller_delegate_) { | 191 if (!controller_delegate_) { |
191 callback.Run(base::nullopt, | 192 callback.Run(base::nullopt, |
192 PresentationError(PRESENTATION_ERROR_NO_PRESENTATION_FOUND, | 193 PresentationError(PRESENTATION_ERROR_NO_PRESENTATION_FOUND, |
193 "Error joining route: No matching route")); | 194 "Error joining route: No matching route")); |
194 return; | 195 return; |
195 } | 196 } |
196 | 197 |
197 int request_session_id = RegisterJoinSessionCallback(callback); | 198 int request_id = RegisterReconnectPresentationCallback(callback); |
198 if (request_session_id == kInvalidRequestSessionId) { | 199 if (request_id == kInvalidRequestId) { |
199 InvokeNewSessionCallbackWithError(callback); | 200 InvokeNewPresentationCallbackWithError(callback); |
200 return; | 201 return; |
201 } | 202 } |
202 controller_delegate_->JoinSession( | 203 controller_delegate_->ReconnectPresentation( |
203 render_process_id_, render_frame_id_, presentation_urls, | 204 render_process_id_, render_frame_id_, presentation_urls, |
204 presentation_id.value_or(std::string()), | 205 presentation_id.value_or(std::string()), |
205 base::Bind(&PresentationServiceImpl::OnJoinSessionSucceeded, | 206 base::Bind(&PresentationServiceImpl::OnReconnectPresentationSucceeded, |
206 weak_factory_.GetWeakPtr(), request_session_id), | 207 weak_factory_.GetWeakPtr(), request_id), |
207 base::Bind(&PresentationServiceImpl::OnJoinSessionError, | 208 base::Bind(&PresentationServiceImpl::OnReconnectPresentationError, |
208 weak_factory_.GetWeakPtr(), request_session_id)); | 209 weak_factory_.GetWeakPtr(), request_id)); |
209 } | 210 } |
210 | 211 |
211 int PresentationServiceImpl::RegisterJoinSessionCallback( | 212 int PresentationServiceImpl::RegisterReconnectPresentationCallback( |
212 const NewSessionCallback& callback) { | 213 const NewPresentationCallback& callback) { |
213 if (pending_join_session_cbs_.size() >= kMaxNumQueuedSessionRequests) | 214 if (pending_reconnect_presentation_cbs_.size() >= kMaxQueuedRequests) |
214 return kInvalidRequestSessionId; | 215 return kInvalidRequestId; |
215 | 216 |
216 int request_id = GetNextRequestSessionId(); | 217 int request_id = GetNextRequestId(); |
217 pending_join_session_cbs_[request_id].reset( | 218 pending_reconnect_presentation_cbs_[request_id].reset( |
218 new NewSessionCallbackWrapper(callback)); | 219 new NewPresentationCallbackWrapper(callback)); |
219 return request_id; | 220 return request_id; |
220 } | 221 } |
221 | 222 |
222 void PresentationServiceImpl::ListenForConnectionStateChange( | 223 void PresentationServiceImpl::ListenForConnectionStateChange( |
223 const PresentationSessionInfo& connection) { | 224 const PresentationInfo& connection) { |
224 // NOTE: Blink will automatically transition the connection's state to | 225 // NOTE: Blink will automatically transition the connection's state to |
225 // 'connected'. | 226 // 'connected'. |
226 if (controller_delegate_) { | 227 if (controller_delegate_) { |
227 controller_delegate_->ListenForConnectionStateChange( | 228 controller_delegate_->ListenForConnectionStateChange( |
228 render_process_id_, render_frame_id_, connection, | 229 render_process_id_, render_frame_id_, connection, |
229 base::Bind(&PresentationServiceImpl::OnConnectionStateChanged, | 230 base::Bind(&PresentationServiceImpl::OnConnectionStateChanged, |
230 weak_factory_.GetWeakPtr(), connection)); | 231 weak_factory_.GetWeakPtr(), connection)); |
231 } | 232 } |
232 } | 233 } |
233 | 234 |
234 void PresentationServiceImpl::OnStartSessionSucceeded( | 235 void PresentationServiceImpl::OnStartPresentationSucceeded( |
235 int request_session_id, | 236 int request_id, |
236 const PresentationSessionInfo& session_info) { | 237 const PresentationInfo& presentation_info) { |
237 if (request_session_id != start_session_request_id_) | 238 if (request_id != start_presentation_request_id_) |
238 return; | 239 return; |
239 | 240 |
240 CHECK(pending_start_session_cb_.get()); | 241 CHECK(pending_start_presentation_cb_.get()); |
241 pending_start_session_cb_->Run(session_info, base::nullopt); | 242 pending_start_presentation_cb_->Run(presentation_info, base::nullopt); |
242 ListenForConnectionStateChange(session_info); | 243 ListenForConnectionStateChange(presentation_info); |
243 pending_start_session_cb_.reset(); | 244 pending_start_presentation_cb_.reset(); |
244 start_session_request_id_ = kInvalidRequestSessionId; | 245 start_presentation_request_id_ = kInvalidRequestId; |
245 } | 246 } |
246 | 247 |
247 void PresentationServiceImpl::OnStartSessionError( | 248 void PresentationServiceImpl::OnStartPresentationError( |
248 int request_session_id, | 249 int request_id, |
249 const PresentationError& error) { | 250 const PresentationError& error) { |
250 if (request_session_id != start_session_request_id_) | 251 if (request_id != start_presentation_request_id_) |
251 return; | 252 return; |
252 | 253 |
253 CHECK(pending_start_session_cb_.get()); | 254 CHECK(pending_start_presentation_cb_.get()); |
254 pending_start_session_cb_->Run(base::nullopt, error); | 255 pending_start_presentation_cb_->Run(base::nullopt, error); |
255 pending_start_session_cb_.reset(); | 256 pending_start_presentation_cb_.reset(); |
256 start_session_request_id_ = kInvalidRequestSessionId; | 257 start_presentation_request_id_ = kInvalidRequestId; |
257 } | 258 } |
258 | 259 |
259 void PresentationServiceImpl::OnJoinSessionSucceeded( | 260 void PresentationServiceImpl::OnReconnectPresentationSucceeded( |
260 int request_session_id, | 261 int request_id, |
261 const PresentationSessionInfo& session_info) { | 262 const PresentationInfo& presentation_info) { |
262 if (RunAndEraseJoinSessionMojoCallback(request_session_id, session_info, | 263 if (RunAndEraseReconnectPresentationMojoCallback( |
263 base::nullopt)) { | 264 request_id, presentation_info, base::nullopt)) { |
264 ListenForConnectionStateChange(session_info); | 265 ListenForConnectionStateChange(presentation_info); |
265 } | 266 } |
266 } | 267 } |
267 | 268 |
268 void PresentationServiceImpl::OnJoinSessionError( | 269 void PresentationServiceImpl::OnReconnectPresentationError( |
269 int request_session_id, | 270 int request_id, |
270 const PresentationError& error) { | 271 const PresentationError& error) { |
271 RunAndEraseJoinSessionMojoCallback(request_session_id, base::nullopt, error); | 272 RunAndEraseReconnectPresentationMojoCallback(request_id, base::nullopt, |
273 error); | |
272 } | 274 } |
273 | 275 |
274 bool PresentationServiceImpl::RunAndEraseJoinSessionMojoCallback( | 276 bool PresentationServiceImpl::RunAndEraseReconnectPresentationMojoCallback( |
275 int request_session_id, | 277 int request_id, |
276 const base::Optional<PresentationSessionInfo>& session_info, | 278 const base::Optional<PresentationInfo>& presentation_info, |
277 const base::Optional<PresentationError>& error) { | 279 const base::Optional<PresentationError>& error) { |
278 auto it = pending_join_session_cbs_.find(request_session_id); | 280 auto it = pending_reconnect_presentation_cbs_.find(request_id); |
279 if (it == pending_join_session_cbs_.end()) | 281 if (it == pending_reconnect_presentation_cbs_.end()) |
280 return false; | 282 return false; |
281 | 283 |
282 DCHECK(it->second.get()); | 284 DCHECK(it->second.get()); |
283 it->second->Run(session_info, error); | 285 it->second->Run(presentation_info, error); |
284 pending_join_session_cbs_.erase(it); | 286 pending_reconnect_presentation_cbs_.erase(it); |
285 return true; | 287 return true; |
286 } | 288 } |
287 | 289 |
288 void PresentationServiceImpl::SetDefaultPresentationUrls( | 290 void PresentationServiceImpl::SetDefaultPresentationUrls( |
289 const std::vector<GURL>& presentation_urls) { | 291 const std::vector<GURL>& presentation_urls) { |
290 DVLOG(2) << "SetDefaultPresentationUrls"; | 292 DVLOG(2) << "SetDefaultPresentationUrls"; |
291 if (!controller_delegate_) | 293 if (!controller_delegate_) |
292 return; | 294 return; |
293 | 295 |
294 if (default_presentation_urls_ == presentation_urls) | 296 if (default_presentation_urls_ == presentation_urls) |
(...skipping 17 matching lines...) Expand all Loading... | |
312 | 314 |
313 void PresentationServiceImpl::Terminate(const GURL& presentation_url, | 315 void PresentationServiceImpl::Terminate(const GURL& presentation_url, |
314 const std::string& presentation_id) { | 316 const std::string& presentation_id) { |
315 DVLOG(2) << "Terminate " << presentation_id; | 317 DVLOG(2) << "Terminate " << presentation_id; |
316 if (controller_delegate_) | 318 if (controller_delegate_) |
317 controller_delegate_->Terminate(render_process_id_, render_frame_id_, | 319 controller_delegate_->Terminate(render_process_id_, render_frame_id_, |
318 presentation_id); | 320 presentation_id); |
319 } | 321 } |
320 | 322 |
321 void PresentationServiceImpl::OnConnectionStateChanged( | 323 void PresentationServiceImpl::OnConnectionStateChanged( |
322 const PresentationSessionInfo& connection, | 324 const PresentationInfo& connection, |
323 const PresentationConnectionStateChangeInfo& info) { | 325 const PresentationConnectionStateChangeInfo& info) { |
324 DVLOG(2) << "PresentationServiceImpl::OnConnectionStateChanged " | 326 DVLOG(2) << "PresentationServiceImpl::OnConnectionStateChanged " |
325 << "[presentation_id]: " << connection.presentation_id | 327 << "[presentation_id]: " << connection.presentation_id |
326 << " [state]: " << info.state; | 328 << " [state]: " << info.state; |
327 DCHECK(client_.get()); | 329 DCHECK(client_.get()); |
328 if (info.state == PRESENTATION_CONNECTION_STATE_CLOSED) { | 330 if (info.state == PRESENTATION_CONNECTION_STATE_CLOSED) { |
329 client_->OnConnectionClosed(connection, info.close_reason, info.message); | 331 client_->OnConnectionClosed(connection, info.close_reason, info.message); |
330 } else { | 332 } else { |
331 client_->OnConnectionStateChanged(connection, info.state); | 333 client_->OnConnectionStateChanged(connection, info.state); |
332 } | 334 } |
333 } | 335 } |
334 | 336 |
335 bool PresentationServiceImpl::FrameMatches( | 337 bool PresentationServiceImpl::FrameMatches( |
336 content::RenderFrameHost* render_frame_host) const { | 338 content::RenderFrameHost* render_frame_host) const { |
337 if (!render_frame_host) | 339 if (!render_frame_host) |
338 return false; | 340 return false; |
339 | 341 |
340 return render_frame_host->GetProcess()->GetID() == render_process_id_ && | 342 return render_frame_host->GetProcess()->GetID() == render_process_id_ && |
341 render_frame_host->GetRoutingID() == render_frame_id_; | 343 render_frame_host->GetRoutingID() == render_frame_id_; |
342 } | 344 } |
343 | 345 |
344 PresentationServiceDelegate* | 346 PresentationServiceDelegate* |
345 PresentationServiceImpl::GetPresentationServiceDelegate() { | 347 PresentationServiceImpl::GetPresentationServiceDelegate() { |
346 return receiver_delegate_ | 348 return receiver_delegate_ |
347 ? static_cast<PresentationServiceDelegate*>(receiver_delegate_) | 349 ? static_cast<PresentationServiceDelegate*>(receiver_delegate_) |
348 : static_cast<PresentationServiceDelegate*>(controller_delegate_); | 350 : static_cast<PresentationServiceDelegate*>(controller_delegate_); |
349 } | 351 } |
350 | 352 |
351 void PresentationServiceImpl::ListenForConnectionMessages( | 353 void PresentationServiceImpl::ListenForConnectionMessages( |
352 const PresentationSessionInfo& session_info) { | 354 const PresentationInfo& presentation_info) { |
353 DVLOG(2) << "ListenForConnectionMessages"; | 355 DVLOG(2) << "ListenForConnectionMessages"; |
354 if (!controller_delegate_) | 356 if (!controller_delegate_) |
355 return; | 357 return; |
356 | 358 |
357 controller_delegate_->ListenForConnectionMessages( | 359 controller_delegate_->ListenForConnectionMessages( |
358 render_process_id_, render_frame_id_, session_info, | 360 render_process_id_, render_frame_id_, presentation_info, |
359 base::Bind(&PresentationServiceImpl::OnConnectionMessages, | 361 base::Bind(&PresentationServiceImpl::OnConnectionMessages, |
360 weak_factory_.GetWeakPtr(), session_info)); | 362 weak_factory_.GetWeakPtr(), presentation_info)); |
361 } | 363 } |
362 | 364 |
363 void PresentationServiceImpl::SetPresentationConnection( | 365 void PresentationServiceImpl::SetPresentationConnection( |
364 const PresentationSessionInfo& session_info, | 366 const PresentationInfo& presentation_info, |
365 blink::mojom::PresentationConnectionPtr controller_connection_ptr, | 367 blink::mojom::PresentationConnectionPtr controller_connection_ptr, |
366 blink::mojom::PresentationConnectionRequest receiver_connection_request) { | 368 blink::mojom::PresentationConnectionRequest receiver_connection_request) { |
367 DVLOG(2) << "SetPresentationConnection"; | 369 DVLOG(2) << "SetPresentationConnection"; |
368 | 370 |
369 if (!controller_delegate_) | 371 if (!controller_delegate_) |
370 return; | 372 return; |
371 | 373 |
372 controller_delegate_->ConnectToPresentation( | 374 controller_delegate_->ConnectToPresentation( |
373 render_process_id_, render_frame_id_, session_info, | 375 render_process_id_, render_frame_id_, presentation_info, |
374 std::move(controller_connection_ptr), | 376 std::move(controller_connection_ptr), |
375 std::move(receiver_connection_request)); | 377 std::move(receiver_connection_request)); |
376 } | 378 } |
377 | 379 |
378 void PresentationServiceImpl::OnConnectionMessages( | 380 void PresentationServiceImpl::OnConnectionMessages( |
379 const PresentationSessionInfo& session_info, | 381 const PresentationInfo& presentation_info, |
380 std::vector<PresentationConnectionMessage> messages) { | 382 std::vector<PresentationConnectionMessage> messages) { |
381 DCHECK(client_); | 383 DCHECK(client_); |
382 | 384 |
383 DVLOG(2) << "OnConnectionMessages [id]: " << session_info.presentation_id; | 385 DVLOG(2) << "OnConnectionMessages [id]: " |
384 client_->OnConnectionMessagesReceived(session_info, std::move(messages)); | 386 << presentation_info.presentation_id; |
387 client_->OnConnectionMessagesReceived(presentation_info, std::move(messages)); | |
385 } | 388 } |
386 | 389 |
387 void PresentationServiceImpl::OnReceiverConnectionAvailable( | 390 void PresentationServiceImpl::OnReceiverConnectionAvailable( |
388 const content::PresentationSessionInfo& session_info, | 391 const content::PresentationInfo& presentation_info, |
389 PresentationConnectionPtr controller_connection_ptr, | 392 PresentationConnectionPtr controller_connection_ptr, |
390 PresentationConnectionRequest receiver_connection_request) { | 393 PresentationConnectionRequest receiver_connection_request) { |
391 DVLOG(2) << "PresentationServiceImpl::OnReceiverConnectionAvailable"; | 394 DVLOG(2) << "PresentationServiceImpl::OnReceiverConnectionAvailable"; |
392 | 395 |
393 client_->OnReceiverConnectionAvailable( | 396 client_->OnReceiverConnectionAvailable( |
394 session_info, std::move(controller_connection_ptr), | 397 presentation_info, std::move(controller_connection_ptr), |
395 std::move(receiver_connection_request)); | 398 std::move(receiver_connection_request)); |
396 } | 399 } |
397 | 400 |
398 void PresentationServiceImpl::DidFinishNavigation( | 401 void PresentationServiceImpl::DidFinishNavigation( |
399 NavigationHandle* navigation_handle) { | 402 NavigationHandle* navigation_handle) { |
400 DVLOG(2) << "PresentationServiceImpl::DidNavigateAnyFrame"; | 403 DVLOG(2) << "PresentationServiceImpl::DidNavigateAnyFrame"; |
401 if (!navigation_handle->HasCommitted() || | 404 if (!navigation_handle->HasCommitted() || |
402 !FrameMatches(navigation_handle->GetRenderFrameHost())) { | 405 !FrameMatches(navigation_handle->GetRenderFrameHost())) { |
403 return; | 406 return; |
404 } | 407 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 void PresentationServiceImpl::Reset() { | 444 void PresentationServiceImpl::Reset() { |
442 DVLOG(2) << "PresentationServiceImpl::Reset"; | 445 DVLOG(2) << "PresentationServiceImpl::Reset"; |
443 | 446 |
444 if (auto* delegate = GetPresentationServiceDelegate()) | 447 if (auto* delegate = GetPresentationServiceDelegate()) |
445 delegate->Reset(render_process_id_, render_frame_id_); | 448 delegate->Reset(render_process_id_, render_frame_id_); |
446 | 449 |
447 default_presentation_urls_.clear(); | 450 default_presentation_urls_.clear(); |
448 | 451 |
449 screen_availability_listeners_.clear(); | 452 screen_availability_listeners_.clear(); |
450 | 453 |
451 start_session_request_id_ = kInvalidRequestSessionId; | 454 start_presentation_request_id_ = kInvalidRequestId; |
452 pending_start_session_cb_.reset(); | 455 pending_start_presentation_cb_.reset(); |
453 | 456 |
454 pending_join_session_cbs_.clear(); | 457 pending_reconnect_presentation_cbs_.clear(); |
455 } | 458 } |
456 | 459 |
457 void PresentationServiceImpl::OnDelegateDestroyed() { | 460 void PresentationServiceImpl::OnDelegateDestroyed() { |
458 DVLOG(2) << "PresentationServiceImpl::OnDelegateDestroyed"; | 461 DVLOG(2) << "PresentationServiceImpl::OnDelegateDestroyed"; |
459 controller_delegate_ = nullptr; | 462 controller_delegate_ = nullptr; |
460 receiver_delegate_ = nullptr; | 463 receiver_delegate_ = nullptr; |
461 Reset(); | 464 Reset(); |
462 } | 465 } |
463 | 466 |
464 void PresentationServiceImpl::OnDefaultPresentationStarted( | 467 void PresentationServiceImpl::OnDefaultPresentationStarted( |
465 const PresentationSessionInfo& connection) { | 468 const PresentationInfo& connection) { |
466 DCHECK(client_.get()); | 469 DCHECK(client_.get()); |
467 client_->OnDefaultSessionStarted(connection); | 470 client_->OnDefaultPresentationStarted(connection); |
468 ListenForConnectionStateChange(connection); | 471 ListenForConnectionStateChange(connection); |
469 } | 472 } |
470 | 473 |
471 PresentationServiceImpl::ScreenAvailabilityListenerImpl:: | 474 PresentationServiceImpl::ScreenAvailabilityListenerImpl:: |
472 ScreenAvailabilityListenerImpl(const GURL& availability_url, | 475 ScreenAvailabilityListenerImpl(const GURL& availability_url, |
473 PresentationServiceImpl* service) | 476 PresentationServiceImpl* service) |
474 : availability_url_(availability_url), service_(service) { | 477 : availability_url_(availability_url), service_(service) { |
475 DCHECK(service_); | 478 DCHECK(service_); |
476 DCHECK(service_->client_.get()); | 479 DCHECK(service_->client_.get()); |
477 } | 480 } |
(...skipping 10 matching lines...) Expand all Loading... | |
488 void PresentationServiceImpl::ScreenAvailabilityListenerImpl | 491 void PresentationServiceImpl::ScreenAvailabilityListenerImpl |
489 ::OnScreenAvailabilityChanged(bool available) { | 492 ::OnScreenAvailabilityChanged(bool available) { |
490 service_->client_->OnScreenAvailabilityUpdated(availability_url_, available); | 493 service_->client_->OnScreenAvailabilityUpdated(availability_url_, available); |
491 } | 494 } |
492 | 495 |
493 void PresentationServiceImpl::ScreenAvailabilityListenerImpl | 496 void PresentationServiceImpl::ScreenAvailabilityListenerImpl |
494 ::OnScreenAvailabilityNotSupported() { | 497 ::OnScreenAvailabilityNotSupported() { |
495 service_->client_->OnScreenAvailabilityNotSupported(availability_url_); | 498 service_->client_->OnScreenAvailabilityNotSupported(availability_url_); |
496 } | 499 } |
497 | 500 |
498 PresentationServiceImpl::NewSessionCallbackWrapper | 501 PresentationServiceImpl::NewPresentationCallbackWrapper :: |
imcheng
2017/03/13 21:17:55
Please fix formatting
mark a. foltz
2017/03/16 19:50:09
Done.
| |
499 ::NewSessionCallbackWrapper(const NewSessionCallback& callback) | 502 NewPresentationCallbackWrapper(const NewPresentationCallback& callback) |
500 : callback_(callback) { | 503 : callback_(callback) {} |
504 | |
505 PresentationServiceImpl::NewPresentationCallbackWrapper :: | |
imcheng
2017/03/13 21:17:55
Please fix formatting
mark a. foltz
2017/03/16 19:50:09
Done.
| |
506 ~NewPresentationCallbackWrapper() { | |
507 if (!callback_.is_null()) | |
508 InvokeNewPresentationCallbackWithError(callback_); | |
501 } | 509 } |
502 | 510 |
503 PresentationServiceImpl::NewSessionCallbackWrapper | 511 void PresentationServiceImpl::NewPresentationCallbackWrapper::Run( |
504 ::~NewSessionCallbackWrapper() { | 512 const base::Optional<PresentationInfo>& presentation_info, |
505 if (!callback_.is_null()) | |
506 InvokeNewSessionCallbackWithError(callback_); | |
507 } | |
508 | |
509 void PresentationServiceImpl::NewSessionCallbackWrapper::Run( | |
510 const base::Optional<PresentationSessionInfo>& session_info, | |
511 const base::Optional<PresentationError>& error) { | 513 const base::Optional<PresentationError>& error) { |
512 DCHECK(!callback_.is_null()); | 514 DCHECK(!callback_.is_null()); |
513 callback_.Run(session_info, error); | 515 callback_.Run(presentation_info, error); |
514 callback_.Reset(); | 516 callback_.Reset(); |
515 } | 517 } |
516 | 518 |
517 } // namespace content | 519 } // namespace content |
OLD | NEW |