Chromium Code Reviews| 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> |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 if (request_session_id != start_session_request_id_) | 300 if (request_session_id != start_session_request_id_) |
| 301 return; | 301 return; |
| 302 | 302 |
| 303 CHECK(pending_start_session_cb_.get()); | 303 CHECK(pending_start_session_cb_.get()); |
| 304 pending_start_session_cb_->Run( | 304 pending_start_session_cb_->Run( |
| 305 blink::mojom::PresentationSessionInfo::From(session_info), | 305 blink::mojom::PresentationSessionInfo::From(session_info), |
| 306 blink::mojom::PresentationErrorPtr()); | 306 blink::mojom::PresentationErrorPtr()); |
| 307 ListenForConnectionStateChange(session_info); | 307 ListenForConnectionStateChange(session_info); |
| 308 pending_start_session_cb_.reset(); | 308 pending_start_session_cb_.reset(); |
| 309 start_session_request_id_ = kInvalidRequestSessionId; | 309 start_session_request_id_ = kInvalidRequestSessionId; |
| 310 OnConnectionStateChanged(session_info, | |
| 311 PresentationConnectionStateChangeInfo( | |
| 312 PRESENTATION_CONNECTION_STATE_CONNECTED)); | |
| 310 } | 313 } |
| 311 | 314 |
| 312 void PresentationServiceImpl::OnStartSessionError( | 315 void PresentationServiceImpl::OnStartSessionError( |
| 313 int request_session_id, | 316 int request_session_id, |
| 314 const PresentationError& error) { | 317 const PresentationError& error) { |
| 315 if (request_session_id != start_session_request_id_) | 318 if (request_session_id != start_session_request_id_) |
| 316 return; | 319 return; |
| 317 | 320 |
| 318 CHECK(pending_start_session_cb_.get()); | 321 CHECK(pending_start_session_cb_.get()); |
| 319 pending_start_session_cb_->Run(blink::mojom::PresentationSessionInfoPtr(), | 322 pending_start_session_cb_->Run(blink::mojom::PresentationSessionInfoPtr(), |
| 320 blink::mojom::PresentationError::From(error)); | 323 blink::mojom::PresentationError::From(error)); |
| 321 pending_start_session_cb_.reset(); | 324 pending_start_session_cb_.reset(); |
| 322 start_session_request_id_ = kInvalidRequestSessionId; | 325 start_session_request_id_ = kInvalidRequestSessionId; |
| 323 } | 326 } |
| 324 | 327 |
| 325 void PresentationServiceImpl::OnJoinSessionSucceeded( | 328 void PresentationServiceImpl::OnJoinSessionSucceeded( |
| 326 int request_session_id, | 329 int request_session_id, |
| 327 const PresentationSessionInfo& session_info) { | 330 const PresentationSessionInfo& session_info) { |
| 328 if (RunAndEraseJoinSessionMojoCallback( | 331 if (RunAndEraseJoinSessionMojoCallback( |
| 329 request_session_id, | 332 request_session_id, |
| 330 blink::mojom::PresentationSessionInfo::From(session_info), | 333 blink::mojom::PresentationSessionInfo::From(session_info), |
| 331 blink::mojom::PresentationErrorPtr())) { | 334 blink::mojom::PresentationErrorPtr())) { |
| 332 ListenForConnectionStateChange(session_info); | 335 ListenForConnectionStateChange(session_info); |
| 336 OnConnectionStateChanged(session_info, | |
| 337 PresentationConnectionStateChangeInfo( | |
| 338 PRESENTATION_CONNECTION_STATE_CONNECTED)); | |
| 333 } | 339 } |
| 334 } | 340 } |
| 335 | 341 |
| 336 void PresentationServiceImpl::OnJoinSessionError( | 342 void PresentationServiceImpl::OnJoinSessionError( |
| 337 int request_session_id, | 343 int request_session_id, |
| 338 const PresentationError& error) { | 344 const PresentationError& error) { |
| 339 RunAndEraseJoinSessionMojoCallback( | 345 RunAndEraseJoinSessionMojoCallback( |
| 340 request_session_id, blink::mojom::PresentationSessionInfoPtr(), | 346 request_session_id, blink::mojom::PresentationSessionInfoPtr(), |
| 341 blink::mojom::PresentationError::From(error)); | 347 blink::mojom::PresentationError::From(error)); |
| 342 } | 348 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 void PresentationServiceImpl::Terminate(const GURL& presentation_url, | 420 void PresentationServiceImpl::Terminate(const GURL& presentation_url, |
| 415 const std::string& presentation_id) { | 421 const std::string& presentation_id) { |
| 416 DVLOG(2) << "Terminate " << presentation_id; | 422 DVLOG(2) << "Terminate " << presentation_id; |
| 417 if (delegate_) | 423 if (delegate_) |
| 418 delegate_->Terminate(render_process_id_, render_frame_id_, presentation_id); | 424 delegate_->Terminate(render_process_id_, render_frame_id_, presentation_id); |
| 419 } | 425 } |
| 420 | 426 |
| 421 void PresentationServiceImpl::OnConnectionStateChanged( | 427 void PresentationServiceImpl::OnConnectionStateChanged( |
| 422 const PresentationSessionInfo& connection, | 428 const PresentationSessionInfo& connection, |
| 423 const PresentationConnectionStateChangeInfo& info) { | 429 const PresentationConnectionStateChangeInfo& info) { |
| 430 DVLOG(2) << "PresentationServiceImpl::OnConnectionStateChanged " | |
| 431 << "[presentation_id]: " << connection.presentation_id | |
| 432 << " [state]: " << info.state; | |
| 424 DCHECK(client_.get()); | 433 DCHECK(client_.get()); |
| 425 if (info.state == PRESENTATION_CONNECTION_STATE_CLOSED) { | 434 if (info.state == PRESENTATION_CONNECTION_STATE_CLOSED) { |
| 426 client_->OnConnectionClosed( | 435 client_->OnConnectionClosed( |
| 427 blink::mojom::PresentationSessionInfo::From(connection), | 436 blink::mojom::PresentationSessionInfo::From(connection), |
| 428 content::PresentationConnectionCloseReasonToMojo(info.close_reason), | 437 content::PresentationConnectionCloseReasonToMojo(info.close_reason), |
| 429 info.message); | 438 info.message); |
| 430 } else { | 439 } else { |
| 431 client_->OnConnectionStateChanged( | 440 client_->OnConnectionStateChanged( |
| 432 blink::mojom::PresentationSessionInfo::From(connection), | 441 blink::mojom::PresentationSessionInfo::From(connection), |
| 433 PresentationConnectionStateToMojo(info.state)); | 442 PresentationConnectionStateToMojo(info.state)); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 DVLOG(2) << "PresentationServiceImpl::OnDelegateDestroyed"; | 558 DVLOG(2) << "PresentationServiceImpl::OnDelegateDestroyed"; |
| 550 delegate_ = nullptr; | 559 delegate_ = nullptr; |
| 551 Reset(); | 560 Reset(); |
| 552 } | 561 } |
| 553 | 562 |
| 554 void PresentationServiceImpl::OnDefaultPresentationStarted( | 563 void PresentationServiceImpl::OnDefaultPresentationStarted( |
| 555 const PresentationSessionInfo& connection) { | 564 const PresentationSessionInfo& connection) { |
| 556 DCHECK(client_.get()); | 565 DCHECK(client_.get()); |
| 557 client_->OnDefaultSessionStarted( | 566 client_->OnDefaultSessionStarted( |
| 558 blink::mojom::PresentationSessionInfo::From(connection)); | 567 blink::mojom::PresentationSessionInfo::From(connection)); |
| 559 ListenForConnectionStateChange(connection); | 568 ListenForConnectionStateChange(connection); |
|
imcheng
2016/11/02 21:04:55
I believe we also need to add the OnConnectionStat
zhaobin
2016/11/03 18:24:31
Done.
| |
| 560 } | 569 } |
| 561 | 570 |
| 562 PresentationServiceImpl::ScreenAvailabilityListenerImpl:: | 571 PresentationServiceImpl::ScreenAvailabilityListenerImpl:: |
| 563 ScreenAvailabilityListenerImpl(const GURL& availability_url, | 572 ScreenAvailabilityListenerImpl(const GURL& availability_url, |
| 564 PresentationServiceImpl* service) | 573 PresentationServiceImpl* service) |
| 565 : availability_url_(availability_url), service_(service) { | 574 : availability_url_(availability_url), service_(service) { |
| 566 DCHECK(service_); | 575 DCHECK(service_); |
| 567 DCHECK(service_->client_.get()); | 576 DCHECK(service_->client_.get()); |
| 568 } | 577 } |
| 569 | 578 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 599 | 608 |
| 600 void PresentationServiceImpl::NewSessionCallbackWrapper::Run( | 609 void PresentationServiceImpl::NewSessionCallbackWrapper::Run( |
| 601 blink::mojom::PresentationSessionInfoPtr session, | 610 blink::mojom::PresentationSessionInfoPtr session, |
| 602 blink::mojom::PresentationErrorPtr error) { | 611 blink::mojom::PresentationErrorPtr error) { |
| 603 DCHECK(!callback_.is_null()); | 612 DCHECK(!callback_.is_null()); |
| 604 callback_.Run(std::move(session), std::move(error)); | 613 callback_.Run(std::move(session), std::move(error)); |
| 605 callback_.Reset(); | 614 callback_.Reset(); |
| 606 } | 615 } |
| 607 | 616 |
| 608 } // namespace content | 617 } // namespace content |
| OLD | NEW |