OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signaling/xmpp_signal_strategy.h" | 5 #include "remoting/signaling/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/strings/string_util.h" | 11 #include "base/strings/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" | |
21 #include "third_party/libjingle/source/talk/xmpp/prexmppauth.h" | 20 #include "third_party/libjingle/source/talk/xmpp/prexmppauth.h" |
22 #include "third_party/libjingle/source/talk/xmpp/saslcookiemechanism.h" | 21 #include "third_party/libjingle/source/talk/xmpp/saslcookiemechanism.h" |
| 22 #include "third_party/webrtc/base/thread.h" |
23 | 23 |
24 const char kDefaultResourceName[] = "chromoting"; | 24 const char kDefaultResourceName[] = "chromoting"; |
25 | 25 |
26 // Use 58 seconds keep-alive interval, in case routers terminate | 26 // Use 58 seconds keep-alive interval, in case routers terminate |
27 // connections that are idle for more than a minute. | 27 // connections that are idle for more than a minute. |
28 const int kKeepAliveIntervalSeconds = 50; | 28 const int kKeepAliveIntervalSeconds = 50; |
29 | 29 |
30 // 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 |
31 // of XMPP messages are smaller than 4kB. | 31 // of XMPP messages are smaller than 4kB. |
32 const size_t kReadBufferSize = 4096; | 32 const size_t kReadBufferSize = 4096; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 Disconnect(); | 70 Disconnect(); |
71 | 71 |
72 buzz::XmppClientSettings settings; | 72 buzz::XmppClientSettings settings; |
73 buzz::Jid login_jid(xmpp_server_config_.username); | 73 buzz::Jid login_jid(xmpp_server_config_.username); |
74 settings.set_user(login_jid.node()); | 74 settings.set_user(login_jid.node()); |
75 settings.set_host(login_jid.domain()); | 75 settings.set_host(login_jid.domain()); |
76 settings.set_resource(resource_name_); | 76 settings.set_resource(resource_name_); |
77 settings.set_token_service(xmpp_server_config_.auth_service); | 77 settings.set_token_service(xmpp_server_config_.auth_service); |
78 settings.set_auth_token(buzz::AUTH_MECHANISM_GOOGLE_TOKEN, | 78 settings.set_auth_token(buzz::AUTH_MECHANISM_GOOGLE_TOKEN, |
79 xmpp_server_config_.auth_token); | 79 xmpp_server_config_.auth_token); |
80 settings.set_server(talk_base::SocketAddress( | 80 settings.set_server(rtc::SocketAddress( |
81 xmpp_server_config_.host, xmpp_server_config_.port)); | 81 xmpp_server_config_.host, xmpp_server_config_.port)); |
82 settings.set_use_tls( | 82 settings.set_use_tls( |
83 xmpp_server_config_.use_tls ? buzz::TLS_ENABLED : buzz::TLS_DISABLED); | 83 xmpp_server_config_.use_tls ? buzz::TLS_ENABLED : buzz::TLS_DISABLED); |
84 | 84 |
85 scoped_ptr<jingle_glue::XmppClientSocketFactory> xmpp_socket_factory( | 85 scoped_ptr<jingle_glue::XmppClientSocketFactory> xmpp_socket_factory( |
86 new jingle_glue::XmppClientSocketFactory( | 86 new jingle_glue::XmppClientSocketFactory( |
87 socket_factory_, net::SSLConfig(), request_context_getter_, false)); | 87 socket_factory_, net::SSLConfig(), request_context_getter_, false)); |
88 buzz::AsyncSocket* socket = new jingle_glue::ChromeAsyncSocket( | 88 buzz::AsyncSocket* socket = new jingle_glue::ChromeAsyncSocket( |
89 xmpp_socket_factory.release(), kReadBufferSize, kWriteBufferSize); | 89 xmpp_socket_factory.release(), kReadBufferSize, kWriteBufferSize); |
90 | 90 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 std::string mechanism = notifier::kDefaultGaiaAuthMechanism; | 242 std::string mechanism = notifier::kDefaultGaiaAuthMechanism; |
243 if (settings.token_service() == "oauth2") { | 243 if (settings.token_service() == "oauth2") { |
244 mechanism = "X-OAUTH2"; | 244 mechanism = "X-OAUTH2"; |
245 } | 245 } |
246 | 246 |
247 return new notifier::GaiaTokenPreXmppAuth( | 247 return new notifier::GaiaTokenPreXmppAuth( |
248 jid.Str(), settings.auth_token(), settings.token_service(), mechanism); | 248 jid.Str(), settings.auth_token(), settings.token_service(), mechanism); |
249 } | 249 } |
250 | 250 |
251 } // namespace remoting | 251 } // namespace remoting |
OLD | NEW |