| Index: remoting/protocol/jingle_session.cc
|
| diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc
|
| index f421b025e6716af41571af663bc24fefa1568f53..89ae6b71b619d0aad7d938331500874356f5eceb 100644
|
| --- a/remoting/protocol/jingle_session.cc
|
| +++ b/remoting/protocol/jingle_session.cc
|
| @@ -7,6 +7,7 @@
|
| #include <stdint.h>
|
|
|
| #include <limits>
|
| +#include <memory>
|
| #include <utility>
|
|
|
| #include "base/bind.h"
|
| @@ -21,6 +22,7 @@
|
| #include "remoting/protocol/jingle_messages.h"
|
| #include "remoting/protocol/jingle_session_manager.h"
|
| #include "remoting/protocol/session_config.h"
|
| +#include "remoting/protocol/session_plugin.h"
|
| #include "remoting/protocol/transport.h"
|
| #include "remoting/signaling/iq_sender.h"
|
| #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
|
| @@ -249,6 +251,7 @@ void JingleSession::AcceptIncomingConnection(
|
| const JingleMessage& initiate_message) {
|
| DCHECK(config_);
|
|
|
| + ExecutePluginsOnIncomingMessage(initiate_message);
|
| // Process the first authentication message.
|
| const buzz::XmlElement* first_auth_message =
|
| initiate_message.description->authenticator_message();
|
| @@ -322,6 +325,7 @@ void JingleSession::SendTransportInfo(
|
| std::unique_ptr<JingleMessage> message(new JingleMessage(
|
| peer_address_, JingleMessage::TRANSPORT_INFO, session_id_));
|
| message->transport_info = std::move(transport_info);
|
| + ExecutePluginsOnOutgoingMessage(message.get());
|
|
|
| std::unique_ptr<buzz::XmlElement> stanza = message->ToXml();
|
| stanza->AddAttr(buzz::QN_ID, GetNextOutgoingId());
|
| @@ -386,9 +390,15 @@ void JingleSession::Close(protocol::ErrorCode error) {
|
| }
|
| }
|
|
|
| +void JingleSession::Attach(std::unique_ptr<SessionPlugin> plugin) {
|
| + DCHECK(plugin);
|
| + plugins_.push_back(std::move(plugin));
|
| +}
|
| +
|
| void JingleSession::SendMessage(std::unique_ptr<JingleMessage> message) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
| + ExecutePluginsOnOutgoingMessage(message.get());
|
| std::unique_ptr<buzz::XmlElement> stanza = message->ToXml();
|
| stanza->AddAttr(buzz::QN_ID, GetNextOutgoingId());
|
|
|
| @@ -482,6 +492,8 @@ void JingleSession::OnTransportInfoResponse(IqRequest* request,
|
| void JingleSession::OnIncomingMessage(const std::string& id,
|
| std::unique_ptr<JingleMessage> message,
|
| const ReplyCallback& reply_callback) {
|
| + DCHECK(message);
|
| + ExecutePluginsOnIncomingMessage(*message);
|
| std::vector<PendingMessage> ordered = message_queue_->OnIncomingMessage(
|
| id, PendingMessage{std::move(message), reply_callback});
|
| base::WeakPtr<JingleSession> self = weak_factory_.GetWeakPtr();
|
| @@ -747,6 +759,20 @@ bool JingleSession::is_session_active() {
|
| state_ == AUTHENTICATING || state_ == AUTHENTICATED;
|
| }
|
|
|
| +void JingleSession::ExecutePluginsOnIncomingMessage(
|
| + const JingleMessage& message) {
|
| + for (const auto& plugin : plugins_) {
|
| + plugin->OnReceiving(state_, message.action, message.attachments);
|
| + }
|
| +}
|
| +
|
| +void JingleSession::ExecutePluginsOnOutgoingMessage(JingleMessage* message) {
|
| + DCHECK(message);
|
| + for (const auto& plugin : plugins_) {
|
| + plugin->OnSending(state_, message->action, &(message->attachments));
|
| + }
|
| +}
|
| +
|
| std::string JingleSession::GetNextOutgoingId() {
|
| return outgoing_id_prefix_ + "_" + base::IntToString(++next_outgoing_id_);
|
| }
|
|
|