Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: content/browser/presentation/presentation_service_impl.cc

Issue 1202963004: Gets presentation ID from route ID upon route creation, and overrides previous presentation ID with… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 398
399 send_message_callback_.reset(new SendMessageMojoCallback(callback)); 399 send_message_callback_.reset(new SendMessageMojoCallback(callback));
400 delegate_->SendMessage( 400 delegate_->SendMessage(
401 render_process_id_, 401 render_process_id_,
402 render_frame_id_, 402 render_frame_id_,
403 GetPresentationSessionMessage(session_message.Pass()), 403 GetPresentationSessionMessage(session_message.Pass()),
404 base::Bind(&PresentationServiceImpl::OnSendMessageCallback, 404 base::Bind(&PresentationServiceImpl::OnSendMessageCallback,
405 weak_factory_.GetWeakPtr())); 405 weak_factory_.GetWeakPtr()));
406 } 406 }
407 407
408 void PresentationServiceImpl::OnSendMessageCallback() { 408 void PresentationServiceImpl::OnSendMessageCallback(bool sent) {
409 // It is possible that Reset() is invoked before receiving this callback. 409 // It is possible that Reset() is invoked before receiving this callback.
410 // So, always check send_message_callback_ for non-null. 410 // So, always check send_message_callback_ for non-null.
411 if (send_message_callback_) { 411 if (send_message_callback_) {
412 send_message_callback_->Run(true); 412 send_message_callback_->Run(sent);
413 send_message_callback_.reset(); 413 send_message_callback_.reset();
414 } 414 }
415 } 415 }
416 416
417 void PresentationServiceImpl::CloseSession( 417 void PresentationServiceImpl::CloseSession(
418 const mojo::String& presentation_url, 418 const mojo::String& presentation_url,
419 const mojo::String& presentation_id) { 419 const mojo::String& presentation_id) {
420 DVLOG(2) << "CloseSession " << presentation_id; 420 DVLOG(2) << "CloseSession " << presentation_id;
421 if (delegate_) 421 if (delegate_)
422 delegate_->CloseSession(render_process_id_, render_frame_id_, 422 delegate_->CloseSession(render_process_id_, render_frame_id_,
(...skipping 27 matching lines...) Expand all
450 450
451 on_session_messages_callback_.reset(new SessionMessagesCallback(callback)); 451 on_session_messages_callback_.reset(new SessionMessagesCallback(callback));
452 delegate_->ListenForSessionMessages( 452 delegate_->ListenForSessionMessages(
453 render_process_id_, render_frame_id_, 453 render_process_id_, render_frame_id_,
454 base::Bind(&PresentationServiceImpl::OnSessionMessages, 454 base::Bind(&PresentationServiceImpl::OnSessionMessages,
455 weak_factory_.GetWeakPtr())); 455 weak_factory_.GetWeakPtr()));
456 } 456 }
457 457
458 void PresentationServiceImpl::OnSessionMessages( 458 void PresentationServiceImpl::OnSessionMessages(
459 scoped_ptr<ScopedVector<PresentationSessionMessage>> messages) { 459 scoped_ptr<ScopedVector<PresentationSessionMessage>> messages) {
460 DCHECK(messages.get() && !messages->empty());
461 if (!on_session_messages_callback_.get()) { 460 if (!on_session_messages_callback_.get()) {
462 // The Reset method of this class was invoked. 461 // The Reset method of this class was invoked.
463 return; 462 return;
464 } 463 }
465 464
466 mojo::Array<presentation::SessionMessagePtr> mojoMessages(messages->size()); 465 if (!messages.get() || messages->empty()) {
467 for (size_t i = 0; i < messages->size(); ++i) { 466 on_session_messages_callback_->Run(
Kevin M 2015/06/24 23:02:07 Add a comment indicating that branch is an error h
haibinlu 2015/06/24 23:25:13 Done.
468 mojoMessages[i] = ToMojoSessionMessage((*messages)[i]); 467 mojo::Array<presentation::SessionMessagePtr>());
468 } else {
469 mojo::Array<presentation::SessionMessagePtr> mojoMessages(messages->size());
470 for (size_t i = 0; i < messages->size(); ++i) {
471 mojoMessages[i] = ToMojoSessionMessage((*messages)[i]);
472 }
473 on_session_messages_callback_->Run(mojoMessages.Pass());
469 } 474 }
470 475
471 on_session_messages_callback_->Run(mojoMessages.Pass());
472 on_session_messages_callback_.reset(); 476 on_session_messages_callback_.reset();
473 } 477 }
474 478
475 void PresentationServiceImpl::DidNavigateAnyFrame( 479 void PresentationServiceImpl::DidNavigateAnyFrame(
476 content::RenderFrameHost* render_frame_host, 480 content::RenderFrameHost* render_frame_host,
477 const content::LoadCommittedDetails& details, 481 const content::LoadCommittedDetails& details,
478 const content::FrameNavigateParams& params) { 482 const content::FrameNavigateParams& params) {
479 DVLOG(2) << "PresentationServiceImpl::DidNavigateAnyFrame"; 483 DVLOG(2) << "PresentationServiceImpl::DidNavigateAnyFrame";
480 if (!FrameMatches(render_frame_host)) 484 if (!FrameMatches(render_frame_host))
481 return; 485 return;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 void PresentationServiceImpl::DefaultSessionStartContext::Reset() { 637 void PresentationServiceImpl::DefaultSessionStartContext::Reset() {
634 ScopedVector<DefaultSessionMojoCallback> callbacks; 638 ScopedVector<DefaultSessionMojoCallback> callbacks;
635 callbacks.swap(callbacks_); 639 callbacks.swap(callbacks_);
636 for (const auto& callback : callbacks) 640 for (const auto& callback : callbacks)
637 callback->Run(presentation::PresentationSessionInfoPtr()); 641 callback->Run(presentation::PresentationSessionInfoPtr());
638 session_.reset(); 642 session_.reset();
639 } 643 }
640 644
641 } // namespace content 645 } // namespace content
642 646
OLDNEW
« no previous file with comments | « content/browser/presentation/presentation_service_impl.h ('k') | content/public/browser/presentation_service_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698