| 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/host/register_support_host_request.h" | 5 #include "remoting/host/register_support_host_request.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 const RegisterCallback& callback) { | 46 const RegisterCallback& callback) { |
| 47 callback_ = callback; | 47 callback_ = callback; |
| 48 | 48 |
| 49 if (!key_pair_.Load(config)) { | 49 if (!key_pair_.Load(config)) { |
| 50 return false; | 50 return false; |
| 51 } | 51 } |
| 52 return true; | 52 return true; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void RegisterSupportHostRequest::OnSignallingConnected( | 55 void RegisterSupportHostRequest::OnSignallingConnected( |
| 56 SignalStrategy* signal_strategy, | 56 SignalStrategy* signal_strategy) { |
| 57 const std::string& jid) { | |
| 58 DCHECK(!callback_.is_null()); | 57 DCHECK(!callback_.is_null()); |
| 59 | 58 |
| 60 message_loop_ = MessageLoop::current(); | 59 message_loop_ = MessageLoop::current(); |
| 61 | 60 |
| 62 iq_sender_.reset(new IqSender(signal_strategy)); | 61 iq_sender_.reset(new IqSender(signal_strategy)); |
| 63 request_.reset(iq_sender_->SendIq( | 62 request_.reset(iq_sender_->SendIq( |
| 64 buzz::STR_SET, kChromotingBotJid, CreateRegistrationRequest(jid), | 63 buzz::STR_SET, kChromotingBotJid, |
| 64 CreateRegistrationRequest(signal_strategy->GetLocalJid()), |
| 65 base::Bind(&RegisterSupportHostRequest::ProcessResponse, | 65 base::Bind(&RegisterSupportHostRequest::ProcessResponse, |
| 66 base::Unretained(this)))); | 66 base::Unretained(this)))); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void RegisterSupportHostRequest::OnSignallingDisconnected() { | 69 void RegisterSupportHostRequest::OnSignallingDisconnected() { |
| 70 if (!message_loop_) { | 70 if (!message_loop_) { |
| 71 // We will reach here with |message_loop_| NULL if the Host's | 71 // We will reach here with |message_loop_| NULL if the Host's |
| 72 // XMPP connection attempt fails. | 72 // XMPP connection attempt fails. |
| 73 CHECK(!callback_.is_null()); | 73 CHECK(!callback_.is_null()); |
| 74 DCHECK(!request_.get()); | 74 DCHECK(!request_.get()); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 void RegisterSupportHostRequest::ProcessResponse(const XmlElement* response) { | 180 void RegisterSupportHostRequest::ProcessResponse(const XmlElement* response) { |
| 181 DCHECK_EQ(message_loop_, MessageLoop::current()); | 181 DCHECK_EQ(message_loop_, MessageLoop::current()); |
| 182 std::string support_id; | 182 std::string support_id; |
| 183 base::TimeDelta lifetime; | 183 base::TimeDelta lifetime; |
| 184 bool success = ParseResponse(response, &support_id, &lifetime); | 184 bool success = ParseResponse(response, &support_id, &lifetime); |
| 185 callback_.Run(success, support_id, lifetime); | 185 callback_.Run(success, support_id, lifetime); |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace remoting | 188 } // namespace remoting |
| OLD | NEW |