diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-23 12:06:19 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-23 12:06:19 +0000 |
commit | cff2764267289815ebab479e962d066706ccdcac (patch) | |
tree | 5b8149ed2cde6f99f1368fa086972f8bc5db23a8 /remoting/jingle_glue/iq_sender.cc | |
parent | 4513eb18159fb35272cd619785a3b8295b4a6467 (diff) | |
download | chromium_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/jingle_glue/iq_sender.cc')
-rw-r--r-- | remoting/jingle_glue/iq_sender.cc | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/remoting/jingle_glue/iq_sender.cc b/remoting/jingle_glue/iq_sender.cc index d22e0f8..eb8f17a 100644 --- a/remoting/jingle_glue/iq_sender.cc +++ b/remoting/jingle_glue/iq_sender.cc @@ -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. @@ -13,15 +13,16 @@ namespace remoting { // static -buzz::XmlElement* IqSender::MakeIqStanza(const std::string& type, - const std::string& addressee, - buzz::XmlElement* iq_body) { - buzz::XmlElement* stanza = new buzz::XmlElement(buzz::QN_IQ); +scoped_ptr<buzz::XmlElement> IqSender::MakeIqStanza( + const std::string& type, + const std::string& addressee, + scoped_ptr<buzz::XmlElement> iq_body) { + scoped_ptr<buzz::XmlElement> stanza(new buzz::XmlElement(buzz::QN_IQ)); stanza->AddAttr(buzz::QN_TYPE, type); if (!addressee.empty()) stanza->AddAttr(buzz::QN_TO, addressee); - stanza->AddElement(iq_body); - return stanza; + stanza->AddElement(iq_body.release()); + return stanza.Pass(); } IqSender::IqSender(SignalStrategy* signal_strategy) @@ -33,25 +34,25 @@ IqSender::~IqSender() { signal_strategy_->RemoveListener(this); } -IqRequest* IqSender::SendIq(buzz::XmlElement* stanza, - const ReplyCallback& callback) { +scoped_ptr<IqRequest> IqSender::SendIq(scoped_ptr<buzz::XmlElement> stanza, + const ReplyCallback& callback) { std::string id = signal_strategy_->GetNextId(); stanza->AddAttr(buzz::QN_ID, id); - if (!signal_strategy_->SendStanza(stanza)) { - return NULL; + if (!signal_strategy_->SendStanza(stanza.Pass())) { + return scoped_ptr<IqRequest>(NULL); } DCHECK(requests_.find(id) == requests_.end()); - IqRequest* request = new IqRequest(this, callback); + scoped_ptr<IqRequest> request(new IqRequest(this, callback)); if (!callback.is_null()) - requests_[id] = request; - return request; + requests_[id] = request.get(); + return request.Pass(); } -IqRequest* IqSender::SendIq(const std::string& type, - const std::string& addressee, - buzz::XmlElement* iq_body, - const ReplyCallback& callback) { - return SendIq(MakeIqStanza(type, addressee, iq_body), callback); +scoped_ptr<IqRequest> IqSender::SendIq(const std::string& type, + const std::string& addressee, + scoped_ptr<buzz::XmlElement> iq_body, + const ReplyCallback& callback) { + return SendIq(MakeIqStanza(type, addressee, iq_body.Pass()), callback); } void IqSender::RemoveRequest(IqRequest* request) { |