summaryrefslogtreecommitdiffstats
path: root/remoting/protocol
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-23 12:06:19 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-23 12:06:19 +0000
commitcff2764267289815ebab479e962d066706ccdcac (patch)
tree5b8149ed2cde6f99f1368fa086972f8bc5db23a8 /remoting/protocol
parent4513eb18159fb35272cd619785a3b8295b4a6467 (diff)
downloadchromium_src-cff2764267289815ebab479e962d066706ccdcac.zip
chromium_src-cff2764267289815ebab479e962d066706ccdcac.tar.gz
chromium_src-cff2764267289815ebab479e962d066706ccdcac.tar.bz2
Use scoped_ptr to pass ownership in SignalStrategy.
Updated SignalStrategy and some other code where we pass ownership of XML objects. Review URL: http://codereview.chromium.org/9453001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123222 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol')
-rw-r--r--remoting/protocol/jingle_messages.cc15
-rw-r--r--remoting/protocol/jingle_messages.h7
-rw-r--r--remoting/protocol/pepper_session.cc21
-rw-r--r--remoting/protocol/pepper_session_manager.cc4
4 files changed, 24 insertions, 23 deletions
diff --git a/remoting/protocol/jingle_messages.cc b/remoting/protocol/jingle_messages.cc
index 7863d0c..8fe749d 100644
--- a/remoting/protocol/jingle_messages.cc
+++ b/remoting/protocol/jingle_messages.cc
@@ -268,7 +268,7 @@ bool JingleMessage::ParseXml(const buzz::XmlElement* stanza,
return true;
}
-buzz::XmlElement* JingleMessage::ToXml() {
+scoped_ptr<buzz::XmlElement> JingleMessage::ToXml() {
scoped_ptr<XmlElement> root(
new XmlElement(QName("jabber:client", "iq"), true));
@@ -292,7 +292,7 @@ buzz::XmlElement* JingleMessage::ToXml() {
if (action == SESSION_INFO) {
if (info.get())
jingle_tag->AddElement(new XmlElement(*info.get()));
- return root.release();
+ return root.Pass();
}
if (action == SESSION_INITIATE)
@@ -330,7 +330,7 @@ buzz::XmlElement* JingleMessage::ToXml() {
}
}
- return root.release();
+ return root.Pass();
}
JingleMessageReply::JingleMessageReply()
@@ -352,9 +352,10 @@ JingleMessageReply::JingleMessageReply(ErrorType error,
JingleMessageReply::~JingleMessageReply() { }
-buzz::XmlElement* JingleMessageReply::ToXml(
+scoped_ptr<buzz::XmlElement> JingleMessageReply::ToXml(
const buzz::XmlElement* request_stanza) const {
- XmlElement* iq = new XmlElement(QName(kJabberNamespace, "iq"), true);
+ scoped_ptr<XmlElement> iq(
+ new XmlElement(QName(kJabberNamespace, "iq"), true));
iq->SetAttr(QName(kEmptyNamespace, "to"),
request_stanza->Attr(QName(kEmptyNamespace, "from")));
iq->SetAttr(QName(kEmptyNamespace, "id"),
@@ -362,7 +363,7 @@ buzz::XmlElement* JingleMessageReply::ToXml(
if (type == REPLY_RESULT) {
iq->SetAttr(QName(kEmptyNamespace, "type"), "result");
- return iq;
+ return iq.Pass();
}
DCHECK_EQ(type, REPLY_ERROR);
@@ -430,7 +431,7 @@ buzz::XmlElement* JingleMessageReply::ToXml(
error->AddElement(text_elem);
}
- return iq;
+ return iq.Pass();
}
} // namespace protocol
diff --git a/remoting/protocol/jingle_messages.h b/remoting/protocol/jingle_messages.h
index bcacbf0..03e5063 100644
--- a/remoting/protocol/jingle_messages.h
+++ b/remoting/protocol/jingle_messages.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -57,7 +57,7 @@ struct JingleMessage {
// message when parsing fails.
bool ParseXml(const buzz::XmlElement* stanza, std::string* error);
- buzz::XmlElement* ToXml();
+ scoped_ptr<buzz::XmlElement> ToXml();
std::string from;
std::string to;
@@ -98,7 +98,8 @@ struct JingleMessageReply {
// Formats reply stanza for the specified |request_stanza|. Id and
// recepient as well as other information needed to generate a valid
// reply are taken from |request_stanza|.
- buzz::XmlElement* ToXml(const buzz::XmlElement* request_stanza) const;
+ scoped_ptr<buzz::XmlElement> ToXml(
+ const buzz::XmlElement* request_stanza) const;
ReplyType type;
ErrorType error_type;
diff --git a/remoting/protocol/pepper_session.cc b/remoting/protocol/pepper_session.cc
index 16b961d..0fc8d06 100644
--- a/remoting/protocol/pepper_session.cc
+++ b/remoting/protocol/pepper_session.cc
@@ -102,10 +102,10 @@ void PepperSession::StartConnection(
message.description.reset(
new ContentDescription(candidate_config_->Clone(),
authenticator_->GetNextMessage()));
- initiate_request_.reset(session_manager_->iq_sender()->SendIq(
+ initiate_request_ = session_manager_->iq_sender()->SendIq(
message.ToXml(),
base::Bind(&PepperSession::OnSessionInitiateResponse,
- base::Unretained(this))));
+ base::Unretained(this)));
SetState(CONNECTING);
}
@@ -158,10 +158,10 @@ void PepperSession::AcceptIncomingConnection(
message.description.reset(
new ContentDescription(CandidateSessionConfig::CreateFrom(config_),
auth_message.Pass()));
- initiate_request_.reset(session_manager_->iq_sender()->SendIq(
+ initiate_request_ = session_manager_->iq_sender()->SendIq(
message.ToXml(),
base::Bind(&PepperSession::OnSessionInitiateResponse,
- base::Unretained(this))));
+ base::Unretained(this)));
// Update state.
SetState(CONNECTED);
@@ -452,10 +452,10 @@ void PepperSession::ProcessAuthenticationStep() {
message.info = authenticator_->GetNextMessage();
DCHECK(message.info.get());
- session_info_request_.reset(session_manager_->iq_sender()->SendIq(
+ session_info_request_ = session_manager_->iq_sender()->SendIq(
message.ToXml(), base::Bind(
&PepperSession::OnSessionInfoResponse,
- base::Unretained(this))));
+ base::Unretained(this)));
}
DCHECK_NE(authenticator_->state(), Authenticator::MESSAGE_READY);
@@ -496,10 +496,10 @@ void PepperSession::OnTransportInfoResponse(const buzz::XmlElement* response) {
void PepperSession::SendTransportInfo() {
JingleMessage message(peer_jid_, JingleMessage::TRANSPORT_INFO, session_id_);
message.candidates.swap(pending_candidates_);
- transport_info_request_.reset(session_manager_->iq_sender()->SendIq(
+ transport_info_request_ = session_manager_->iq_sender()->SendIq(
message.ToXml(), base::Bind(
&PepperSession::OnTransportInfoResponse,
- base::Unretained(this))));
+ base::Unretained(this)));
}
@@ -527,9 +527,8 @@ void PepperSession::CloseInternal(Error error) {
JingleMessage message(peer_jid_, JingleMessage::SESSION_TERMINATE,
session_id_);
message.reason = reason;
- scoped_ptr<IqRequest> terminate_request(
- session_manager_->iq_sender()->SendIq(
- message.ToXml(), IqSender::ReplyCallback()));
+ session_manager_->iq_sender()->SendIq(
+ message.ToXml(), IqSender::ReplyCallback());
}
error_ = error;
diff --git a/remoting/protocol/pepper_session_manager.cc b/remoting/protocol/pepper_session_manager.cc
index e6edc02..1024984 100644
--- a/remoting/protocol/pepper_session_manager.cc
+++ b/remoting/protocol/pepper_session_manager.cc
@@ -171,8 +171,8 @@ bool PepperSessionManager::OnSignalStrategyIncomingStanza(
void PepperSessionManager::SendReply(const buzz::XmlElement* original_stanza,
JingleMessageReply::ErrorType error) {
- buzz::XmlElement* stanza = JingleMessageReply(error).ToXml(original_stanza);
- signal_strategy_->SendStanza(stanza);
+ signal_strategy_->SendStanza(
+ JingleMessageReply(error).ToXml(original_stanza));
}
void PepperSessionManager::SessionDestroyed(PepperSession* session) {