OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "remoting/jingle_glue/xmpp_iq_request.h" | 5 #include "remoting/jingle_glue/xmpp_iq_request.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "third_party/libjingle/source/talk/xmpp/constants.h" | 9 #include "third_party/libjingle/source/talk/xmpp/constants.h" |
10 #include "third_party/libjingle/source/talk/xmpp/xmppclient.h" | 10 #include "third_party/libjingle/source/talk/xmpp/xmppclient.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 Unregister(); | 34 Unregister(); |
35 | 35 |
36 DCHECK_GT(type.length(), 0U); | 36 DCHECK_GT(type.length(), 0U); |
37 | 37 |
38 scoped_ptr<buzz::XmlElement> stanza(MakeIqStanza(type, addressee, iq_body, | 38 scoped_ptr<buzz::XmlElement> stanza(MakeIqStanza(type, addressee, iq_body, |
39 xmpp_client_->NextId())); | 39 xmpp_client_->NextId())); |
40 | 40 |
41 xmpp_client_->engine()->SendIq(stanza.get(), this, &cookie_); | 41 xmpp_client_->engine()->SendIq(stanza.get(), this, &cookie_); |
42 } | 42 } |
43 | 43 |
44 void XmppIqRequest::set_callback(ReplyCallback* callback) { | 44 void XmppIqRequest::set_callback(const ReplyCallback& callback) { |
45 callback_.reset(callback); | 45 callback_ = callback; |
46 } | 46 } |
47 | 47 |
48 void XmppIqRequest::Unregister() { | 48 void XmppIqRequest::Unregister() { |
49 if (cookie_) { | 49 if (cookie_) { |
50 // No need to unregister the handler if the client has been destroyed. | 50 // No need to unregister the handler if the client has been destroyed. |
51 if (xmpp_client_) { | 51 if (xmpp_client_) { |
52 xmpp_client_->engine()->RemoveIqHandler(cookie_, NULL); | 52 xmpp_client_->engine()->RemoveIqHandler(cookie_, NULL); |
53 } | 53 } |
54 cookie_ = NULL; | 54 cookie_ = NULL; |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 void XmppIqRequest::IqResponse(buzz::XmppIqCookie cookie, | 58 void XmppIqRequest::IqResponse(buzz::XmppIqCookie cookie, |
59 const buzz::XmlElement* stanza) { | 59 const buzz::XmlElement* stanza) { |
60 if (callback_.get() != NULL) { | 60 if (callback_.is_null()) { |
61 callback_->Run(stanza); | 61 callback_.Run(stanza); |
| 62 callback_.Reset(); |
62 } | 63 } |
63 } | 64 } |
64 | 65 |
65 } // namespace remoting | 66 } // namespace remoting |
OLD | NEW |