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

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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Error handling. Session is either closed or in error state.
468 mojoMessages[i] = ToMojoSessionMessage((*messages)[i]); 467 on_session_messages_callback_->Run(
468 mojo::Array<presentation::SessionMessagePtr>());
469 } else {
470 mojo::Array<presentation::SessionMessagePtr> mojoMessages(messages->size());
471 for (size_t i = 0; i < messages->size(); ++i) {
Kevin M 2015/06/25 22:51:56 for (const auto& next_message : *messages)
haibinlu 2015/06/26 00:12:00 with "for", I can not reverse the array size. mo
472 mojoMessages[i] = ToMojoSessionMessage((*messages)[i]);
473 }
474 on_session_messages_callback_->Run(mojoMessages.Pass());
469 } 475 }
470 476
471 on_session_messages_callback_->Run(mojoMessages.Pass());
472 on_session_messages_callback_.reset(); 477 on_session_messages_callback_.reset();
473 } 478 }
474 479
475 void PresentationServiceImpl::DidNavigateAnyFrame( 480 void PresentationServiceImpl::DidNavigateAnyFrame(
476 content::RenderFrameHost* render_frame_host, 481 content::RenderFrameHost* render_frame_host,
477 const content::LoadCommittedDetails& details, 482 const content::LoadCommittedDetails& details,
478 const content::FrameNavigateParams& params) { 483 const content::FrameNavigateParams& params) {
479 DVLOG(2) << "PresentationServiceImpl::DidNavigateAnyFrame"; 484 DVLOG(2) << "PresentationServiceImpl::DidNavigateAnyFrame";
480 if (!FrameMatches(render_frame_host)) 485 if (!FrameMatches(render_frame_host))
481 return; 486 return;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 void PresentationServiceImpl::DefaultSessionStartContext::Reset() { 638 void PresentationServiceImpl::DefaultSessionStartContext::Reset() {
634 ScopedVector<DefaultSessionMojoCallback> callbacks; 639 ScopedVector<DefaultSessionMojoCallback> callbacks;
635 callbacks.swap(callbacks_); 640 callbacks.swap(callbacks_);
636 for (const auto& callback : callbacks) 641 for (const auto& callback : callbacks)
637 callback->Run(presentation::PresentationSessionInfoPtr()); 642 callback->Run(presentation::PresentationSessionInfoPtr());
638 session_.reset(); 643 session_.reset();
639 } 644 }
640 645
641 } // namespace content 646 } // namespace content
642 647
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698