| 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/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "jingle/glue/chrome_async_socket.h" | 13 #include "jingle/glue/chrome_async_socket.h" |
| 14 #include "jingle/glue/task_pump.h" | 14 #include "jingle/glue/task_pump.h" |
| 15 #include "jingle/glue/xmpp_client_socket_factory.h" | 15 #include "jingle/glue/xmpp_client_socket_factory.h" |
| 16 #include "jingle/notifier/base/gaia_constants.h" | 16 #include "jingle/notifier/base/gaia_constants.h" |
| 17 #include "jingle/notifier/base/gaia_token_pre_xmpp_auth.h" | 17 #include "jingle/notifier/base/gaia_token_pre_xmpp_auth.h" |
| 18 #include "net/socket/client_socket_factory.h" | 18 #include "net/socket/client_socket_factory.h" |
| 19 #include "net/url_request/url_request_context_getter.h" | 19 #include "net/url_request/url_request_context_getter.h" |
| 20 #include "third_party/libjingle/source/talk/base/thread.h" | 20 #include "third_party/libjingle/source/talk/base/thread.h" |
| 21 #include "third_party/libjingle/source/talk/xmpp/prexmppauth.h" | 21 #include "third_party/libjingle/source/talk/xmpp/prexmppauth.h" |
| 22 #include "third_party/libjingle/source/talk/xmpp/saslcookiemechanism.h" | 22 #include "third_party/libjingle/source/talk/xmpp/saslcookiemechanism.h" |
| 23 | 23 |
| 24 namespace { | |
| 25 | |
| 26 const char kDefaultResourceName[] = "chromoting"; | 24 const char kDefaultResourceName[] = "chromoting"; |
| 27 | 25 |
| 28 // Use 58 seconds keep-alive interval, in case routers terminate | 26 // Use 58 seconds keep-alive interval, in case routers terminate |
| 29 // connections that are idle for more than a minute. | 27 // connections that are idle for more than a minute. |
| 30 const int kKeepAliveIntervalSeconds = 50; | 28 const int kKeepAliveIntervalSeconds = 50; |
| 31 | 29 |
| 32 // Read buffer size used by ChromeAsyncSocket for read and write buffers. Most | 30 // Read buffer size used by ChromeAsyncSocket for read and write buffers. Most |
| 33 // of XMPP messages are smaller than 4kB. | 31 // of XMPP messages are smaller than 4kB. |
| 34 const size_t kReadBufferSize = 4096; | 32 const size_t kReadBufferSize = 4096; |
| 35 const size_t kWriteBufferSize = 4096; | 33 const size_t kWriteBufferSize = 4096; |
| 36 | 34 |
| 37 void DisconnectXmppClient(buzz::XmppClient* client) { | |
| 38 client->Disconnect(); | |
| 39 } | |
| 40 | |
| 41 } // namespace | |
| 42 | |
| 43 namespace remoting { | 35 namespace remoting { |
| 44 | 36 |
| 45 XmppSignalStrategy::XmppSignalStrategy( | 37 XmppSignalStrategy::XmppSignalStrategy( |
| 46 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 38 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 47 const std::string& username, | 39 const std::string& username, |
| 48 const std::string& auth_token, | 40 const std::string& auth_token, |
| 49 const std::string& auth_token_service) | 41 const std::string& auth_token_service) |
| 50 : request_context_getter_(request_context_getter), | 42 : request_context_getter_(request_context_getter), |
| 51 username_(username), | 43 username_(username), |
| 52 auth_token_(auth_token), | 44 auth_token_(auth_token), |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 std::string mechanism = notifier::kDefaultGaiaAuthMechanism; | 235 std::string mechanism = notifier::kDefaultGaiaAuthMechanism; |
| 244 if (settings.token_service() == "oauth2") { | 236 if (settings.token_service() == "oauth2") { |
| 245 mechanism = "X-OAUTH2"; | 237 mechanism = "X-OAUTH2"; |
| 246 } | 238 } |
| 247 | 239 |
| 248 return new notifier::GaiaTokenPreXmppAuth( | 240 return new notifier::GaiaTokenPreXmppAuth( |
| 249 jid.Str(), settings.auth_token(), settings.token_service(), mechanism); | 241 jid.Str(), settings.auth_token(), settings.token_service(), mechanism); |
| 250 } | 242 } |
| 251 | 243 |
| 252 } // namespace remoting | 244 } // namespace remoting |
| OLD | NEW |