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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/browser/presentation/presentation_type_converters.h" | 10 #include "content/browser/presentation/presentation_type_converters.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 | 306 |
| 307 // Remove listener for old default presentation URL. | 307 // Remove listener for old default presentation URL. |
| 308 delegate_->RemoveScreenAvailabilityListener( | 308 delegate_->RemoveScreenAvailabilityListener( |
| 309 render_process_id_, | 309 render_process_id_, |
| 310 render_frame_id_, | 310 render_frame_id_, |
| 311 old_it->second.get()); | 311 old_it->second.get()); |
| 312 availability_contexts_.erase(old_it); | 312 availability_contexts_.erase(old_it); |
| 313 DoSetDefaultPresentationUrl(new_default_url, default_presentation_id); | 313 DoSetDefaultPresentationUrl(new_default_url, default_presentation_id); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void PresentationServiceImpl::SendMessage( | |
| 317 presentation::SessionMessagePtr message_request, | |
| 318 const SendMessageMojoCallback& callback) { | |
| 319 DVLOG(2) << "SendMessage"; | |
| 320 DCHECK(!message_request.is_null()); | |
| 321 if (!delegate_) { | |
| 322 callback.Run(true); | |
|
whywhat
2015/04/30 15:50:58
nit: did you want to Run(false) here?
USE s.singapati at gmail.com
2015/05/01 10:30:25
Yes.
USE s.singapati at gmail.com
2015/05/04 16:40:28
Done.
| |
| 323 return; | |
| 324 } | |
| 325 | |
| 326 // send_message_cb_ptr_ should be null by now. | |
| 327 DCHECK(!send_message_cb_ptr_); | |
|
imcheng (use chromium acct)
2015/04/30 20:11:29
instead of DCHECKing and/or dropping the old callb
USE s.singapati at gmail.com
2015/05/04 16:40:28
Done.
| |
| 328 send_message_cb_ptr_.reset(new SendMessageMojoCallback(callback)); | |
| 329 | |
| 330 delegate_->SendMessage( | |
| 331 render_process_id_, | |
| 332 render_frame_id_, | |
| 333 new PresentationMessageRequest( | |
| 334 message_request->presentation_url, | |
| 335 message_request->presentation_id, | |
| 336 static_cast<PresentationMessageType>(message_request->type), | |
|
whywhat
2015/04/30 15:50:58
nit: it'd be safer to have a static function that
imcheng (use chromium acct)
2015/04/30 20:11:29
To add to what Anton said, I think it would be goo
USE s.singapati at gmail.com
2015/05/04 16:40:28
Done for PresentationMessageType conversion.
Need
USE s.singapati at gmail.com
2015/05/05 14:26:36
Done.
| |
| 337 message_request->message, | |
| 338 message_request->data), | |
| 339 base::Bind(&PresentationServiceImpl::OnSendMessageCallback, | |
| 340 weak_factory_.GetWeakPtr())); | |
| 341 } | |
| 342 | |
| 343 void PresentationServiceImpl::OnSendMessageCallback() { | |
| 344 DCHECK(send_message_cb_ptr_); | |
|
imcheng (use chromium acct)
2015/04/30 20:11:29
Hmm, Reset() could have occurred between SendMessa
USE s.singapati at gmail.com
2015/05/04 16:40:27
Done.
| |
| 345 send_message_cb_ptr_->Run(true); | |
| 346 send_message_cb_ptr_.reset(); | |
| 347 } | |
| 348 | |
| 316 void PresentationServiceImpl::CloseSession( | 349 void PresentationServiceImpl::CloseSession( |
| 317 const mojo::String& presentation_url, | 350 const mojo::String& presentation_url, |
| 318 const mojo::String& presentation_id) { | 351 const mojo::String& presentation_id) { |
| 319 NOTIMPLEMENTED(); | 352 NOTIMPLEMENTED(); |
| 320 } | 353 } |
| 321 | 354 |
| 322 void PresentationServiceImpl::ListenForSessionStateChange( | 355 void PresentationServiceImpl::ListenForSessionStateChange( |
| 323 const SessionStateCallback& callback) { | 356 const SessionStateCallback& callback) { |
| 324 NOTIMPLEMENTED(); | 357 NOTIMPLEMENTED(); |
| 325 } | 358 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 DVLOG(2) << "PresentationServiceImpl::Reset"; | 409 DVLOG(2) << "PresentationServiceImpl::Reset"; |
| 377 if (delegate_) | 410 if (delegate_) |
| 378 delegate_->Reset(render_process_id_, render_frame_id_); | 411 delegate_->Reset(render_process_id_, render_frame_id_); |
| 379 | 412 |
| 380 default_presentation_url_.clear(); | 413 default_presentation_url_.clear(); |
| 381 default_presentation_id_.clear(); | 414 default_presentation_id_.clear(); |
| 382 availability_contexts_.clear(); | 415 availability_contexts_.clear(); |
| 383 queued_start_session_requests_.clear(); | 416 queued_start_session_requests_.clear(); |
| 384 FlushNewSessionCallbacks(); | 417 FlushNewSessionCallbacks(); |
| 385 default_session_start_context_.reset(); | 418 default_session_start_context_.reset(); |
| 419 if (send_message_cb_ptr_) { | |
| 420 // Run the callback with false, indicating the renderer to stop sending | |
| 421 // the requests and invalidate all pending requests. | |
| 422 send_message_cb_ptr_->Run(false); | |
| 423 send_message_cb_ptr_.reset(); | |
| 424 } | |
| 386 } | 425 } |
| 387 | 426 |
| 388 // static | 427 // static |
| 389 void PresentationServiceImpl::InvokeNewSessionMojoCallbackWithError( | 428 void PresentationServiceImpl::InvokeNewSessionMojoCallbackWithError( |
| 390 const NewSessionMojoCallback& callback) { | 429 const NewSessionMojoCallback& callback) { |
| 391 callback.Run( | 430 callback.Run( |
| 392 presentation::PresentationSessionInfoPtr(), | 431 presentation::PresentationSessionInfoPtr(), |
| 393 presentation::PresentationError::From( | 432 presentation::PresentationError::From( |
| 394 PresentationError(PRESENTATION_ERROR_UNKNOWN, "Internal error"))); | 433 PresentationError(PRESENTATION_ERROR_UNKNOWN, "Internal error"))); |
| 395 } | 434 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 void PresentationServiceImpl::DefaultSessionStartContext::Reset() { | 564 void PresentationServiceImpl::DefaultSessionStartContext::Reset() { |
| 526 ScopedVector<DefaultSessionMojoCallback> callbacks; | 565 ScopedVector<DefaultSessionMojoCallback> callbacks; |
| 527 callbacks.swap(callbacks_); | 566 callbacks.swap(callbacks_); |
| 528 for (const auto& callback : callbacks) | 567 for (const auto& callback : callbacks) |
| 529 callback->Run(presentation::PresentationSessionInfoPtr()); | 568 callback->Run(presentation::PresentationSessionInfoPtr()); |
| 530 session_.reset(); | 569 session_.reset(); |
| 531 } | 570 } |
| 532 | 571 |
| 533 } // namespace content | 572 } // namespace content |
| 534 | 573 |
| OLD | NEW |