| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/iq_sender.h" | 5 #include "remoting/jingle_glue/iq_sender.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 addressee_(addressee) { | 139 addressee_(addressee) { |
| 140 } | 140 } |
| 141 | 141 |
| 142 IqRequest::~IqRequest() { | 142 IqRequest::~IqRequest() { |
| 143 sender_->RemoveRequest(this); | 143 sender_->RemoveRequest(this); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void IqRequest::SetTimeout(base::TimeDelta timeout) { | 146 void IqRequest::SetTimeout(base::TimeDelta timeout) { |
| 147 base::MessageLoopProxy::current()->PostDelayedTask( | 147 base::MessageLoopProxy::current()->PostDelayedTask( |
| 148 FROM_HERE, base::Bind(&IqRequest::OnTimeout, AsWeakPtr()), | 148 FROM_HERE, base::Bind(&IqRequest::OnTimeout, AsWeakPtr()), |
| 149 timeout.InMilliseconds()); | 149 timeout); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void IqRequest::CallCallback(const buzz::XmlElement* stanza) { | 152 void IqRequest::CallCallback(const buzz::XmlElement* stanza) { |
| 153 if (!callback_.is_null()) { | 153 if (!callback_.is_null()) { |
| 154 IqSender::ReplyCallback callback(callback_); | 154 IqSender::ReplyCallback callback(callback_); |
| 155 callback_.Reset(); | 155 callback_.Reset(); |
| 156 callback.Run(this, stanza); | 156 callback.Run(this, stanza); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 void IqRequest::OnTimeout() { | 160 void IqRequest::OnTimeout() { |
| 161 CallCallback(NULL); | 161 CallCallback(NULL); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void IqRequest::OnResponse(const buzz::XmlElement* stanza) { | 164 void IqRequest::OnResponse(const buzz::XmlElement* stanza) { |
| 165 CallCallback(stanza); | 165 CallCallback(stanza); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace remoting | 168 } // namespace remoting |
| OLD | NEW |