OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // TODO(ajwong): Check the initialization sentinels. Can we base it off of | 5 // TODO(ajwong): Check the initialization sentinels. Can we base it off of |
6 // state_ instead of a member variable? Also, we assign and read from a few of | 6 // state_ instead of a member variable? Also, we assign and read from a few of |
7 // the member variables on two threads. We need to audit this for thread | 7 // the member variables on two threads. We need to audit this for thread |
8 // safety. | 8 // safety. |
9 | 9 |
10 #include "remoting/jingle_glue/jingle_client.h" | 10 #include "remoting/jingle_glue/jingle_client.h" |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/waitable_event.h" | 13 #include "base/waitable_event.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "chrome/common/net/notifier/communicator/gaia_token_pre_xmpp_auth.h" | 15 #include "remoting/jingle_glue/gaia_token_pre_xmpp_auth.h" |
16 #include "chrome/common/net/notifier/communicator/xmpp_socket_adapter.h" | |
17 #include "remoting/jingle_glue/jingle_thread.h" | 16 #include "remoting/jingle_glue/jingle_thread.h" |
18 #include "remoting/jingle_glue/relay_port_allocator.h" | 17 #include "remoting/jingle_glue/relay_port_allocator.h" |
| 18 #include "remoting/jingle_glue/xmpp_socket_adapter.h" |
19 #include "third_party/libjingle/source/talk/base/asyncsocket.h" | 19 #include "third_party/libjingle/source/talk/base/asyncsocket.h" |
20 #include "third_party/libjingle/source/talk/base/ssladapter.h" | 20 #include "third_party/libjingle/source/talk/base/ssladapter.h" |
21 #include "third_party/libjingle/source/talk/p2p/base/sessionmanager.h" | 21 #include "third_party/libjingle/source/talk/p2p/base/sessionmanager.h" |
22 #include "third_party/libjingle/source/talk/p2p/client/sessionmanagertask.h" | 22 #include "third_party/libjingle/source/talk/p2p/client/sessionmanagertask.h" |
23 #ifdef USE_SSL_TUNNEL | 23 #ifdef USE_SSL_TUNNEL |
24 #include "third_party/libjingle/source/talk/session/tunnel/securetunnelsessioncl
ient.h" | 24 #include "third_party/libjingle/source/talk/session/tunnel/securetunnelsessioncl
ient.h" |
25 #endif | 25 #endif |
26 #include "third_party/libjingle/source/talk/session/tunnel/tunnelsessionclient.h
" | 26 #include "third_party/libjingle/source/talk/session/tunnel/tunnelsessionclient.h
" |
27 #include "third_party/libjingle/source/talk/xmpp/prexmppauth.h" | 27 #include "third_party/libjingle/source/talk/xmpp/prexmppauth.h" |
28 #include "third_party/libjingle/source/talk/xmpp/saslcookiemechanism.h" | 28 #include "third_party/libjingle/source/talk/xmpp/saslcookiemechanism.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 settings.set_resource("chromoting"); | 113 settings.set_resource("chromoting"); |
114 settings.set_use_tls(true); | 114 settings.set_use_tls(true); |
115 settings.set_token_service(auth_token_service); | 115 settings.set_token_service(auth_token_service); |
116 settings.set_auth_cookie(auth_token); | 116 settings.set_auth_cookie(auth_token); |
117 settings.set_server(talk_base::SocketAddress("talk.google.com", 5222)); | 117 settings.set_server(talk_base::SocketAddress("talk.google.com", 5222)); |
118 | 118 |
119 client_ = new buzz::XmppClient(thread_->task_pump()); | 119 client_ = new buzz::XmppClient(thread_->task_pump()); |
120 client_->SignalStateChange.connect( | 120 client_->SignalStateChange.connect( |
121 this, &JingleClient::OnConnectionStateChanged); | 121 this, &JingleClient::OnConnectionStateChanged); |
122 | 122 |
123 buzz::AsyncSocket* socket = | 123 buzz::AsyncSocket* socket = new XmppSocketAdapter(settings, false); |
124 new notifier::XmppSocketAdapter(settings, false); | |
125 | 124 |
126 client_->Connect(settings, "", socket, CreatePreXmppAuth(settings)); | 125 client_->Connect(settings, "", socket, CreatePreXmppAuth(settings)); |
127 client_->Start(); | 126 client_->Start(); |
128 | 127 |
129 network_manager_.reset(new talk_base::NetworkManager()); | 128 network_manager_.reset(new talk_base::NetworkManager()); |
130 | 129 |
131 RelayPortAllocator* port_allocator = | 130 RelayPortAllocator* port_allocator = |
132 new RelayPortAllocator(network_manager_.get(), "transp2"); | 131 new RelayPortAllocator(network_manager_.get(), "transp2"); |
133 port_allocator_.reset(port_allocator); | 132 port_allocator_.reset(port_allocator); |
134 port_allocator->SetJingleInfo(client_); | 133 port_allocator->SetJingleInfo(client_); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 if (new_state != state_) { | 213 if (new_state != state_) { |
215 state_ = new_state; | 214 state_ = new_state; |
216 if (callback_) | 215 if (callback_) |
217 callback_->OnStateChange(this, new_state); | 216 callback_->OnStateChange(this, new_state); |
218 } | 217 } |
219 } | 218 } |
220 | 219 |
221 buzz::PreXmppAuth* JingleClient::CreatePreXmppAuth( | 220 buzz::PreXmppAuth* JingleClient::CreatePreXmppAuth( |
222 const buzz::XmppClientSettings& settings) { | 221 const buzz::XmppClientSettings& settings) { |
223 buzz::Jid jid(settings.user(), settings.host(), buzz::STR_EMPTY); | 222 buzz::Jid jid(settings.user(), settings.host(), buzz::STR_EMPTY); |
224 return new notifier::GaiaTokenPreXmppAuth(jid.Str(), settings.auth_cookie(), | 223 return new GaiaTokenPreXmppAuth(jid.Str(), settings.auth_cookie(), |
225 settings.token_service()); | 224 settings.token_service()); |
226 } | 225 } |
227 | 226 |
228 } // namespace remoting | 227 } // namespace remoting |
OLD | NEW |