Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: remoting/host/register_support_host_request.cc

Issue 7744041: Use new callbacks in the IqRequest interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « remoting/host/heartbeat_sender.cc ('k') | remoting/host/register_support_host_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698