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/xmpp_signal_strategy.h" | 5 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" |
8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" |
9 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/thread_task_runner_handle.h" |
10 #include "jingle/glue/chrome_async_socket.h" | 13 #include "jingle/glue/chrome_async_socket.h" |
11 #include "jingle/glue/task_pump.h" | 14 #include "jingle/glue/task_pump.h" |
12 #include "jingle/glue/xmpp_client_socket_factory.h" | 15 #include "jingle/glue/xmpp_client_socket_factory.h" |
13 #include "jingle/notifier/base/gaia_token_pre_xmpp_auth.h" | 16 #include "jingle/notifier/base/gaia_token_pre_xmpp_auth.h" |
14 #include "net/socket/client_socket_factory.h" | 17 #include "net/socket/client_socket_factory.h" |
15 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" |
16 #include "third_party/libjingle/source/talk/base/thread.h" | 19 #include "third_party/libjingle/source/talk/base/thread.h" |
17 #include "third_party/libjingle/source/talk/xmpp/prexmppauth.h" | 20 #include "third_party/libjingle/source/talk/xmpp/prexmppauth.h" |
18 #include "third_party/libjingle/source/talk/xmpp/saslcookiemechanism.h" | 21 #include "third_party/libjingle/source/talk/xmpp/saslcookiemechanism.h" |
19 | 22 |
(...skipping 28 matching lines...) Expand all Loading... |
48 auth_token_(auth_token), | 51 auth_token_(auth_token), |
49 auth_token_service_(auth_token_service), | 52 auth_token_service_(auth_token_service), |
50 resource_name_(kDefaultResourceName), | 53 resource_name_(kDefaultResourceName), |
51 xmpp_client_(NULL), | 54 xmpp_client_(NULL), |
52 state_(DISCONNECTED), | 55 state_(DISCONNECTED), |
53 error_(OK) { | 56 error_(OK) { |
54 } | 57 } |
55 | 58 |
56 XmppSignalStrategy::~XmppSignalStrategy() { | 59 XmppSignalStrategy::~XmppSignalStrategy() { |
57 Disconnect(); | 60 Disconnect(); |
| 61 |
| 62 // Destroying task runner will destroy XmppClient, but XmppClient may be on |
| 63 // the stack and it doesn't handle this case properly, so we need to delay |
| 64 // destruction. |
| 65 base::ThreadTaskRunnerHandle::Get()->DeleteSoon( |
| 66 FROM_HERE, task_runner_.release()); |
58 } | 67 } |
59 | 68 |
60 void XmppSignalStrategy::Connect() { | 69 void XmppSignalStrategy::Connect() { |
61 DCHECK(CalledOnValidThread()); | 70 DCHECK(CalledOnValidThread()); |
62 | 71 |
63 // Disconnect first if we are currently connected. | 72 // Disconnect first if we are currently connected. |
64 Disconnect(); | 73 Disconnect(); |
65 | 74 |
66 buzz::XmppClientSettings settings; | 75 buzz::XmppClientSettings settings; |
67 buzz::Jid login_jid(username_); | 76 buzz::Jid login_jid(username_); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 std::string mechanism = notifier::GaiaTokenPreXmppAuth::kDefaultAuthMechanism; | 242 std::string mechanism = notifier::GaiaTokenPreXmppAuth::kDefaultAuthMechanism; |
234 if (settings.token_service() == "oauth2") { | 243 if (settings.token_service() == "oauth2") { |
235 mechanism = "X-OAUTH2"; | 244 mechanism = "X-OAUTH2"; |
236 } | 245 } |
237 | 246 |
238 return new notifier::GaiaTokenPreXmppAuth( | 247 return new notifier::GaiaTokenPreXmppAuth( |
239 jid.Str(), settings.auth_token(), settings.token_service(), mechanism); | 248 jid.Str(), settings.auth_token(), settings.token_service(), mechanism); |
240 } | 249 } |
241 | 250 |
242 } // namespace remoting | 251 } // namespace remoting |
OLD | NEW |