| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signaling/iq_sender.h" | 5 #include "remoting/signaling/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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" | 
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 139 | 139 | 
| 140 void IqRequest::CallCallback(const buzz::XmlElement* stanza) { | 140 void IqRequest::CallCallback(const buzz::XmlElement* stanza) { | 
| 141   if (!callback_.is_null()) { | 141   if (!callback_.is_null()) { | 
| 142     IqSender::ReplyCallback callback(callback_); | 142     IqSender::ReplyCallback callback(callback_); | 
| 143     callback_.Reset(); | 143     callback_.Reset(); | 
| 144     callback.Run(this, stanza); | 144     callback.Run(this, stanza); | 
| 145   } | 145   } | 
| 146 } | 146 } | 
| 147 | 147 | 
| 148 void IqRequest::OnTimeout() { | 148 void IqRequest::OnTimeout() { | 
| 149   CallCallback(NULL); | 149   CallCallback(nullptr); | 
| 150 } | 150 } | 
| 151 | 151 | 
| 152 void IqRequest::OnResponse(const buzz::XmlElement* stanza) { | 152 void IqRequest::OnResponse(const buzz::XmlElement* stanza) { | 
| 153   // It's unsafe to delete signal strategy here, and the callback may | 153   // It's unsafe to delete signal strategy here, and the callback may | 
| 154   // want to do that, so we post task to invoke the callback later. | 154   // want to do that, so we post task to invoke the callback later. | 
| 155   scoped_ptr<buzz::XmlElement> stanza_copy(new buzz::XmlElement(*stanza)); | 155   scoped_ptr<buzz::XmlElement> stanza_copy(new buzz::XmlElement(*stanza)); | 
| 156   base::ThreadTaskRunnerHandle::Get()->PostTask( | 156   base::ThreadTaskRunnerHandle::Get()->PostTask( | 
| 157       FROM_HERE, base::Bind(&IqRequest::DeliverResponse, AsWeakPtr(), | 157       FROM_HERE, base::Bind(&IqRequest::DeliverResponse, AsWeakPtr(), | 
| 158                             base::Passed(&stanza_copy))); | 158                             base::Passed(&stanza_copy))); | 
| 159 } | 159 } | 
| 160 | 160 | 
| 161 void IqRequest::DeliverResponse(scoped_ptr<buzz::XmlElement> stanza) { | 161 void IqRequest::DeliverResponse(scoped_ptr<buzz::XmlElement> stanza) { | 
| 162   CallCallback(stanza.get()); | 162   CallCallback(stanza.get()); | 
| 163 } | 163 } | 
| 164 | 164 | 
| 165 }  // namespace remoting | 165 }  // namespace remoting | 
| OLD | NEW | 
|---|