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
3 // found in the LICENSE file.
5 #include "chrome/browser/media/router/presentation_session_messages_observer.h"
7 #include "chrome/browser/media/router/media_router.h"
9 namespace media_router
{
11 PresentationSessionMessagesObserver::PresentationSessionMessagesObserver(
12 const content::PresentationSessionMessageCallback
& message_cb
,
13 const MediaRoute::Id
& route_id
,
15 : message_cb_(message_cb
), route_id_(route_id
), router_(router
) {
16 DCHECK(!message_cb_
.is_null());
17 DCHECK(!route_id_
.empty());
19 router_
->RegisterPresentationSessionMessagesObserver(this);
22 PresentationSessionMessagesObserver::~PresentationSessionMessagesObserver() {
23 router_
->UnregisterPresentationSessionMessagesObserver(this);
26 void PresentationSessionMessagesObserver::OnMessagesReceived(
27 const ScopedVector
<content::PresentationSessionMessage
>& messages
,
28 bool pass_ownership
) {
29 DVLOG(2) << __FUNCTION__
<< ", number of messages : " << messages
.size()
30 << " (pass_ownership = " << pass_ownership
<< ")";
31 DCHECK(!messages
.empty());
32 message_cb_
.Run(messages
, pass_ownership
);
35 } // namespace media_router