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/logging.h" | 8 #include "base/logging.h" |
8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
9 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
10 #include "base/time.h" | 11 #include "base/time.h" |
11 #include "remoting/base/constants.h" | 12 #include "remoting/base/constants.h" |
12 #include "remoting/host/host_config.h" | 13 #include "remoting/host/host_config.h" |
13 #include "remoting/jingle_glue/iq_request.h" | 14 #include "remoting/jingle_glue/iq_request.h" |
14 #include "remoting/jingle_glue/jingle_thread.h" | 15 #include "remoting/jingle_glue/jingle_thread.h" |
15 #include "remoting/jingle_glue/signal_strategy.h" | 16 #include "remoting/jingle_glue/signal_strategy.h" |
16 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 17 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 53 } |
53 | 54 |
54 void RegisterSupportHostRequest::OnSignallingConnected( | 55 void RegisterSupportHostRequest::OnSignallingConnected( |
55 SignalStrategy* signal_strategy, | 56 SignalStrategy* signal_strategy, |
56 const std::string& jid) { | 57 const std::string& jid) { |
57 DCHECK(!callback_.is_null()); | 58 DCHECK(!callback_.is_null()); |
58 | 59 |
59 message_loop_ = MessageLoop::current(); | 60 message_loop_ = MessageLoop::current(); |
60 | 61 |
61 request_.reset(signal_strategy->CreateIqRequest()); | 62 request_.reset(signal_strategy->CreateIqRequest()); |
62 request_->set_callback(NewCallback( | 63 request_->set_callback(base::Bind( |
63 this, &RegisterSupportHostRequest::ProcessResponse)); | 64 &RegisterSupportHostRequest::ProcessResponse, base::Unretained(this))); |
64 | 65 |
65 request_->SendIq(buzz::STR_SET, kChromotingBotJid, | 66 request_->SendIq(buzz::STR_SET, kChromotingBotJid, |
66 CreateRegistrationRequest(jid)); | 67 CreateRegistrationRequest(jid)); |
67 } | 68 } |
68 | 69 |
69 void RegisterSupportHostRequest::OnSignallingDisconnected() { | 70 void RegisterSupportHostRequest::OnSignallingDisconnected() { |
70 if (!message_loop_) { | 71 if (!message_loop_) { |
71 // We will reach here with |message_loop_| NULL if the Host's | 72 // We will reach here with |message_loop_| NULL if the Host's |
72 // XMPP connection attempt fails. | 73 // XMPP connection attempt fails. |
73 CHECK(!callback_.is_null()); | 74 CHECK(!callback_.is_null()); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 176 |
176 void RegisterSupportHostRequest::ProcessResponse(const XmlElement* response) { | 177 void RegisterSupportHostRequest::ProcessResponse(const XmlElement* response) { |
177 DCHECK_EQ(message_loop_, MessageLoop::current()); | 178 DCHECK_EQ(message_loop_, MessageLoop::current()); |
178 std::string support_id; | 179 std::string support_id; |
179 base::TimeDelta lifetime; | 180 base::TimeDelta lifetime; |
180 bool success = ParseResponse(response, &support_id, &lifetime); | 181 bool success = ParseResponse(response, &support_id, &lifetime); |
181 callback_.Run(success, support_id, lifetime); | 182 callback_.Run(success, support_id, lifetime); |
182 } | 183 } |
183 | 184 |
184 } // namespace remoting | 185 } // namespace remoting |
OLD | NEW |